Trevor Gross 26df5d6689 Use cargo-nextest for running tests in CI
The test suite for this repo has quite a lot of tests, and it is
difficult to tell which contribute the most to the long CI runtime.
libtest does have an unstable flag to report test times, but that is
inconvenient to use because it needs to be passed only to libtest
binaries.

Switch to cargo-nextest [1] which provides time reporting and, overall,
a better test UI. It may also improve test runtime, though this seems
unlikely since we have larger test binaries with many small tests
(nextest benefits the most when there are larger binaries that can be
run in parallel).

For anyone running locally without, `run.sh` should still fall back to
`cargo test` if `cargo-nextest` is not available.

This diff includes some cleanup and consistency changes to other
CI-related files.

[1]: https://nexte.st
2025-01-13 21:32:54 -05:00

57 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# Small script to run tests for a target (or all targets) inside all the
# respective docker images.
set -euxo pipefail
host_arch="$(uname -m | sed 's/arm64/aarch64/')"
run() {
local target=$1
echo "testing target: $target"
target_arch="$(echo "$target" | cut -d'-' -f1)"
emulated=""
if [ "$target_arch" != "$host_arch" ]; then
emulated=1
echo "target is emulated"
fi
# This directory needs to exist before calling docker, otherwise docker will create it but it
# will be owned by root
mkdir -p target
set_env="HOME=/tmp PATH=\$PATH:/rust/bin:/cargo/bin"
docker build -t "libm-$target" "ci/docker/$target"
docker run \
--rm \
--user "$(id -u):$(id -g)" \
-e CI \
-e RUSTFLAGS \
-e CARGO_TERM_COLOR \
-e CARGO_HOME=/cargo \
-e CARGO_TARGET_DIR=/target \
-e "EMULATED=$emulated" \
-v "${HOME}/.cargo:/cargo" \
-v "$(pwd)/target:/target" \
-v "$(pwd):/checkout:ro" \
-v "$(rustc --print sysroot):/rust:ro" \
--init \
-w /checkout \
"libm-$target" \
sh -c "$set_env exec ci/run.sh $target"
}
if [ -z "$1" ]; then
echo "running tests for all targets"
for d in ci/docker/*; do
run $d
done
else
run $1
fi