Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error codes checkup and rustdoc test fix #67850

Merged
merged 2 commits into from
Jan 13, 2020

Conversation

GuillaumeGomez
Copy link
Member

@GuillaumeGomez GuillaumeGomez commented Jan 4, 2020

This PR does a few things:

  • fix how rustdoc checks that an error code has been thrown (it only checked for "E0XXX" so if it appeared in the output because the file has it in its name or wherever, it passed the test, which was incorrect)
  • fix the failing code examples that weren't throwing the expected error code

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-7 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2020-01-04T00:45:09.2620133Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-01-04T00:45:10.0570101Z ##[command]git config gc.auto 0
2020-01-04T00:45:10.0577246Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-01-04T00:45:10.0582873Z ##[command]git config --get-all http.proxy
2020-01-04T00:45:10.0586443Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/67850/merge:refs/remotes/pull/67850/merge

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@Mark-Simulacrum Mark-Simulacrum added the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Jan 4, 2020
@Mark-Simulacrum
Copy link
Member

I will review once #67837 has been merged and this is rebased atop of it (also, looks like there's a CI failure).

@GuillaumeGomez
Copy link
Member Author

Forgot to run rustfmt on the new checker... Let's wait for #67837 now. :)

@GuillaumeGomez
Copy link
Member Author

@Mark-Simulacrum #67837 has been merged. :)

src/bootstrap/test.rs Outdated Show resolved Hide resolved
src/tools/error-codes/main.rs Outdated Show resolved Hide resolved
src/tools/error-codes/main.rs Outdated Show resolved Hide resolved
@@ -704,6 +704,39 @@ impl Step for RustdocUi {
}
}

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct ErrorCodesCheck {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already a step to run rustdoc tests on the error index:

pub struct ErrorIndex {

Does it not work properly?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not for the same purpose. ErrorIndex generates it, but it doesn't test that the code examples inside the explanations are compiling (or not) as expected.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it does. It uses error_index_generator to concatenate all of the error code docs into a single error-index.md file and then runs rustdoc --test on that:

rust/src/bootstrap/test.rs

Lines 1411 to 1436 in 1756313

/// Runs the error index generator tool to execute the tests located in the error
/// index.
///
/// The `error_index_generator` tool lives in `src/tools` and is used to
/// generate a markdown file from the error indexes of the code base which is
/// then passed to `rustdoc --test`.
fn run(self, builder: &Builder<'_>) {
let compiler = self.compiler;
builder.ensure(compile::Std { compiler, target: compiler.host });
let dir = testdir(builder, compiler.host);
t!(fs::create_dir_all(&dir));
let output = dir.join("error-index.md");
let mut tool = tool::ErrorIndex::command(
builder,
builder.compiler(compiler.stage, builder.config.build),
);
tool.arg("markdown").arg(&output).env("CFG_BUILD", &builder.config.build);
builder.info(&format!("Testing error-index stage{}", compiler.stage));
let _time = util::timeit(&builder);
builder.run_quiet(&mut tool);
markdown_test(builder, compiler, &output);
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I can tell that it doesn't work since a lot of error codes I fixed in this PR weren't detected.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But why doesn't it work? If we have existing code that overlaps this one, ideally we'd fix the pre-existing code, rather than replace it wholesale (or at least, we should make sure that we're replacing it, rather than just also adding atop it).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good question. Let me check again.

fn run(self, builder: &Builder<'_>) {
builder.ensure(compile::Std { compiler: self.compiler, target: self.compiler.host });

let mut cmd = builder.tool_cmd(Tool::ErrorCodesCheck);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this really need to be done using a new tool? Rustbuild can already run rustdoc --test on all .md files in a directory using the DocTest step.

Either way this will be slower than the current ErrorIndex step because it will have to call rustdoc --test once for each error code rather than just once for all of them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to write a tool in any case to import the markdown files. So instead of having everything at once, at least we get a very precise error output. Also, the run is a bit longer, but nothing much bigger.

@GuillaumeGomez
Copy link
Member Author

Ping @Mark-Simulacrum

@Mark-Simulacrum
Copy link
Member

I think @ollie27's comments around error-index-generator need to get resolved and then I can take another look (or not, if it turns out we're already doing everything necessary here).

@GuillaumeGomez
Copy link
Member Author

@ollie27 was absolutely right: adding this new check was useless. I discovered this issue, believing that the change of the error explanations format somehow messed with the run of rustdoc --test so I fixed rustdoc and adding the new (and useless) checker. Luckily, it was detected and I removed it. Thanks a lot @ollie27!

I think this is ready now.

@Mark-Simulacrum
Copy link
Member

Please update the PR description (some of it seems a bit outdated). After that, r=me.

@GuillaumeGomez
Copy link
Member Author

@bors: r=Mark-Simulacrum

@bors
Copy link
Contributor

bors commented Jan 13, 2020

📌 Commit 5b7d64e has been approved by Mark-Simulacrum

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Jan 13, 2020
@bors
Copy link
Contributor

bors commented Jan 13, 2020

⌛ Testing commit 5b7d64e with merge bf84eb5...

bors added a commit that referenced this pull request Jan 13, 2020
…acrum

Error codes checkup and rustdoc test fix

This PR does a few things:

 * fix how rustdoc checks that an error code has been thrown (it only checked for "E0XXX" so if it appeared in the output because the file has it in its name or wherever, it passed the test, which was incorrect)
 * fix the failing code examples that weren't throwing the expected error code
@bors
Copy link
Contributor

bors commented Jan 13, 2020

☀️ Test successful - checks-azure
Approved by: Mark-Simulacrum
Pushing bf84eb5 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jan 13, 2020
@bors bors merged commit 5b7d64e into rust-lang:master Jan 13, 2020
@GuillaumeGomez GuillaumeGomez deleted the err-codes-checkup branch January 13, 2020 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants