From 822ead41f35f0032a067f95a4986cbad7bcc329b Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Wed, 19 Jul 2023 20:20:49 -0400 Subject: [PATCH] Add --tool=check --- .github/workflows/ci.yml | 2 +- docker/run.sh | 13 +++++++++---- src/diagnose.rs | 4 ++-- src/main.rs | 6 ++++++ src/run.rs | 7 +------ 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0be666c..8767cf5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: suite_matrix: strategy: matrix: - suite: [style, miri, asan, build] + suite: [style, miri, asan, build, check] runs-on: ubuntu-latest name: Test ${{ matrix.suite }} steps: diff --git a/docker/run.sh b/docker/run.sh index fe9e96e..2a1e93a 100644 --- a/docker/run.sh +++ b/docker/run.sh @@ -33,13 +33,16 @@ function run_build { timed inapty cargo +$TOOLCHAIN test --no-run --target=$HOST $ARGS } +function run_check { + inapty cargo +$TOOLCHAIN check --target=$HOST $ARGS +} + function run_asan { timed cargo +$TOOLCHAIN careful test -Zcareful-sanitizer=address --no-run --target=$HOST $ARGS &> /dev/null timed inapty cargo +$TOOLCHAIN careful test -Zcareful-sanitizer=address --color=always --no-fail-fast --target=$HOST $ARGS } function run_miri { - cargo +$TOOLCHAIN miri setup timed cargo +$TOOLCHAIN miri test --no-run $ARGS &> /dev/null # rustdoc is already passed --color=always, so adding it to the global MIRIFLAGS is just an error MIRIFLAGS="$MIRIFLAGS --color=always" timed inapty cargo +$TOOLCHAIN miri nextest run --color=always --no-fail-fast --config-file=/root/.cargo/nextest.toml $ARGS @@ -52,14 +55,16 @@ fi while read crate; do - cd /root/build + cd /build # Delete everything in our writable mount points - find /root/build /tmp /root/.cargo/registry -mindepth 1 -delete - if cargo download $crate /root/build; then + find /build /tmp /root/.cargo/registry -mindepth 1 -delete + if cargo download $crate /build; then ARGS=$(get-args $crate) cargo +$TOOLCHAIN update &> /dev/null if [[ $TOOL == "build" ]]; then run_build + elif [[ $TOOL == "check" ]]; then + run_check elif [[ $TOOL == "asan" ]]; then run_asan elif [[ $TOOL == "miri" ]]; then diff --git a/src/diagnose.rs b/src/diagnose.rs index 8397d44..afbf14c 100644 --- a/src/diagnose.rs +++ b/src/diagnose.rs @@ -168,9 +168,9 @@ fn diagnose_output(output: &str) -> Vec { for line in &lines[l..] { if line.contains("inside `") && line.contains(" at ") { let path = line.split(" at ").nth(1).unwrap(); - if path.contains("/root/build") || !path.starts_with('/') { + if path.starts_with("/build") || !path.starts_with('/') { break; - } else if path.contains("/root/.cargo/registry/src/") { + } else if path.contains(".cargo/registry/src/") { let crate_name = path.split('/').nth(6).unwrap(); source_crate = Some(crate_name.to_string()); break; diff --git a/src/main.rs b/src/main.rs index aa1cd0d..cf2cf89 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,6 +44,7 @@ pub enum Tool { Miri, Asan, Build, + Check, } impl Tool { @@ -52,6 +53,7 @@ impl Tool { Tool::Miri => "miri/raw", Tool::Asan => "asan/raw", Tool::Build => "build/raw", + Tool::Check => "check/raw", } } @@ -64,6 +66,7 @@ impl Tool { Tool::Miri => "miri/logs", Tool::Asan => "asan/logs", Tool::Build => "build/logs", + Tool::Check => "check/logs", } } @@ -76,6 +79,7 @@ impl Tool { Tool::Miri => "miri/index.html", Tool::Asan => "asan/index.html", Tool::Build => "build/index.html", + Tool::Check => "check/index.html", } } } @@ -86,6 +90,7 @@ impl fmt::Display for Tool { Tool::Miri => "miri", Tool::Asan => "asan", Tool::Build => "build", + Tool::Check => "check", }; f.write_str(s) } @@ -99,6 +104,7 @@ impl FromStr for Tool { "miri" => Ok(Self::Miri), "asan" => Ok(Self::Asan), "build" => Ok(Self::Build), + "check" => Ok(Self::Check), _ => Err(format!("Invalid tool {}", s)), } } diff --git a/src/run.rs b/src/run.rs index a9f61f0..44c6a1e 100644 --- a/src/run.rs +++ b/src/run.rs @@ -191,18 +191,13 @@ fn spawn_worker(args: &Args, cpu: usize) -> tokio::process::Child { // We set up our filesystem as read-only, but with 3 exceptions "--read-only", // The directory we are building in (not just its target dir!) is all writable - "--tmpfs=/root/build:exec", + "--tmpfs=/build:exec", // rustdoc tries to write to and executes files in /tmp, odd move but whatever "--tmpfs=/tmp:exec", // The default cargo registry location; we download dependences in the sandbox "--tmpfs=/root/.cargo/registry:exec", // cargo-miri builds a sysroot under /root/.cache, so why not make it all writeable "--tmpfs=/root/.cache:exec", - // AWS credentials for sccache - &format!( - "--volume={}/.aws:/root/.aws:ro", - dirs::home_dir().unwrap().display() - ), &format!("--env=TEST_END_DELIMITER={}", *TEST_END_DELIMITER), &format!("--env=TOOL={}", args.tool), ]);