|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Run rustc test suites using our test driver using nightly. |
| 4 | +# This script leverages the rustc's repo compiletest crate. |
| 5 | +# |
| 6 | +# The suites configuration should match: |
| 7 | +# https://github.com/rust-lang/rust/blob/master/src/bootstrap/test.rs |
| 8 | + |
| 9 | +set -e |
| 10 | +set -u |
| 11 | +export RUST_BACKTRACE=1 |
| 12 | + |
| 13 | +# Location of a rust repository. Clone one if path doesn't exist. |
| 14 | +RUST_REPO="${RUST_REPO:-"/tmp/rustc"}" |
| 15 | + |
| 16 | +# Where we will store the SMIR tools (Optional). |
| 17 | +TOOLS_BIN="${TOOLS_BIN:-"/tmp/smir/bin"}" |
| 18 | + |
| 19 | +# Assume we are inside SMIR repository |
| 20 | +SMIR_PATH=$(git rev-parse --show-toplevel) |
| 21 | + |
| 22 | +# Build stable_mir tools |
| 23 | +function build_smir_tools() { |
| 24 | + pushd "${SMIR_PATH}" |
| 25 | + cargo +nightly build -Z unstable-options --out-dir "${TOOLS_BIN}" |
| 26 | + export PATH="${TOOLS_BIN}":"${PATH}" |
| 27 | +} |
| 28 | + |
| 29 | +# Set up rustc repository |
| 30 | +function setup_rustc_repo() { |
| 31 | + if [[ ! -e "${RUST_REPO}" ]]; then |
| 32 | + mkdir -p "$(dirname ${RUST_REPO})" |
| 33 | + git clone -b master https://github.com/rust-lang/rust.git "${RUST_REPO}" |
| 34 | + pushd "${RUST_REPO}" |
| 35 | + commit="$(rustc +nightly -vV | awk '/^commit-hash/ { print $2 }')" |
| 36 | + git checkout ${commit} |
| 37 | + git submodule init -- "${RUST_REPO}/library/stdarch" |
| 38 | + git submodule update |
| 39 | + else |
| 40 | + pushd "${RUST_REPO}" |
| 41 | + fi |
| 42 | +} |
| 43 | + |
| 44 | +function run_tests() { |
| 45 | + # Run the following suite configuration for now (test suite + mode) |
| 46 | + SUITES=( |
| 47 | + "codegen codegen" |
| 48 | + "codegen-units codegen-units" |
| 49 | + # -- The suites below are failing because of fully qualified paths for standard library |
| 50 | + # E.g.: |
| 51 | + # - _10 = _eprint(move _11) -> [return: bb6, unwind unreachable]; |
| 52 | + # + _10 = std::io::_eprint(move _11) -> [return: bb6, unwind unreachable]; |
| 53 | + # |
| 54 | + #"ui ui" |
| 55 | + #"mir-opt mir-opt" |
| 56 | + #"pretty pretty" -- 2 failing tests |
| 57 | + ) |
| 58 | + |
| 59 | + SYSROOT=$(rustc +nightly --print sysroot) |
| 60 | + PY_PATH=$(type -P python3) |
| 61 | + HOST=$(rustc +nightly -vV | awk '/^host/ { print $2 }') |
| 62 | + FILE_CHECK="$(which FileCheck-12 || which FileCheck-13 || which FileCheck-14)" |
| 63 | + |
| 64 | + for suite_cfg in "${SUITES[@]}"; do |
| 65 | + # Hack to work on older bash like the ones on MacOS. |
| 66 | + suite_pair=($suite_cfg) |
| 67 | + suite=${suite_pair[0]} |
| 68 | + mode=${suite_pair[1]} |
| 69 | + |
| 70 | + echo "#### Running suite: ${suite} mode: ${mode}" |
| 71 | + cargo +nightly run -p compiletest -- \ |
| 72 | + --compile-lib-path="${SYSROOT}/lib" \ |
| 73 | + --run-lib-path="${SYSROOT}/lib"\ |
| 74 | + --python="${PY_PATH}" \ |
| 75 | + --rustc-path="${TOOLS_BIN}/test-drive" \ |
| 76 | + --mode=${mode} \ |
| 77 | + --suite="${suite}" \ |
| 78 | + --src-base="tests/${suite}" \ |
| 79 | + --build-base="$(pwd)/build/${HOST}/stage1/tests/${suite}" \ |
| 80 | + --sysroot-base="$SYSROOT" \ |
| 81 | + --stage-id=stage1-${HOST} \ |
| 82 | + --cc= \ |
| 83 | + --cxx= \ |
| 84 | + --cflags= \ |
| 85 | + --cxxflags= \ |
| 86 | + --llvm-components= \ |
| 87 | + --android-cross-path= \ |
| 88 | + --target=${HOST} \ |
| 89 | + --llvm-filecheck="${FILE_CHECK}" \ |
| 90 | + --channel=nightly \ |
| 91 | + --target-rustcflags="--smir-check" \ |
| 92 | + --host-rustcflags="--smir-check" |
| 93 | + done |
| 94 | +} |
| 95 | + |
| 96 | +build_smir_tools |
| 97 | +setup_rustc_repo |
| 98 | +run_tests |
0 commit comments