Enable build-mpfr and build-musl by default

Most users who are developing this crate are likely running on a Unix
system, since there isn't much to test against otherwise. For
convenience, enable the features required to run these tests by default.
This commit is contained in:
Trevor Gross 2025-01-13 03:17:54 +00:00
parent 504616d5a0
commit 3de783c40f
4 changed files with 22 additions and 23 deletions

View file

@ -131,10 +131,7 @@ jobs:
- uses: Swatinem/rust-cache@v2
- name: Download musl source
run: ./ci/download-musl.sh
- run: |
cargo clippy --all \
--features libm-test/build-musl,libm-test/build-mpfr \
--all-targets
- run: cargo clippy --all --all-features --all-targets
builtins:
name: Check use with compiler-builtins

View file

@ -62,15 +62,12 @@ Check [PR #65] for an example.
Normal tests can be executed with:
```sh
cargo test
# `--release` ables more test cases
cargo test --release
```
If you'd like to run tests with randomized inputs that get compared against
infinite-precision results, run:
```sh
cargo test --features libm-test/build-mpfr,libm-test/build-musl --release
```
If you are on a system that cannot build musl or MPFR, passing
`--no-default-features` will run some limited tests.
The multiprecision tests use the [`rug`] crate for bindings to MPFR. MPFR can
be difficult to build on non-Unix systems, refer to [`gmp_mpfr_sys`] for help.

View file

@ -14,7 +14,15 @@ if [ -z "$target" ]; then
target="$host_target"
fi
extra_flags=""
# We enumerate features manually.
extra_flags="--no-default-features"
# Enable arch-specific routines when available.
extra_flags="$extra_flags --features arch"
# Always enable `unstable-float` since it expands available API but does not
# change any implementations.
extra_flags="$extra_flags --features unstable-float"
# We need to specifically skip tests for musl-math-sys on systems that can't
# build musl since otherwise `--all` will activate it.
@ -57,14 +65,8 @@ case "$target" in
*windows-gnu) extra_flags="$extra_flags --exclude libm-macros" ;;
esac
# Make sure we can build with overriding features. We test the indibidual
# features it controls separately.
cargo check --no-default-features
cargo check --features "force-soft-floats"
# Always enable `unstable-float` since it expands available API but does not
# change any implementations.
extra_flags="$extra_flags --features unstable-float"
# Make sure we can build with overriding features.
cargo check -p libm --no-default-features
if [ "${BUILD_ONLY:-}" = "1" ]; then
cmd="cargo build --target $target --package libm"
@ -80,11 +82,14 @@ else
$cmd --features unstable-intrinsics
$cmd --features unstable-intrinsics --benches
# Test the same in release mode, which also increases coverage.
# Test the same in release mode, which also increases coverage. Also ensure
# the soft float routines are checked.
$cmd --profile release-checked
$cmd --profile release-checked --features force-soft-floats
$cmd --profile release-checked --features unstable-intrinsics
$cmd --profile release-checked --features unstable-intrinsics --benches
ENSURE_NO_PANIC=1 cargo build --target "$target" --release
# Ensure that the routines do not panic.
ENSURE_NO_PANIC=1 cargo build -p libm --target "$target" --no-default-features --release
fi

View file

@ -5,7 +5,7 @@ edition = "2021"
publish = false
[features]
default = ["unstable-float"]
default = ["build-mpfr", "build-musl", "unstable-float"]
# Propagated from libm because this affects which functions we test.
unstable-float = ["libm/unstable-float", "rug?/nightly-float"]