Skip to content

Commit 45d86f6

Browse files
committed
Auto merge of #543 - jyn514:doc-runs, r=<try>
[WIP] Read docs.rs metadata when running rustdoc Closes #532 <details><summary>Outdated errors</summary> I'm having trouble running the test suite, so I haven't yet added a test. My idea was to have a crate that only builds successfully when you read the metadata, but I'm not sure if that would work with the way the test suite is set up. Current errors: ``` $ cargo test minicrater -- single_thread_small --ignored --test-threads 1 [2020-09-05T02:02:04Z INFO rustwide::cmd] running `Command { std: "/home/joshua/src/rust/crater/work/cargo-home/bin/cargo" "+stable" "install" "lazy_static", kill_on_drop: false }` [2020-09-05T02:02:04Z INFO rustwide::cmd] [stderr] Updating crates.io index [2020-09-05T02:02:04Z INFO rustwide::cmd] [stderr] error: specified package `lazy_static v1.4.0` has no binaries [2020-09-05T02:02:04Z ERROR crater::utils] Permission denied (os error 13) [2020-09-05T02:02:04Z ERROR crater::utils] note: run with `RUST_BACKTRACE=1` to display a backtrace. [2020-09-05T02:02:04Z INFO crater] command failed ', /home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/assert_cmd-0.10.1/src/assert.rs:154:13 ``` </details> Before merging, I need to publish the `docsrs-metadata` package to crates.io so crater doesn't depend on a git version. r? `@pietroalbini` help
2 parents dcc5456 + 4d1fd47 commit 45d86f6

21 files changed

+419
-125
lines changed

Cargo.lock

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ chrono-humanize = "0.0.11"
2020
crates-index = "0.12"
2121
crossbeam-utils = "0.5"
2222
csv = "1.0.2"
23+
docsrs-metadata = { git = "https://github.com/rust-lang/docs.rs/" }
2324
dotenv = "0.13"
2425
error-chain = "0.12"
2526
failure = "0.1.3"
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "docs-rs-features"
3+
version = "0.1.0"
4+
authors = ["Joshua Nelson <[email protected]>"]
5+
edition = "2018"
6+
7+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
9+
[dependencies]
10+
11+
[package.metadata.docs.rs]
12+
features = ["docs_rs_feature"]
13+
14+
[features]
15+
docs_rs_feature = []
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#[cfg(feature = "docs_rs_feature")]
2+
compile_error!("oh no, a hidden regression!");
3+
4+
fn main() {
5+
println!("Hello, world!");
6+
}

src/runner/test.rs

+24-11
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ use crate::runner::tasks::TaskCtx;
66
use crate::runner::OverrideResult;
77
use cargo_metadata::diagnostic::DiagnosticLevel;
88
use cargo_metadata::{Message, Metadata, PackageId};
9+
use docsrs_metadata::Metadata as DocsrsMetadata;
910
use failure::Error;
1011
use remove_dir_all::remove_dir_all;
1112
use rustwide::cmd::{CommandError, ProcessLinesActions, SandboxBuilder};
1213
use rustwide::{Build, PrepareError};
13-
use std::collections::{BTreeSet, HashSet};
14+
use std::collections::{BTreeSet, HashMap, HashSet};
1415
use std::convert::TryFrom;
1516

