Skip to content

Commit

Permalink
Add --tool=check
Browse files Browse the repository at this point in the history
  • Loading branch information
saethlin committed Aug 27, 2023
1 parent cae6305 commit 85b6317
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
13 changes: 9 additions & 4 deletions docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ function run_build {
inapty cargo +$TOOLCHAIN test --no-run --target=$HOST $ARGS
}

function run_check {
inapty cargo +$TOOLCHAIN check --target=$HOST $ARGS
}

function run_asan {
cargo +$TOOLCHAIN careful test -Zcareful-sanitizer=address --no-run --target=$HOST $ARGS &> /dev/null
timeout --kill-after=10 600 inapty cargo +$TOOLCHAIN careful test -Zcareful-sanitizer=address --color=always --no-fail-fast --target=$HOST $ARGS
}

function run_miri {
cargo +$TOOLCHAIN miri setup
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" timeout --kill-after=10 3600 inapty cargo +$TOOLCHAIN miri nextest run --color=always --no-fail-fast --config-file=/root/.cargo/nextest.toml $ARGS
Expand All @@ -48,14 +51,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
Expand Down
4 changes: 2 additions & 2 deletions src/diagnose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ fn diagnose_output(output: &str) -> Vec<Cause> {
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;
Expand Down
6 changes: 6 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pub enum Tool {
Miri,
Asan,
Build,
Check,
}

impl Tool {
Expand All @@ -52,6 +53,7 @@ impl Tool {
Tool::Miri => "miri/raw",
Tool::Asan => "asan/raw",
Tool::Build => "build/raw",
Tool::Check => "check/raw",
}
}

Expand All @@ -64,6 +66,7 @@ impl Tool {
Tool::Miri => "miri/logs",
Tool::Asan => "asan/logs",
Tool::Build => "build/logs",
Tool::Check => "check/logs",
}
}

Expand All @@ -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",
}
}
}
Expand All @@ -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)
}
Expand All @@ -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)),
}
}
Expand Down
7 changes: 1 addition & 6 deletions src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,18 +193,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),
]);
Expand Down

0 comments on commit 85b6317

Please sign in to comment.