Skip to content

Commit

Permalink
Rollup merge of #81675 - poliorcetics:respect-shortness, r=jyn514
Browse files Browse the repository at this point in the history
Make rustdoc respect `--error-format short` in doctests

Note that this will not work with `cargo test`, only with `rustdoc --test`, I'll have to modify `cargo` as well.

Fix #81662.

`@rustbot` label +T-rustdoc +A-doctests
  • Loading branch information
m-ou-se authored Feb 5, 2021
2 parents add80c9 + 716d2cd commit e8aaa14
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/librustdoc/doctest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,12 @@ fn run_test(
}
});
if let ErrorOutputType::HumanReadable(kind) = options.error_format {
let (_, color_config) = kind.unzip();
let (short, color_config) = kind.unzip();

if short {
compiler.arg("--error-format").arg("short");
}

match color_config {
ColorConfig::Never => {
compiler.arg("--color").arg("never");
Expand Down
12 changes: 12 additions & 0 deletions src/test/rustdoc-ui/issue-81662-shortness.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// compile-flags:--test --error-format=short
// normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR"
// normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"
// failure-status: 101

/// ```rust
/// foo();
/// ```
//~^^ ERROR cannot find function `foo` in this scope
fn foo() {
println!("Hello, world!");
}
16 changes: 16 additions & 0 deletions src/test/rustdoc-ui/issue-81662-shortness.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

running 1 test
test $DIR/issue-81662-shortness.rs - foo (line 6) ... FAILED

failures:

---- $DIR/issue-81662-shortness.rs - foo (line 6) stdout ----
$DIR/issue-81662-shortness.rs:7:1: error[E0425]: cannot find function `foo` in this scope
error: aborting due to previous error
Couldn't compile the test.

failures:
$DIR/issue-81662-shortness.rs - foo (line 6)

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME

0 comments on commit e8aaa14

Please sign in to comment.