Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
196 changes: 96 additions & 100 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ reqwest = { version = "0.13", features = ["blocking", "json", "gzip"] }
jiff = { version = "0.2.15", features = ["serde"] }
rusqlite = { version = "0.39", features = ["chrono", "functions", "bundled"] }
rust_team_data = { git = "https://github.com/rust-lang/team" }
rustwide = { version = "0.22.1", features = [
rustwide = { version = "0.25.0", features = [
"unstable",
"unstable-toolchain-ci",
] }
Expand Down
2 changes: 1 addition & 1 deletion src/results/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl<'a> DatabaseDB<'a> {
log::info!(
"insert {krate} for ex={ex:?} with tc={toolchain}; result={res:?}",
krate = krate.id(),
ex = &ex.name
ex = ex.name
);
self.db.execute(
"INSERT INTO results (experiment, crate, toolchain, result, log, encoding) \
Expand Down
72 changes: 57 additions & 15 deletions src/runner/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::prelude::*;
use crate::results::TestResult;
use crate::runner::test;
use crate::toolchain::Toolchain;
use rustwide::cmd::MountKind;
use rustwide::{Build, BuildDirectory};
use std::collections::HashMap;
use std::sync::Mutex;
Expand All @@ -19,6 +20,7 @@ pub(super) struct TaskCtx<'ctx> {
pub(super) toolchain: &'ctx Toolchain,
pub(super) krate: &'ctx Crate,
pub(super) quiet: bool,
pub(super) mount_kind: MountKind,
}

impl<'ctx> TaskCtx<'ctx> {
Expand All @@ -29,6 +31,7 @@ impl<'ctx> TaskCtx<'ctx> {
toolchain: &'ctx Toolchain,
krate: &'ctx Crate,
quiet: bool,
mount_kind: MountKind,
) -> Self {
TaskCtx {
build_dir,
Expand All @@ -37,6 +40,7 @@ impl<'ctx> TaskCtx<'ctx> {
toolchain,
krate,
quiet,
mount_kind,
}
}
}
Expand Down Expand Up @@ -93,43 +97,81 @@ impl Task {
ex: &'ctx Experiment,
logs: &LogStorage,
) -> Fallible<TestResult> {
let (build_dir, action, test, toolchain, quiet): (
let (build_dir, action, test, toolchain, quiet, mount_kind): (
_,
_,
fn(&TaskCtx, &Build, &_) -> _,
_,
_,
_,
) = match self.step {
TaskStep::BuildAndTest { ref tc, quiet } => (
&build_dir[tc],
"testing",
test::test_build_and_test,
tc,
quiet,
MountKind::ReadOnly,
),
TaskStep::BuildOnly { ref tc, quiet } => (
&build_dir[tc],
"building",
test::test_build_only,
tc,
quiet,
MountKind::ReadOnly,
),
TaskStep::CheckOnly { ref tc, quiet } => (
&build_dir[tc],
"checking",
test::test_check_only,
tc,
quiet,
MountKind::ReadOnly,
),
TaskStep::Clippy { ref tc, quiet } => (
&build_dir[tc],
"linting",
test::test_clippy_only,
tc,
quiet,
MountKind::ReadOnly,
),
TaskStep::Rustdoc { ref tc, quiet } => (
&build_dir[tc],
"documenting",
test::test_rustdoc,
tc,
quiet,
MountKind::ReadOnly,
),
TaskStep::BuildOnly { ref tc, quiet } => {
(&build_dir[tc], "building", test::test_build_only, tc, quiet)
}
TaskStep::CheckOnly { ref tc, quiet } => {
(&build_dir[tc], "checking", test::test_check_only, tc, quiet)
}
TaskStep::Clippy { ref tc, quiet } => {
(&build_dir[tc], "linting", test::test_clippy_only, tc, quiet)
}
TaskStep::Rustdoc { ref tc, quiet } => {
(&build_dir[tc], "documenting", test::test_rustdoc, tc, quiet)
}
TaskStep::UnstableFeatures { ref tc } => (
&build_dir[tc],
"checking unstable",
crate::runner::unstable_features::find_unstable_features,
tc,
false,
MountKind::ReadOnly,
),
TaskStep::Fix { ref tc, quiet } => (
&build_dir[tc],
"fixing",
test::fix,
tc,
quiet,
MountKind::ReadWrite,
),
TaskStep::Fix { ref tc, quiet } => (&build_dir[tc], "fixing", test::fix, tc, quiet),
};

let ctx = TaskCtx::new(build_dir, config, ex, toolchain, &self.krate, quiet);
let ctx = TaskCtx::new(
build_dir,
config,
ex,
toolchain,
&self.krate,
quiet,
mount_kind,
);
test::run_test(action, &ctx, test, logs)
}
}
28 changes: 12 additions & 16 deletions src/runner/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use cargo_metadata::diagnostic::DiagnosticLevel;
use cargo_metadata::{CrateType, Metadata, Package, Target, TargetKind};
use docsrs_metadata::Metadata as DocsrsMetadata;
use remove_dir_all::remove_dir_all;
use rustwide::cmd::{CommandError, MountKind, ProcessLinesActions, SandboxBuilder};
use rustwide::cmd::{CommandError, ProcessLinesActions, SandboxBuilder};
use rustwide::logging::LogStorage;
use rustwide::{Build, PrepareError};
use std::collections::{BTreeSet, HashMap, HashSet};
Expand Down Expand Up @@ -92,7 +92,7 @@ pub(super) fn detect_broken<T>(res: Result<T, Error>) -> Result<T, Error> {
fn get_local_packages(build_env: &Build) -> Fallible<Vec<Package>> {
Ok(build_env
.cargo()
.args(&["metadata", "--no-deps", "--format-version=1"])
.args(["metadata", "--no-deps", "--format-version=1"])
.log_output(false)
.run_capture()?
.stdout_lines()
Expand All @@ -109,7 +109,6 @@ fn run_cargo(
check_errors: bool,
local_packages: &[Package],
env: HashMap<&'static str, String>,
mount_kind: MountKind,
cap_lints: Option<CapLints>,
) -> Fallible<()> {
let local_packages_id: HashSet<_> = local_packages.iter().map(|p| &p.id).collect();
Expand Down Expand Up @@ -213,7 +212,6 @@ fn run_cargo(
let mut command = build_env
.cargo()
.args(&args)
.source_dir_mount_kind(mount_kind)
.env("CARGO_INCREMENTAL", "0")
.env("RUST_BACKTRACE", "full")
.env("RUSTFLAGS", rustflags)
Expand Down Expand Up @@ -304,7 +302,8 @@ pub(super) fn run_test(
);
let sandbox = SandboxBuilder::new()
.memory_limit(Some(ctx.config.sandbox.memory_limit.to_bytes()))
.enable_networking(false);
.enable_networking(false)
.source_dir_mount_kind(ctx.mount_kind);

let krate = &ctx.krate.to_rustwide();
let mut build_dir = ctx.build_dir.lock().unwrap();
Expand All @@ -314,10 +313,14 @@ pub(super) fn run_test(
build = build.patch_with_git(&patch.name, patch.repo.as_str(), &patch.branch);
}

detect_broken(build.run(|build| {
let local_packages = get_local_packages(build)?;
test_fn(ctx, build, &local_packages)
}))
detect_broken(
build
.run(|build| {
let local_packages = get_local_packages(build)?;
test_fn(ctx, build, &local_packages)
})
.map(|v| v.into_inner()),
)
})
}

Expand All @@ -329,7 +332,6 @@ fn build(ctx: &TaskCtx, build_env: &Build, local_packages: &[Package]) -> Fallib
true,
local_packages,
HashMap::default(),
MountKind::ReadOnly,
Some(ctx.experiment.cap_lints),
)?;
run_cargo(
Expand All @@ -339,7 +341,6 @@ fn build(ctx: &TaskCtx, build_env: &Build, local_packages: &[Package]) -> Fallib
true,
local_packages,
HashMap::default(),
MountKind::ReadOnly,
Some(ctx.experiment.cap_lints),
)?;
Ok(())
Expand All @@ -353,7 +354,6 @@ fn test(ctx: &TaskCtx, build_env: &Build) -> Fallible<()> {
false,
&[],
HashMap::default(),
MountKind::ReadOnly,
Some(ctx.experiment.cap_lints),
)
}
Expand Down Expand Up @@ -408,7 +408,6 @@ pub(super) fn test_check_only(
true,
local_packages_id,
HashMap::default(),
MountKind::ReadOnly,
Some(ctx.experiment.cap_lints),
) {
Ok(TestResult::BuildFail(failure_reason(&err)))
Expand All @@ -435,7 +434,6 @@ pub(super) fn test_clippy_only(
true,
local_packages,
HashMap::default(),
MountKind::ReadOnly,
Some(ctx.experiment.cap_lints),
) {
Ok(TestResult::BuildFail(failure_reason(&err)))
Expand All @@ -457,7 +455,6 @@ pub(super) fn test_rustdoc(
true,
local_packages,
env,
MountKind::ReadOnly,
Some(ctx.experiment.cap_lints),
);

Expand Down Expand Up @@ -538,7 +535,6 @@ pub(crate) fn fix(
true,
local_packages_id,
HashMap::default(),
MountKind::ReadWrite,
None,
) {
Ok(TestResult::BuildFail(failure_reason(&err)))
Expand Down
2 changes: 2 additions & 0 deletions tests/minicrater/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ The runs' output is hidden by default, but you can show it by setting the
$ MINICRATER_SHOW_OUTPUT=1 cargo test minicrater -- --ignored --test-threads 1
```

To bless all minicrater reports set the environment variable `MINICRATER_BLESS`

## Adding tests to minicrater

There are two ways to add a test to minicrater:
Expand Down
29 changes: 22 additions & 7 deletions tests/minicrater/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,27 @@ trait Compare {
"Difference between expected and actual reports:\n{}",
changeset
);
eprintln!("To expect the new report in the future run:");
eprintln!(
"$ cp {} {}\n",
actual_file.to_string_lossy(),
expected_file.to_string_lossy()
);
failed = true;

if std::env::var_os("MINICRATER_BLESS").is_some() {
eprintln!(
"Copying {} to {} to bless the updated resport",
actual_file.to_string_lossy(),
expected_file.to_string_lossy()
);
if let Err(err) = std::fs::copy(&actual_file, &expected_file) {
eprintln!("Failed to bless report: {err}");
} else {
eprintln!("Report bless successfully.")
}
} else {
eprintln!("To expect the new report in the future run:");
eprintln!(
"$ cp {} {}\n",
actual_file.to_string_lossy(),
expected_file.to_string_lossy()
);
failed = true;
}
}
}
failed
Expand Down Expand Up @@ -212,6 +226,7 @@ impl MinicraterRun {
.minicrater_exec();

if failed {
eprintln!("to bless all changed reports re-run with MINICRATER_BLESS=1");
panic!("invalid report generated by Crater");
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/minicrater/full/full.html.context.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"url": "https://github.com/rust-lang/crater/tree/HEAD/local-crates/ice-regression"
}
],
"build compiler-error(E0277)": [
"build compiler-error(E0015)": [
{
"color_idx": 0,
"name": "error-code (local)",
Expand Down
2 changes: 1 addition & 1 deletion tests/minicrater/full/index.html.context.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"url": "https://github.com/rust-lang/crater/tree/HEAD/local-crates/ice-regression"
}
],
"build compiler-error(E0277)": [
"build compiler-error(E0015)": [
{
"color_idx": 0,
"name": "error-code (local)",
Expand Down
2 changes: 1 addition & 1 deletion tests/minicrater/full/markdown.md.context.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
},
{
"log": "beta/local/error-code",
"res": "build-fail:compiler-error(E0277)"
"res": "build-fail:compiler-error(E0015)"
}
],
"url": "https://github.com/rust-lang/crater/tree/HEAD/local-crates/error-code"
Expand Down
2 changes: 1 addition & 1 deletion tests/minicrater/full/results.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
},
{
"log": "beta/local/error-code",
"res": "build-fail:compiler-error(E0277)"
"res": "build-fail:compiler-error(E0015)"
}
],
"url": "https://github.com/rust-lang/crater/tree/HEAD/local-crates/error-code"
Expand Down