Skip to content

Commit 50bb0a6

Browse files
committed
Auto merge of #3436 - RalfJung:win-ci, r=RalfJung
speed up Windows CI The many-seeds test is taking 15 minutes. Let's just run that only once instead of many times on Windows. Also refactor the CI script to make the caller control which tests are being run.
2 parents 2eb8531 + 77ae305 commit 50bb0a6

File tree

3 files changed

+61
-46
lines changed

3 files changed

+61
-46
lines changed

.github/workflows/ci.yml

+4
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ jobs:
130130
run: ./miri fmt --check
131131
- name: clippy
132132
run: ./miri clippy -- -D warnings
133+
- name: clippy (no features)
134+
run: ./miri clippy --no-default-features -- -D warnings
135+
- name: clippy (all features)
136+
run: ./miri clippy --all-features -- -D warnings
133137
- name: rustdoc
134138
run: RUSTDOCFLAGS="-Dwarnings" ./miri cargo doc --document-private-items
135139

ci/ci.sh

+55-44
Original file line numberDiff line numberDiff line change
@@ -27,60 +27,59 @@ export RUSTFLAGS="-D warnings"
2727
export CARGO_INCREMENTAL=0
2828
export CARGO_EXTRA_FLAGS="--locked"
2929

30-
# Determine configuration for installed build
30+
# Determine configuration for installed build (used by test-cargo-miri).
3131
echo "Installing release version of Miri"
32-
./miri install
33-
34-
echo "Checking various feature flag configurations"
35-
./miri check --no-default-features # make sure this can be built
36-
./miri check # and this, too
37-
# `--all-features` is used for the build below, so no extra check needed.
32+
time ./miri install
3833

3934
# Prepare debug build for direct `./miri` invocations.
4035
# We enable all features to make sure the Stacked Borrows consistency check runs.
4136
echo "Building debug version of Miri"
4237
export CARGO_EXTRA_FLAGS="$CARGO_EXTRA_FLAGS --all-features"
43-
./miri build --all-targets # the build that all the `./miri test` below will use
38+
time ./miri build --all-targets # the build that all the `./miri test` below will use
4439

4540
endgroup
4641

