]> git.lizzy.rs Git - rust.git/blob - ci.sh
rustup
[rust.git] / ci.sh
1 #!/bin/bash
2 set -euo pipefail
3 set -x
4
5 # Determine configuration
6 export RUSTFLAGS="-D warnings"
7 export CARGO_INCREMENTAL=0
8 export CARGO_EXTRA_FLAGS="--all-features"
9
10 # Prepare
11 echo "Build and install miri"
12 ./miri install # implicitly locked
13 ./miri build --all-targets --locked # the build that all the `./miri test` below will use
14 echo
15
16 # Test
17 function run_tests {
18   if [ -n "${MIRI_TEST_TARGET+exists}" ]; then
19     echo "Testing foreign architecture $MIRI_TEST_TARGET"
20   else
21     echo "Testing host architecture"
22   fi
23
24   ./miri test --locked
25   if [ -z "${MIRI_TEST_TARGET+exists}" ]; then
26     # Only for host architecture: tests with optimizations (`-O` is what cargo passes, but crank MIR
27     # optimizations up all the way).
28     # Optimizations change diagnostics (mostly backtraces), so we don't check them
29     #FIXME(#2155): we want to only run the pass and panic tests here, not the fail tests.
30     MIRIFLAGS="-O -Zmir-opt-level=4" MIRI_SKIP_UI_CHECKS=1 ./miri test --locked -- tests/{pass,panic}
31   fi
32
33   # On Windows, there is always "python", not "python3" or "python2".
34   if command -v python3 > /dev/null; then
35     PYTHON=python3
36   else
37     PYTHON=python
38   fi
39
40   # "miri test" has built the sysroot for us, now this should pass without
41   # any interactive questions.
42   ${PYTHON} test-cargo-miri/run-test.py
43   echo
44
45   # Ensure that our benchmarks all work, on the host at least.
46   if [ -z "${MIRI_TEST_TARGET+exists}" ]; then
47     for BENCH in $(ls "bench-cargo-miri"); do
48       cargo miri run --manifest-path bench-cargo-miri/$BENCH/Cargo.toml
49     done
50   fi
51 }
52
53 function run_tests_minimal {
54   if [ -n "${MIRI_TEST_TARGET+exists}" ]; then
55     echo "Testing MINIMAL foreign architecture $MIRI_TEST_TARGET: only testing $@"
56   else
57     echo "Testing MINIMAL host architecture: only testing $@"
58   fi
59
60   ./miri test --locked -- "$@"
61 }
62
63 # host
64 run_tests
65
66 case $HOST_TARGET in
67   x86_64-unknown-linux-gnu)
68     MIRI_TEST_TARGET=i686-unknown-linux-gnu run_tests
69     MIRI_TEST_TARGET=aarch64-apple-darwin run_tests
70     MIRI_TEST_TARGET=i686-pc-windows-msvc run_tests
71     MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal hello integer vec current_dir data_race env
72     MIRI_TEST_TARGET=thumbv7em-none-eabihf MIRI_NO_STD=1 run_tests_minimal no_std # no_std embedded architecture
73     ;;
74   x86_64-apple-darwin)
75     MIRI_TEST_TARGET=mips64-unknown-linux-gnuabi64 run_tests # big-endian architecture
76     MIRI_TEST_TARGET=x86_64-pc-windows-msvc run_tests
77     ;;
78   i686-pc-windows-msvc)
79     MIRI_TEST_TARGET=x86_64-unknown-linux-gnu run_tests
80     ;;
81   *)
82     echo "FATAL: unknown OS"
83     exit 1
84     ;;
85 esac