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
1 change: 1 addition & 0 deletions docs/bot-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ The following experiment modes are currently available:
* `build-and-test`: run `cargo build` and `cargo test` on every crate
* `build-only`: run `cargo build` on every crate
* `check-only`: run `cargo check` on every crate (faster)
* `rustdoc`: run `cargo doc --no-deps` on every crate

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 @@ -21,6 +21,7 @@ string_enum!(pub enum Mode {
BuildAndTest => "build-and-test",
BuildOnly => "build-only",
CheckOnly => "check-only",
Rustdoc => "rustdoc",
UnstableFeatures => "unstable-features",
});

Expand Down
4 changes: 4 additions & 0 deletions src/runner/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ pub(super) fn build_graph(ex: &Experiment, config: &Config) -> TasksGraph {
tc: tc.clone(),
quiet,
},
Mode::Rustdoc => TaskStep::Rustdoc {
tc: tc.clone(),
quiet,
},
Mode::UnstableFeatures => TaskStep::UnstableFeatures { tc: tc.clone() },
},
},
Expand Down
30 changes: 30 additions & 0 deletions src/runner/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub(super) enum TaskStep {
BuildAndTest { tc: Toolchain, quiet: bool },
BuildOnly { tc: Toolchain, quiet: bool },
CheckOnly { tc: Toolchain, quiet: bool },
Rustdoc { tc: Toolchain, quiet: bool },
UnstableFeatures { tc: Toolchain },
}

Expand All @@ -39,6 +40,12 @@ impl fmt::Debug for TaskStep {
write!(f, " (quiet)")?;
}
}
TaskStep::Rustdoc { ref tc, quiet } => {
write!(f, "doc {}", tc.to_string())?;
if quiet {
write!(f, " (quiet)")?;
}
}
TaskStep::UnstableFeatures { ref tc } => {
write!(f, "find unstable features on {}", tc.to_string())?;
}
Expand Down Expand Up @@ -71,6 +78,7 @@ impl Task {
TaskStep::BuildAndTest { ref tc, .. }
| TaskStep::BuildOnly { ref tc, .. }
| TaskStep::CheckOnly { ref tc, .. }
| TaskStep::Rustdoc { ref tc, .. }
| TaskStep::UnstableFeatures { ref tc } => {
db.get_result(ex, tc, &self.krate).unwrap_or(None).is_none()
}
Expand All @@ -89,6 +97,7 @@ impl Task {
TaskStep::BuildAndTest { ref tc, .. }
| TaskStep::BuildOnly { ref tc, .. }
| TaskStep::CheckOnly { ref tc, .. }
| TaskStep::Rustdoc { ref tc, .. }
| TaskStep::UnstableFeatures { ref tc } => {
db.record_result(ex, tc, &self.krate, || {
error!("this task or one of its parent failed!");
Expand All @@ -114,6 +123,7 @@ impl Task {
}
TaskStep::BuildOnly { ref tc, quiet } => self.run_build_only(config, ex, tc, db, quiet),
TaskStep::CheckOnly { ref tc, quiet } => self.run_check_only(config, ex, tc, db, quiet),
TaskStep::Rustdoc { ref tc, quiet } => self.run_rustdoc(config, ex, tc, db, quiet),
TaskStep::UnstableFeatures { ref tc } => self.run_unstable_features(config, ex, db, tc),
}
}
Expand Down Expand Up @@ -199,6 +209,26 @@ impl Task {
).map(|_| ())
}

fn run_rustdoc<DB: WriteResults>(
&self,
config: &Config,
ex: &Experiment,
tc: &Toolchain,
db: &DB,
quiet: bool,
) -> Fallible<()> {
test::run_test(
config,
"documenting",
ex,
tc,
&self.krate,
db,
quiet,
test::test_rustdoc,
).map(|_| ())
}

fn run_unstable_features<DB: WriteResults>(
&self,
config: &Config,
Expand Down
36 changes: 35 additions & 1 deletion src/runner/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,20 @@ fn run_cargo(
rustflags.push_str(tc_rustflags);
}

let rustflags_env = if let Some(&"doc") = args.get(0) {
"RUSTDOCFLAGS"
} else {
"RUSTFLAGS"
};

RunCommand::new(CARGO.toolchain(toolchain))
.args(args)
.quiet(quiet)
.cd(source_path)
.env("CARGO_TARGET_DIR", "/target")
.env("CARGO_INCREMENTAL", "0")
.env("RUST_BACKTRACE", "full")
.env("RUSTFLAGS", rustflags)
.env(rustflags_env, rustflags)
.sandboxed()
.mount(target_dir, "/target", MountPerms::ReadWrite)
.memory_limit(Some(config.sandbox.memory_limit))
Expand Down Expand Up @@ -202,3 +208,31 @@ pub fn test_check_only(
Ok(TestResult::TestPass)
}
}

pub fn test_rustdoc(
config: &Config,
ex: &Experiment,
source_path: &Path,
toolchain: &Toolchain,
quiet: bool,
) -> Fallible<TestResult> {
let res = run_cargo(
config,
ex,
source_path,
toolchain,
quiet,
&["doc", "--frozen", "--no-deps", "--document-private-items"],
);

// Make sure to remove the built documentation
// There is no point in storing it after the build is done
let target_dir = toolchain.target_dir(&ex.name);
::utils::fs::remove_dir_all(&target_dir.join("doc"))?;

if let Err(err) = res {
Ok(TestResult::BuildFail(failure_reason(&err)))
} else {
Ok(TestResult::TestPass)
}
}
1 change: 1 addition & 0 deletions src/server/routes/ui/experiments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ impl ExperimentData {
Mode::BuildAndTest => "cargo test",
Mode::BuildOnly => "cargo build",
Mode::CheckOnly => "cargo check",
Mode::Rustdoc => "cargo doc",
Mode::UnstableFeatures => "unstable features",
},
assigned_to: experiment.assigned_to.as_ref().map(|a| a.to_string()),
Expand Down