Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ remove_dir_all = "0.7"
reqwest = { version = "0.11", features = ["blocking", "json"] }
rusqlite = { version = "0.32.1", features = ["chrono", "functions", "bundled"] }
rust_team_data = { git = "https://github.com/rust-lang/team" }
rustwide = { version = "0.19.1", features = [
rustwide = { version = "0.19.3", features = [
"unstable",
"unstable-toolchain-ci",
] }
Expand Down
1 change: 1 addition & 0 deletions docs/bot-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ The following experiment modes are currently available:
* `check-only`: run `cargo check` on every crate (faster)
* `clippy`: run `cargo clippy` on every crate
* `rustdoc`: run `cargo doc --no-deps` on every crate
* `fix`: run `cargo fix` on every crate (intended for edition migration testing)

The mode you should use depends on what your experiment is testing:

Expand Down
1 change: 1 addition & 0 deletions src/experiments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ string_enum!(pub enum Mode {
Clippy => "clippy",
Rustdoc => "rustdoc",
UnstableFeatures => "unstable-features",
Fix => "fix",
});

string_enum!(pub enum CapLints {
Expand Down
2 changes: 1 addition & 1 deletion src/report/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ fn write_logs<DB: ReadResults, W: ReportWriter>(
}

for (i, krate) in crates.iter().enumerate() {
if i % progress_every == 0 {
if i.is_multiple_of(progress_every) {
info!("wrote logs for {i}/{num_crates} crates")
}

Expand Down
3 changes: 3 additions & 0 deletions src/runner/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub(super) enum TaskStep {
Clippy { tc: Toolchain, quiet: bool },
Rustdoc { tc: Toolchain, quiet: bool },
UnstableFeatures { tc: Toolchain },
Fix { tc: Toolchain, quiet: bool },
}

impl fmt::Debug for TaskStep {
Expand All @@ -59,6 +60,7 @@ impl fmt::Debug for TaskStep {
TaskStep::Clippy { ref tc, quiet } => ("clippy", quiet, Some(tc)),
TaskStep::Rustdoc { ref tc, quiet } => ("doc", quiet, Some(tc)),
TaskStep::UnstableFeatures { ref tc } => ("find unstable features on", false, Some(tc)),
TaskStep::Fix { ref tc, quiet } => ("fix", quiet, Some(tc)),
};

write!(f, "{name}")?;
Expand Down Expand Up @@ -124,6 +126,7 @@ impl Task {
tc,
false,
),
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);
Expand Down
64 changes: 60 additions & 4 deletions src/runner/test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::crates::Crate;
use crate::experiments::CapLints;
use crate::prelude::*;
use crate::results::DiagnosticCode;
use crate::results::{BrokenReason, FailureReason, TestResult};
Expand All @@ -9,7 +10,7 @@ use cargo_metadata::diagnostic::DiagnosticLevel;
use cargo_metadata::{Message, Metadata, Package, Target};
use docsrs_metadata::Metadata as DocsrsMetadata;
use remove_dir_all::remove_dir_all;
use rustwide::cmd::{CommandError, ProcessLinesActions, SandboxBuilder};
use rustwide::cmd::{CommandError, MountKind, ProcessLinesActions, SandboxBuilder};
use rustwide::logging::LogStorage;
use rustwide::{Build, PrepareError};
use std::collections::{BTreeSet, HashMap, HashSet};
Expand Down Expand Up @@ -89,6 +90,8 @@ 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 All @@ -100,13 +103,17 @@ fn run_cargo(
args.extend(tc_cargoflags.split(' '));
}

let mut rustflags = format!("--cap-lints={}", ctx.experiment.cap_lints.to_str());
let mut rustflags = cap_lints
.map(|cap| format!("--cap-lints={cap}"))
.unwrap_or_default();
if let Some(ref tc_rustflags) = ctx.toolchain.rustflags {
rustflags.push(' ');
rustflags.push_str(tc_rustflags);
}

let mut rustdocflags = format!("--cap-lints={}", ctx.experiment.cap_lints.to_str());
let mut rustdocflags = cap_lints
.map(|cap| format!("--cap-lints={cap}"))
.unwrap_or_default();
if let Some(ref tc_rustdocflags) = ctx.toolchain.rustdocflags {
rustdocflags.push(' ');
rustdocflags.push_str(tc_rustdocflags);
Expand Down Expand Up @@ -187,6 +194,7 @@ 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 @@ -263,6 +271,8 @@ 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(
ctx,
Expand All @@ -271,6 +281,8 @@ 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 @@ -283,6 +295,8 @@ fn test(ctx: &TaskCtx, build_env: &Build) -> Fallible<()> {
false,
&[],
HashMap::default(),
MountKind::ReadOnly,
Some(ctx.experiment.cap_lints),
)
}

Expand Down Expand Up @@ -336,6 +350,8 @@ 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)))
} else {
Expand All @@ -361,6 +377,8 @@ pub(super) fn test_clippy_only(
true,
local_packages,
HashMap::default(),
MountKind::ReadOnly,
Some(ctx.experiment.cap_lints),
) {
Ok(TestResult::BuildFail(failure_reason(&err)))
} else {
Expand All @@ -374,7 +392,16 @@ pub(super) fn test_rustdoc(
local_packages: &[Package],
) -> Fallible<TestResult> {
let run = |cargo_args, env| {
let res = run_cargo(ctx, build_env, cargo_args, true, local_packages, env);
let res = run_cargo(
ctx,
build_env,
cargo_args,
true,
local_packages,
env,
MountKind::ReadOnly,
Some(ctx.experiment.cap_lints),
);

// Make sure to remove the built documentation
// There is no point in storing it after the build is done
Expand Down Expand Up @@ -433,6 +460,35 @@ fn is_library(target: &Target) -> bool {
.all(|k| !["example", "test", "bench"].contains(&k.as_str()))
}

pub(crate) fn fix(
ctx: &TaskCtx,
build_env: &Build,
local_packages_id: &[Package],
) -> Fallible<TestResult> {
if let Err(err) = run_cargo(
ctx,
build_env,
&[
"fix",
"--allow-no-vcs",
"--allow-dirty",
"--frozen",
"--all",
"--all-targets",
"--message-format=json",
],
true,
local_packages_id,
HashMap::default(),
MountKind::ReadWrite,
None,
) {
Ok(TestResult::BuildFail(failure_reason(&err)))
} else {
Ok(TestResult::TestPass)
}
}

#[test]
fn test_failure_reason() {
let error: anyhow::Error = anyhow!(CommandError::IO(std::io::Error::other("Test")));
Expand Down
7 changes: 6 additions & 1 deletion src/runner/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ impl<'a> Worker<'a> {
| TaskStep::CheckOnly { tc, .. }
| TaskStep::Clippy { tc, .. }
| TaskStep::Rustdoc { tc, .. }
| TaskStep::UnstableFeatures { tc } => Some(tc),
| TaskStep::UnstableFeatures { tc }
| TaskStep::Fix { tc, .. } => Some(tc),
};
if let Some(toolchain) = toolchain {
if toolchain == self.ex.toolchains.last().unwrap() {
Expand Down Expand Up @@ -301,6 +302,10 @@ impl<'a> Worker<'a> {
quiet,
},
Mode::UnstableFeatures => TaskStep::UnstableFeatures { tc: tc.clone() },
Mode::Fix => TaskStep::Fix {
tc: tc.clone(),
quiet,
},
},
};

Expand Down
1 change: 1 addition & 0 deletions src/server/routes/ui/experiments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ impl ExperimentData {
Mode::Clippy => "cargo clippy",
Mode::Rustdoc => "cargo doc",
Mode::UnstableFeatures => "unstable features",
Mode::Fix => "cargo fix",
},
assigned_to: experiment.assigned_to.as_ref().map(|a| a.to_string()),
priority: experiment.priority,
Expand Down