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