|
| 1 | +#!/bin/sh |
| 2 | +# ignore-tidy-linelength |
| 3 | + |
| 4 | +set -eu |
| 5 | +set -x # so one can see where we are in the script |
| 6 | + |
| 7 | +X_PY="$1" |
| 8 | + |
| 9 | +# Try to test the toolstate-tracked tools and store the build/test success in the TOOLSTATE_FILE. |
| 10 | + |
| 11 | +# Pre-build the compiler and the library first to output a better error message when the build |
| 12 | +# itself fails (see https://github.com/rust-lang/rust/issues/127869 for context). |
| 13 | +python3 "$X_PY" build --stage 2 compiler rustdoc |
| 14 | + |
| 15 | +# set +e |
| 16 | +# python3 "$X_PY" test --stage 2 --no-fail-fast \ |
| 17 | +# src/doc/book \ |
| 18 | +# src/doc/nomicon \ |
| 19 | +# src/doc/reference \ |
| 20 | +# src/doc/rust-by-example \ |
| 21 | +# src/doc/embedded-book \ |
| 22 | +# src/doc/edition-guide \ |
| 23 | + |
| 24 | +# set -e |
| 25 | + |
| 26 | +# debugging: print out the saved toolstates |
| 27 | +# cat /tmp/toolstate/toolstates.json |
| 28 | + |
| 29 | +# Test remaining tools that must pass. |
| 30 | +# python3 "$X_PY" test --stage 2 check-tools |
| 31 | +# python3 "$X_PY" test --stage 2 src/tools/clippy |
| 32 | +# python3 "$X_PY" test --stage 2 src/tools/rustfmt |
| 33 | + |
| 34 | +# Testing Miri is a bit more complicated. |
| 35 | +# We set the GC interval to the shortest possible value (0 would be off) to increase the chance |
| 36 | +# that bugs which only surface when the GC runs at a specific time are more likely to cause CI to fail. |
| 37 | +# This significantly increases the runtime of our test suite, or we'd do this in PR CI too. |
| 38 | +if [ -z "${PR_CI_JOB:-}" ]; then |
| 39 | + MIRIFLAGS=-Zmiri-provenance-gc=1 python3 "$X_PY" test --stage 2 src/tools/miri src/tools/miri/cargo-miri |
| 40 | +else |
| 41 | + python3 "$X_PY" test --stage 2 src/tools/miri src/tools/miri/cargo-miri |
| 42 | +fi |
| 43 | +# We natively run this script on x86_64-unknown-linux-gnu and x86_64-pc-windows-msvc. |
| 44 | +# Also cover some other targets via cross-testing, in particular all tier 1 targets. |
| 45 | +case $HOST_TARGET in |
| 46 | + x86_64-unknown-linux-gnu) |
| 47 | + # Only this branch runs in PR CI. |
| 48 | + # Fully test all main OSes, including a 32bit target. |
| 49 | + python3 "$X_PY" test --stage 2 src/tools/miri src/tools/miri/cargo-miri --target x86_64-apple-darwin |
| 50 | + python3 "$X_PY" test --stage 2 src/tools/miri src/tools/miri/cargo-miri --target i686-pc-windows-msvc |
| 51 | + # Only run "pass" tests for the remaining targets, which is quite a bit faster. |
| 52 | + python3 "$X_PY" test --stage 2 src/tools/miri --target x86_64-pc-windows-gnu --test-args pass |
| 53 | + python3 "$X_PY" test --stage 2 src/tools/miri --target i686-unknown-linux-gnu --test-args pass |
| 54 | + python3 "$X_PY" test --stage 2 src/tools/miri --target aarch64-unknown-linux-gnu --test-args pass |
| 55 | + python3 "$X_PY" test --stage 2 src/tools/miri --target s390x-unknown-linux-gnu --test-args pass |
| 56 | + ;; |
| 57 | + x86_64-pc-windows-msvc) |
| 58 | + # Strangely, Linux targets do not work here. cargo always says |
| 59 | + # "error: cannot produce cdylib for ... as the target ... does not support these crate types". |
| 60 | + # Only run "pass" tests, which is quite a bit faster. |
| 61 | + python3 "$X_PY" test --stage 2 src/tools/miri --target aarch64-apple-darwin --test-args pass |
| 62 | + python3 "$X_PY" test --stage 2 src/tools/miri --target i686-pc-windows-gnu --test-args pass |
| 63 | + ;; |
| 64 | + *) |
| 65 | + echo "FATAL: unexpected host $HOST_TARGET" |
| 66 | + exit 1 |
| 67 | + ;; |
| 68 | +esac |
| 69 | +# Also smoke-test `x.py miri`. This doesn't run any actual tests (that would take too long), |
| 70 | +# but it ensures that the crates build properly when tested with Miri. |
| 71 | +python3 "$X_PY" miri --stage 2 library/core --test-args notest |
| 72 | +python3 "$X_PY" miri --stage 2 library/alloc --test-args notest |
| 73 | +python3 "$X_PY" miri --stage 2 library/std --test-args notest |
0 commit comments