33set -eux
44
55export RUST_BACKTRACE=" ${RUST_BACKTRACE:- full} "
6+ export NEXTEST_STATUS_LEVEL=all
67
78target=" ${1:- } "
9+ flags=" "
810
911if [ -z " $target " ]; then
1012 host_target=$( rustc -vV | awk ' /^host/ { print $2 }' )
@@ -13,22 +15,22 @@ if [ -z "$target" ]; then
1315fi
1416
1517# We enumerate features manually.
16- extra_flags= " --no-default-features"
18+ flags= " $flags --no-default-features"
1719
1820# Enable arch-specific routines when available.
19- extra_flags =" $extra_flags --features arch"
21+ flags =" $flags --features arch"
2022
2123# Always enable `unstable-float` since it expands available API but does not
2224# change any implementations.
23- extra_flags =" $extra_flags --features unstable-float"
25+ flags =" $flags --features unstable-float"
2426
2527# We need to specifically skip tests for musl-math-sys on systems that can't
2628# build musl since otherwise `--all` will activate it.
2729case " $target " in
2830 # Can't build at all on MSVC, WASM, or thumb
29- * windows-msvc* ) extra_flags =" $extra_flags --exclude musl-math-sys" ;;
30- * wasm* ) extra_flags =" $extra_flags --exclude musl-math-sys" ;;
31- * thumb* ) extra_flags =" $extra_flags --exclude musl-math-sys" ;;
31+ * windows-msvc* ) flags =" $flags --exclude musl-math-sys" ;;
32+ * wasm* ) flags =" $flags --exclude musl-math-sys" ;;
33+ * thumb* ) flags =" $flags --exclude musl-math-sys" ;;
3234
3335 # We can build musl on MinGW but running tests gets a stack overflow
3436 * windows-gnu* ) ;;
@@ -38,7 +40,7 @@ case "$target" in
3840 * powerpc64le* ) ;;
3941
4042 # Everything else gets musl enabled
41- * ) extra_flags =" $extra_flags --features libm-test/build-musl" ;;
43+ * ) flags =" $flags --features libm-test/build-musl" ;;
4244esac
4345
4446# Configure which targets test against MPFR
@@ -50,17 +52,17 @@ case "$target" in
5052 # Targets that aren't cross compiled work fine
5153 # FIXME(ci): we should be able to enable aarch64 Linux here once GHA
5254 # support rolls out.
53- x86_64* ) extra_flags =" $extra_flags --features libm-test/build-mpfr" ;;
54- i686* ) extra_flags =" $extra_flags --features libm-test/build-mpfr" ;;
55- i586* ) extra_flags =" $extra_flags --features libm-test/build-mpfr --features gmp-mpfr-sys/force-cross" ;;
55+ x86_64* ) flags =" $flags --features libm-test/build-mpfr" ;;
56+ i686* ) flags =" $flags --features libm-test/build-mpfr" ;;
57+ i586* ) flags =" $flags --features libm-test/build-mpfr --features gmp-mpfr-sys/force-cross" ;;
5658 # Apple aarch64 is native
57- aarch64* apple* ) extra_flags =" $extra_flags --features libm-test/build-mpfr" ;;
59+ aarch64* apple* ) flags =" $flags --features libm-test/build-mpfr" ;;
5860esac
5961
6062# FIXME: `STATUS_DLL_NOT_FOUND` testing macros on CI.
6163# <https://github.com/rust-lang/rust/issues/128944>
6264case " $target " in
63- * windows-gnu) extra_flags =" $extra_flags --exclude libm-macros" ;;
65+ * windows-gnu) flags =" $flags --exclude libm-macros" ;;
6466esac
6567
6668# Make sure we can build with overriding features.
@@ -76,13 +78,31 @@ if [ "${BUILD_ONLY:-}" = "1" ]; then
7678 exit
7779fi
7880
79- # Otherwise, run the test suite.
80-
81- cmd=" cargo test --all --target $target $extra_flags "
81+ flags=" $flags --all --target $target "
82+ cmd=" cargo test $flags "
83+ profile=" --profile"
84+
85+ # If nextest is available, use that
86+ command -v cargo-nextest && nextest=1 || nextest=0
87+ if [ " $nextest " = " 1" ]; then
88+ # Workaround for https://github.com/nextest-rs/nextest/issues/2066
89+ if [ -f /.dockerenv ]; then
90+ cfg_file=" /tmp/nextest-config.toml"
91+ echo " [store]" >> " $cfg_file "
92+ echo " dir = \" $CARGO_TARGET_DIR /nextest\" " >> " $cfg_file "
93+ cfg_flag=" --config-file $cfg_file "
94+ fi
95+
96+ cmd=" cargo nextest run ${cfg_flag:- } $flags "
97+ profile=" --cargo-profile"
98+ fi
8299
83100# Test once without intrinsics
84101$cmd
85102
103+ # Run doctests if they were excluded by nextest
104+ [ " $nextest " = " 1" ] && cargo test --doc $flags
105+
86106# Exclude the macros and utile crates from the rest of the tests to save CI
87107# runtime, they shouldn't have anything feature- or opt-level-dependent.
88108cmd=" $cmd --exclude util --exclude libm-macros"
@@ -93,10 +113,10 @@ $cmd --features unstable-intrinsics --benches
93113
94114# Test the same in release mode, which also increases coverage. Also ensure
95115# the soft float routines are checked.
96- $cmd -- profile release-checked
97- $cmd -- profile release-checked --features force-soft-floats
98- $cmd -- profile release-checked --features unstable-intrinsics
99- $cmd -- profile release-checked --features unstable-intrinsics --benches
116+ $cmd " $ profile" release-checked
117+ $cmd " $ profile" release-checked --features force-soft-floats
118+ $cmd " $ profile" release-checked --features unstable-intrinsics
119+ $cmd " $ profile" release-checked --features unstable-intrinsics --benches
100120
101121# Ensure that the routines do not panic.
102122ENSURE_NO_PANIC=1 cargo build -p libm --target " $target " --no-default-features --release
0 commit comments