]> git.lizzy.rs Git - rust.git/blob - ci.sh
work around apfloat bug in FMA by using host floats instead
[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   ## ui test suite
25   ./miri test --locked
26   if [ -z "${MIRI_TEST_TARGET+exists}" ]; then
27     # Only for host architecture: tests with optimizations (`-O` is what cargo passes, but crank MIR
28     # optimizations up all the way).
29     # Optimizations change diagnostics (mostly backtraces), so we don't check them
30     #FIXME(#2155): we want to only run the pass and panic tests here, not the fail tests.
31     MIRIFLAGS="-O -Zmir-opt-level=4" MIRI_SKIP_UI_CHECKS=1 ./miri test --locked -- tests/{pass,panic}
32   fi
33
34   ## test-cargo-miri
35   # On Windows, there is always "python", not "python3" or "python2".
36   if command -v python3 > /dev/null; then
37     PYTHON=python3
38   else
39     PYTHON=python
40   fi
41   # Some environment setup that attempts to confuse the heck out of cargo-miri.
42   if [ "$HOST_TARGET" = x86_64-unknown-linux-gnu ]; then
43     # These act up on Windows (`which miri` produces a filename that does not exist?!?),
44     # so let's do this only on Linux. Also makes sure things work without these set.
45     export RUSTC=$(which rustc)
46     export MIRI=$(which miri)
47   fi
48   mkdir -p .cargo
49   echo 'build.rustc-wrapper = "thisdoesnotexist"' > .cargo/config.toml
50   # Run the actual test
51   ${PYTHON} test-cargo-miri/run-test.py
52   echo
53   # Clean up
54   unset RUSTC MIRI
55   rm -rf .cargo
56
57   # Ensure that our benchmarks all work, on the host at least.
58   if [ -z "${MIRI_TEST_TARGET+exists}" ]; then
59     for BENCH in $(ls "bench-cargo-miri"); do
60       cargo miri run --manifest-path bench-cargo-miri/$BENCH/Cargo.toml
61     done
62   fi
63 }
64
65 function run_tests_minimal {
66   if [ -n "${MIRI_TEST_TARGET+exists}" ]; then
67     echo "Testing MINIMAL foreign architecture $MIRI_TEST_TARGET: only testing $@"
68   else
69     echo "Testing MINIMAL host architecture: only testing $@"
70   fi
71
72   ./miri test --locked -- "$@"
73 }
74
75 # host
76 run_tests
77
78 case $HOST_TARGET in
79   x86_64-unknown-linux-gnu)
80     MIRI_TEST_TARGET=i686-unknown-linux-gnu run_tests
81     MIRI_TEST_TARGET=aarch64-apple-darwin run_tests
82     MIRI_TEST_TARGET=i686-pc-windows-msvc run_tests
83     MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal hello integer vec current_dir data_race env
84     MIRI_TEST_TARGET=thumbv7em-none-eabihf MIRI_NO_STD=1 run_tests_minimal no_std # no_std embedded architecture
85     ;;
86   x86_64-apple-darwin)
87     MIRI_TEST_TARGET=mips64-unknown-linux-gnuabi64 run_tests # big-endian architecture
88     MIRI_TEST_TARGET=x86_64-pc-windows-msvc run_tests
89     ;;
90   i686-pc-windows-msvc)
91     MIRI_TEST_TARGET=x86_64-unknown-linux-gnu run_tests
92     ;;
93   *)
94     echo "FATAL: unknown OS"
95     exit 1
96     ;;
97 esac