47-
# Test
42+
# Run tests. Recognizes these variables:
43+
# - MIRI_TEST_TARGET: the target to test. Empty for host target.
44+
# - GC_STRESS: if non-empty, run the GC stress test for the main test suite.
45+
# - MIR_OPT: if non-empty, re-run test `pass` tests with mir-opt-level=4
46+
# - MANY_SEEDS: if set to N, run the "many-seeds" tests N times
47+
# - TEST_BENCH: if non-empty, check that the benchmarks all build
48+
# - CARGO_MIRI_ENV: if non-empty, set some env vars and config to potentially confuse cargo-miri
4849
function run_tests {
49-
if [ -n "${MIRI_TEST_TARGET:-}" ]; then
50+
if [ -n "${MIRI_TEST_TARGET-}" ]; then
5051
begingroup "Testing foreign architecture $MIRI_TEST_TARGET"
5152
else
5253
begingroup "Testing host architecture"
5354
fi
5455

5556
## ui test suite
56-
# On the host, also stress-test the GC.
57-
if [ -z "${MIRI_TEST_TARGET:-}" ]; then
58-
MIRIFLAGS="${MIRIFLAGS:-} -Zmiri-provenance-gc=1" ./miri test
57+
if [ -n "${GC_STRESS-}" ]; then
58+
time MIRIFLAGS="${MIRIFLAGS-} -Zmiri-provenance-gc=1" ./miri test
5959
else
60-
./miri test
60+
time ./miri test
6161
fi
6262

63-
# Host-only tests
64-
if [ -z "${MIRI_TEST_TARGET:-}" ]; then
65-
# Running these on all targets is unlikely to catch more problems and would
66-
# cost a lot of CI time.
67-
63+
## advanced tests
64+
if [ -n "${MIR_OPT-}" ]; then
6865
# Tests with optimizations (`-O` is what cargo passes, but crank MIR optimizations up all the
6966
# way, too).
7067
# Optimizations change diagnostics (mostly backtraces), so we don't check
7168
# them. Also error locations change so we don't run the failing tests.
7269
# We explicitly enable debug-assertions here, they are disabled by -O but we have tests
7370
# which exist to check that we panic on debug assertion failures.
74-
MIRIFLAGS="${MIRIFLAGS:-} -O -Zmir-opt-level=4 -Cdebug-assertions=yes" MIRI_SKIP_UI_CHECKS=1 ./miri test -- tests/{pass,panic}
75-
71+
time MIRIFLAGS="${MIRIFLAGS-} -O -Zmir-opt-level=4 -Cdebug-assertions=yes" MIRI_SKIP_UI_CHECKS=1 ./miri test -- tests/{pass,panic}
72+
fi
73+
if [ -n "${MANY_SEEDS-}" ]; then
7674
# Also run some many-seeds tests. 64 seeds means this takes around a minute per test.
7775
# (Need to invoke via explicit `bash -c` for Windows.)
78-
for FILE in tests/many-seeds/*.rs; do
79-
MIRI_SEEDS=64 ./miri many-seeds "$BASH" -c "./miri run '$FILE'"
76+
time for FILE in tests/many-seeds/*.rs; do
77+
MIRI_SEEDS=$MANY_SEEDS ./miri many-seeds "$BASH" -c "./miri run '$FILE'"
8078
done
81-
79+
fi
80+
if [ -n "${TEST_BENCH-}" ]; then
8281
# Check that the benchmarks build and run, but without actually benchmarking.
83-
HYPERFINE="'$BASH' -c" ./miri bench
82+
time HYPERFINE="'$BASH' -c" ./miri bench
8483
fi
8584

8685
## test-cargo-miri
@@ -91,16 +90,18 @@ function run_tests {
9190
PYTHON=python
9291
fi
9392
# Some environment setup that attempts to confuse the heck out of cargo-miri.
94-
if [ "$HOST_TARGET" = x86_64-unknown-linux-gnu ]; then
95-
# These act up on Windows (`which miri` produces a filename that does not exist?!?),
96-
# so let's do this only on Linux. Also makes sure things work without these set.
97-
export RUSTC=$(which rustc) # Produces a warning unless we also set MIRI
93+
if [ -n "${CARGO_MIRI_ENV-}" ]; then
94+
# These act up on Windows (`which miri` produces a filename that does not exist?!?).
95+
# RUSTC is the main thing to set (it changes the first argument our wrapper will see).
96+
# Unless MIRI is also set, that produces a warning.
97+
export RUSTC=$(which rustc)
9898
export MIRI=$(rustc +miri --print sysroot)/bin/miri
99+
# We entirely ignore other wrappers.
100+
mkdir -p .cargo
101+
echo 'build.rustc-wrapper = "thisdoesnotexist"' > .cargo/config.toml
99102
fi
100-
mkdir -p .cargo
101-
echo 'build.rustc-wrapper = "thisdoesnotexist"' > .cargo/config.toml
102103
# Run the actual test
103-
${PYTHON} test-cargo-miri/run-test.py
104+
time ${PYTHON} test-cargo-miri/run-test.py
104105
# Clean up
105106
unset RUSTC MIRI
106107
rm -rf .cargo
@@ -109,7 +110,7 @@ function run_tests {
109110
}
110111

111112
function run_tests_minimal {
112-
if [ -n "${MIRI_TEST_TARGET:-}" ]; then
113+
if [ -n "${MIRI_TEST_TARGET-}" ]; then
113114
begingroup "Testing MINIMAL foreign architecture $MIRI_TEST_TARGET: only testing $@"
114115
else
115116
echo "run_tests_minimal requires MIRI_TEST_TARGET to be set"
@@ -126,38 +127,48 @@ function run_tests_minimal {
126127

127128
## Main Testing Logic ##
128129

129-
# Host target.
130-
run_tests
131-
132-
# Extra targets.
133130
# In particular, fully cover all tier 1 targets.
134131
case $HOST_TARGET in
135132
x86_64-unknown-linux-gnu)
133+
# Host
134+
GC_STRESS=1 MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 CARGO_MIRI_ENV=1 run_tests
135+
# Extra tier 1
136136
MIRI_TEST_TARGET=i686-unknown-linux-gnu run_tests
137137
MIRI_TEST_TARGET=aarch64-unknown-linux-gnu run_tests
138-
MIRI_TEST_TARGET=aarch64-apple-darwin run_tests
139138
MIRI_TEST_TARGET=i686-pc-windows-gnu run_tests
140139
MIRI_TEST_TARGET=x86_64-pc-windows-gnu run_tests
140+
# Extra tier 2
141+
MIRI_TEST_TARGET=aarch64-apple-darwin run_tests
141142
MIRI_TEST_TARGET=arm-unknown-linux-gnueabi run_tests
142-
# Some targets are only partially supported.
143+
# Partially supported targets (tier 2)
143144
MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple pthread-threadname libc-getentropy libc-getrandom libc-misc libc-fs atomic env align num_cpus
144145
MIRI_TEST_TARGET=i686-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple pthread-threadname libc-getentropy libc-getrandom libc-misc libc-fs atomic env align num_cpus
145-
146146
MIRI_TEST_TARGET=aarch64-linux-android run_tests_minimal hello integer vec panic/panic
147147
MIRI_TEST_TARGET=wasm32-wasi run_tests_minimal no_std integer strings wasm
148148
MIRI_TEST_TARGET=wasm32-unknown-unknown run_tests_minimal no_std integer strings wasm
149-
MIRI_TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std # no_std embedded architecture
150-
MIRI_TEST_TARGET=tests/avr.json MIRI_NO_STD=1 run_tests_minimal no_std # JSON target file
149+
MIRI_TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std
150+
# Custom target JSON file
151+
MIRI_TEST_TARGET=tests/avr.json MIRI_NO_STD=1 run_tests_minimal no_std
151152
;;
152153
x86_64-apple-darwin)
154+
# Host
155+
GC_STRESS=1 MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 CARGO_MIRI_ENV=1 run_tests
156+
# Extra tier 1
157+
MIRI_TEST_TARGET=x86_64-pc-windows-msvc CARGO_MIRI_ENV=1 run_tests
158+
# Extra tier 2
153159
MIRI_TEST_TARGET=s390x-unknown-linux-gnu run_tests # big-endian architecture
154-
MIRI_TEST_TARGET=x86_64-pc-windows-msvc run_tests
155160
;;
156161
i686-pc-windows-msvc)
162+
# Host
163+
# Only smoke-test `many-seeds`; 64 runs take 15min here!
164+
GC_STRESS=1 MIR_OPT=1 MANY_SEEDS=1 TEST_BENCH=1 run_tests
165+
# Extra tier 1
166+
# We really want to ensure a Linux target works on a Windows host,
167+
# and a 64bit target works on a 32bit host.
157168
MIRI_TEST_TARGET=x86_64-unknown-linux-gnu run_tests
158169
;;
159170
*)
160-
echo "FATAL: unknown OS"
171+
echo "FATAL: unknown host target: $HOST_TARGET"
161172
exit 1
162173
;;
163174
esac

test-cargo-miri/run-test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ def cargo_miri(cmd, quiet = True):
3131

3232
def normalize_stdout(str):
3333
str = str.replace("src\\", "src/") # normalize paths across platforms
34-
str = re.sub("finished in \d+\.\d\ds", "finished in $TIME", str) # the time keeps changing, obviously
34+
str = re.sub("finished in \\d+\\.\\d\\ds", "finished in $TIME", str) # the time keeps changing, obviously
3535
return str
3636

3737
def normalize_stderr(str):
38-
str = re.sub("Preparing a sysroot for Miri \(target: [a-z0-9_-]+\)\.\.\. done\n", "", str) # remove leading cargo-miri setup output
38+
str = re.sub("Preparing a sysroot for Miri \\(target: [a-z0-9_-]+\\)\\.\\.\\. done\n", "", str) # remove leading cargo-miri setup output
3939
return str
4040

4141
def check_output(actual, path, name):

0 commit comments

Comments
 (0)