1617
fn failure_reason(err: &Error) -> FailureReason {
@@ -80,8 +81,9 @@ fn run_cargo<DB: WriteResults>(
8081
args: &[&str],
8182
check_errors: bool,
8283
local_packages_id: &HashSet<PackageId>,
84+
mut env: HashMap<&'static str, String>,
8385
) -> Fallible<()> {
84-
let mut rustflags = format!("--cap-lints={}", ctx.experiment.cap_lints.to_str());
86+
let mut rustflags = format!(" --cap-lints={}", ctx.experiment.cap_lints.to_str());
8587
if let Some(ref tc_rustflags) = ctx.toolchain.rustflags {
8688
rustflags.push(' ');
8789
rustflags.push_str(tc_rustflags);
@@ -92,6 +94,7 @@ fn run_cargo<DB: WriteResults>(
9294
} else {
9395
"RUSTFLAGS"
9496
};
97+
env.entry(rustflags_env).or_default().push_str(&rustflags);
9598

9699
let mut did_ice = false;
97100
let mut error_codes = BTreeSet::new();
@@ -146,8 +149,10 @@ fn run_cargo<DB: WriteResults>(
146149
.cargo()
147150
.args(args)
148151
.env("CARGO_INCREMENTAL", "0")
149-
.env("RUST_BACKTRACE", "full")
150-
.env(rustflags_env, rustflags);
152+
.env("RUST_BACKTRACE", "full");
153+
for (var, data) in env {
154+
command = command.env(var, data);
155+
}
151156

152157
if check_errors {
153158
command = command.process_lines(&mut detect_error);
@@ -238,13 +243,15 @@ fn build<DB: WriteResults>(
238243
&["build", "--frozen", "--message-format=json"],
239244
true,
240245
local_packages_id,
246+
HashMap::default(),
241247
)?;
242248
run_cargo(
243249
ctx,
244250
build_env,
245251
&["test", "--frozen", "--no-run", "--message-format=json"],
246252
true,
247253
local_packages_id,
254+
HashMap::default(),
248255
)?;
249256
Ok(())
250257
}
@@ -256,6 +263,7 @@ fn test<DB: WriteResults>(ctx: &TaskCtx<DB>, build_env: &Build) -> Fallible<()>
256263
&["test", "--frozen"],
257264
false,
258265
&HashSet::new(),
266+
HashMap::default(),
259267
)
260268
}
261269

@@ -308,6 +316,7 @@ pub(super) fn test_check_only<DB: WriteResults>(
308316
],
309317
true,
310318
local_packages_id,
319+
HashMap::default(),
311320
) {
312321
Ok(TestResult::BuildFail(failure_reason(&err)))
313322
} else {
@@ -332,6 +341,7 @@ pub(super) fn test_clippy_only<DB: WriteResults>(
332341
],
333342
true,
334343
local_packages_id,
344+
HashMap::default(),
335345
) {
336346
Ok(TestResult::BuildFail(failure_reason(&err)))
337347
} else {
@@ -344,18 +354,21 @@ pub(super) fn test_rustdoc<DB: WriteResults>(
344354
build_env: &Build,
345355
local_packages_id: &HashSet<PackageId>,
346356
) -> Fallible<TestResult> {
357+
let src = build_env.host_source_dir();
358+
let metadata = DocsrsMetadata::from_crate_root(src)?;
359+
let cargo_args = metadata.cargo_args();
360+
assert_eq!(cargo_args[0], "doc");
361+
let mut cargo_args: Vec<_> = cargo_args.iter().map(|s| s.as_str()).collect();
362+
cargo_args.push("--frozen");
363+
cargo_args.push("--message-format=json");
364+
347365
let res = run_cargo(
348366
ctx,
349367
build_env,
350-
&[
351-
"doc",
352-
"--frozen",
353-
"--no-deps",
354-
"--document-private-items",
355-
"--message-format=json",
356-
],
368+
&cargo_args,
357369
true,
358370
local_packages_id,
371+
metadata.environment_variables(),
359372
);
360373

361374
// Make sure to remove the built documentation

tests/minicrater/doc/config.toml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[server.bot-acl]
2+
rust-teams = true
3+
github = ["pietroalbini"]
4+
5+
[server.labels]
6+
remove = "^S-"
7+
experiment-queued = "S-waiting-on-crater"
8+
experiment-completed = "S-waiting-on-review"
9+
10+
[server.distributed]
11+
chunk-size = 32
12+
13+
[demo-crates]
14+
crates = []
15+
github-repos = []
16+
local-crates = ["build-pass", "docs-rs-features"]
17+
18+
[sandbox]
19+
memory-limit = "512M"
20+
build-log-max-size = "2M"
21+
build-log-max-lines = 1000
22+
23+
[crates]
24+
25+
[github-repos]
26+
27+
[local-crates]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"available_archives": [
3+
{
4+
"name": "All the crates",
5+
"path": "logs-archives/all.tar.gz"
6+
},
7+
{
8+
"name": "error crates",
9+
"path": "logs-archives/error.tar.gz"
10+
}
11+
],
12+
"crates_count": 2,
13+
"nav": [
14+
{
15+
"active": false,
16+
"label": "Summary",
17+
"url": "index.html"
18+
},
19+
{
20+
"active": false,
21+
"label": "Full report",
22+
"url": "full.html"
23+
},
24+
{
25+
"active": true,
26+
"label": "Downloads",
27+
"url": "downloads.html"
28+
}
29+
]
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
"categories": [
3+
[
4+
"error",
5+
{
6+
"Plain": [
7+
{
8+
"name": "build-pass (local)",
9+
"res": "error",
10+
"runs": [
11+
{
12+
"log": "stable/local/build-pass",
13+
"res": 0
14+
},
15+
{
16+
"log": "beta/local/build-pass",
17+
"res": 0
18+
}
19+
],
20+
"url": "https://github.com/rust-lang/crater/tree/master/local-crates/build-pass"
21+
},
22+
{
23+
"name": "docs-rs-features (local)",
24+
"res": "error",
25+
"runs": [
26+
{
27+
"log": "stable/local/docs-rs-features",
28+
"res": 0
29+
},
30+
{
31+
"log": "beta/local/docs-rs-features",
32+
"res": 0
33+
}
34+
],
35+
"url": "https://github.com/rust-lang/crater/tree/master/local-crates/docs-rs-features"
36+
}
37+
]
38+
}
39+
]
40+
],
41+
"comparison_colors": {
42+
"error": {
43+
"Single": "#d77026"
44+
}
45+
},
46+
"crates_count": 2,
47+
"full": true,
48+
"info": {
49+
"error": 2
50+
},
51+
"nav": [
52+
{
53+
"active": false,
54+
"label": "Summary",
55+
"url": "index.html"
56+
},
57+
{
58+
"active": true,
59+
"label": "Full report",
60+
"url": "full.html"
61+
},
62+
{
63+
"active": false,
64+
"label": "Downloads",
65+
"url": "downloads.html"
66+
}
67+
],
68+
"result_colors": [
69+
{
70+
"Single": "#d77026"
71+
}
72+
],
73+
"result_names": [
74+
"error"
75+
]
76+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
"categories": [
3+
[
4+
"error",
5+
{
6+
"Plain": [
7+
{
8+
"name": "build-pass (local)",
9+
"res": "error",
10+
"runs": [
11+
{
12+
"log": "stable/local/build-pass",
13+
"res": 0
14+
},
15+
{
16+
"log": "beta/local/build-pass",
17+
"res": 0
18+
}
19+
],
20+
"url": "https://github.com/rust-lang/crater/tree/master/local-crates/build-pass"
21+
},
22+
{
23+
"name": "docs-rs-features (local)",
24+
"res": "error",
25+
"runs": [
26+
{
27+
"log": "stable/local/docs-rs-features",
28+
"res": 0
29+
},
30+
{
31+
"log": "beta/local/docs-rs-features",
32+
"res": 0
33+
}
34+
],
35+
"url": "https://github.com/rust-lang/crater/tree/master/local-crates/docs-rs-features"
36+
}
37+
]
38+
}
39+
]
40+
],
41+
"comparison_colors": {
42+
"error": {
43+
"Single": "#d77026"
44+
}
45+
},
46+
"crates_count": 2,
47+
"full": false,
48+
"info": {
49+
"error": 2
50+
},
51+
"nav": [
52+
{
53+
"active": true,
54+
"label": "Summary",
55+
"url": "index.html"
56+
},
57+
{
58+
"active": false,
59+
"label": "Full report",
60+
"url": "full.html"
61+
},
62+
{
63+
"active": false,
64+
"label": "Downloads",
65+
"url": "downloads.html"
66+
}
67+
],
68+
"result_colors": [
69+
{
70+
"Single": "#d77026"
71+
}
72+
],
73+
"result_names": [
74+
"error"
75+
]
76+
}

0 commit comments

Comments
 (0)