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

Implement x.py test src/tools/clippy --bless #84189

Merged
merged 1 commit into from
Apr 29, 2021
Merged

Conversation

jyn514
Copy link
Member

@jyn514 jyn514 commented Apr 14, 2021

  • Add clippy_dev to the rust workspace

    Before, it would give an error that it wasn't either included or
    excluded from the workspace:

    error: current package believes it's in a workspace when it's not:
    current:   /home/joshua/rustc/src/tools/clippy/clippy_dev/Cargo.toml
    workspace: /home/joshua/rustc/Cargo.toml
    
    this may be fixable by adding `src/tools/clippy/clippy_dev` to the `workspace.members` array of the manifest located at: /home/joshua/rustc/Cargo.toml
    Alternatively, to keep it out of the workspace, add the package to the `workspace.exclude` array, or add an empty `[workspace]` table to the package's manifest.
    
  • Change clippy's copy of compiletest not to special-case
    rust-lang/rust. Using OUT_DIR confused clippy_dev and it couldn't find
    the test outputs. This is one of the reasons why cargo dev bless used
    to silently do nothing (the others were that CARGO_TARGET_DIR and
    PROFILE weren't set appropriately).

  • Run clippy_dev on test failure

I tested this by removing a couple lines from a stderr file, and they
were correctly replaced.

  • Fix clippy_dev warnings

@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 14, 2021
@jyn514 jyn514 added A-clippy Area: Clippy A-contributor-roadblock Area: Makes things more difficult for new contributors to rust itself T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Apr 14, 2021
@Mark-Simulacrum
Copy link
Member

Does this actually work for blessing? Can we hook up x.py to run this?

@jyn514
Copy link
Member Author

jyn514 commented Apr 14, 2021

I don't know. I don't have time to look into it right now.

@jyn514
Copy link
Member Author

jyn514 commented Apr 14, 2021

Ok, I updated this to implement cargo test --bless src/tools/clippy.

@jyn514 jyn514 changed the title Allow running cargo dev from inside src/tools/clippy Implement x.py test src/tools/clippy --bless Apr 14, 2021
@jyn514
Copy link
Member Author

jyn514 commented Apr 25, 2021

@Mark-Simulacrum do you know when you'll have a chance to look at this? In the meantime I've been cherry-picking the commit for #84039.

std::process::exit(1);
}

println!("running `cargo dev bless` on clippy tests");
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason for an explicit message here? compiletest blessing is silent -- is there a reason we can't pull that off here?

FWIW I find it a bit interesting that unlike compiletest this is a separate command etc -- maybe @Manishearth or someone familiar with clippy can say why? I'd expect this to be just a flag passed in to compile test when running clippy's tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

No particular reason, I'll remove it.

Copy link
Contributor

Choose a reason for hiding this comment

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

separate command

I think it's just because the compiletest bless functionality is newer and we just haven't migrated to it yet. But we also have an added feature where cargo dev bless only updates files that were updated after the last clippy build.

@Mark-Simulacrum
Copy link
Member

@Manishearth can you either investigate or ping someone who could why we're seeing slightly different test outputs when blessing with this PR (Vec::new -> .., for example; see PR description).

@Manishearth
Copy link
Member

cc @camsteffen @flip1995

unsure what's going on here, that looks like span_from_snippet failing but idk why

Also it could be divergences in compiletest. We tried to convince the compiler team to move compiletest out of tree but they weren't really in favor.

@flip1995
Copy link
Member

AFAIK the compiletest Clippy uses doesn't have bless support, so we implemented in Clippy on our own. @xFrednet and @phansch worked on this command mainly, so they probably have insight into this. Also why cargo dev bless changes files that shouldn't be changed.

@jyn514
Copy link
Member Author

jyn514 commented Apr 27, 2021

can you either investigate or ping someone who could why we're seeing slightly different test outputs when blessing with this PR (Vec::new -> .., for example; see PR description).

It's also possible that I just need to rebase over master or something - I haven't spent too much time looking into this.

@Manishearth
Copy link
Member

Manishearth commented Apr 27, 2021

That sounds like it's not unlikely 😄

@xFrednet
Copy link
Member

I'm sadly not totally up to date when it comes to the bless command due to some RL obligations. I believe @camsteffen has also worked on the bless command in Clippy, so he might know something about this 🙃

@flip1995
Copy link
Member

@jyn514 I checked out your branch, rebased it on top of the current master and tried ./x.py test --bless src/tools/clippy after modifying some stderr files in the clippy dir.It didn't update any test files other than the modified.

@flip1995
Copy link
Member

It would be great if you could also apply this patch:

diff --git a/src/tools/clippy/clippy_dev/src/new_lint.rs b/src/tools/clippy/clippy_dev/src/new_lint.rs
index d951ca0e630..4676c2affad 100644
--- a/src/tools/clippy/clippy_dev/src/new_lint.rs
+++ b/src/tools/clippy/clippy_dev/src/new_lint.rs
@@ -44,7 +44,7 @@ pub fn create(pass: Option<&str>, lint_name: Option<&str>, category: Option<&str
     create_test(&lint).context("Unable to create a test for the new lint")
 }
 
-fn create_lint(lint: &LintData) -> io::Result<()> {
+fn create_lint(lint: &LintData<'_>) -> io::Result<()> {
     let (pass_type, pass_lifetimes, pass_import, context_import) = match lint.pass {
         "early" => ("EarlyLintPass", "", "use rustc_ast::ast::*;", "EarlyContext"),
         "late" => ("LateLintPass", "<'_>", "use rustc_hir::*;", "LateContext"),
@@ -68,7 +68,7 @@ fn create_lint(lint: &LintData) -> io::Result<()> {
     write_file(lint.project_root.join(&lint_path), lint_contents.as_bytes())
 }
 
-fn create_test(lint: &LintData) -> io::Result<()> {
+fn create_test(lint: &LintData<'_>) -> io::Result<()> {
     fn create_project_layout<P: Into<PathBuf>>(lint_name: &str, location: P, case: &str, hint: &str) -> io::Result<()> {
         let mut path = location.into().join(case);
         fs::create_dir(&path)?;

- Add clippy_dev to the rust workspace

  Before, it would give an error that it wasn't either included or
  excluded from the workspace:

  ```
  error: current package believes it's in a workspace when it's not:
  current:   /home/joshua/rustc/src/tools/clippy/clippy_dev/Cargo.toml
  workspace: /home/joshua/rustc/Cargo.toml

  this may be fixable by adding `src/tools/clippy/clippy_dev` to the `workspace.members` array of the manifest located at: /home/joshua/rustc/Cargo.toml
  Alternatively, to keep it out of the workspace, add the package to the `workspace.exclude` array, or add an empty `[workspace]` table to the package's manifest.
  ```

- Change clippy's copy of compiletest not to special-case
  rust-lang/rust. Using OUT_DIR confused `clippy_dev` and it couldn't find
  the test outputs. This is one of the reasons why `cargo dev bless` used
  to silently do nothing (the others were that `CARGO_TARGET_DIR` and
  `PROFILE` weren't set appropriately).

- Run clippy_dev on test failure

I tested this by removing a couple lines from a stderr file, and they
were correctly replaced.

- Fix clippy_dev warnings
@jyn514
Copy link
Member Author

jyn514 commented Apr 27, 2021

It would be great if you could also apply this patch:

Sure thing, done.

@camsteffen
Copy link
Contributor

So no outstanding concerns here? Just checking since I was tagged.

@Mark-Simulacrum
Copy link
Member

@jyn514 Can you update the PR description to reflect what I think is the current state, i.e., that this just works?

If so, r=me

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 28, 2021
@jyn514
Copy link
Member Author

jyn514 commented Apr 28, 2021

Oops, I updated the commit message but not the description. Now fixed.

@bors r=Mark-Simulacrum

@bors
Copy link
Contributor

bors commented Apr 28, 2021

📌 Commit 8c25e27 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-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 28, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Apr 29, 2021
Implement `x.py test src/tools/clippy --bless`

- Add clippy_dev to the rust workspace

  Before, it would give an error that it wasn't either included or
  excluded from the workspace:

  ```
  error: current package believes it's in a workspace when it's not:
  current:   /home/joshua/rustc/src/tools/clippy/clippy_dev/Cargo.toml
  workspace: /home/joshua/rustc/Cargo.toml

  this may be fixable by adding `src/tools/clippy/clippy_dev` to the `workspace.members` array of the manifest located at: /home/joshua/rustc/Cargo.toml
  Alternatively, to keep it out of the workspace, add the package to the `workspace.exclude` array, or add an empty `[workspace]` table to the package's manifest.
  ```

- Change clippy's copy of compiletest not to special-case
  rust-lang/rust. Using OUT_DIR confused `clippy_dev` and it couldn't find
  the test outputs. This is one of the reasons why `cargo dev bless` used
  to silently do nothing (the others were that `CARGO_TARGET_DIR` and
  `PROFILE` weren't set appropriately).

- Run clippy_dev on test failure

I tested this by removing a couple lines from a stderr file, and they
were correctly replaced.

- Fix clippy_dev warnings
@bors
Copy link
Contributor

bors commented Apr 29, 2021

⌛ Testing commit 8c25e27 with merge 267ddd8719e80bbcdf8613881b8f87788de74412...

@bors
Copy link
Contributor

bors commented Apr 29, 2021

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 29, 2021
@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
 19  424M   19 84.6M    0     0  11.2M      0  0:00:37  0:00:07  0:00:30 11.1M
 21  424M   21 90.5M    0     0  10.5M      0  0:00:40  0:00:08  0:00:32 10.0M
 22  424M   22 96.5M    0     0  10.1M      0  0:00:41  0:00:09  0:00:32 9194k
 24  424M   24  101M    0     0  10.2M      0  0:00:41  0:00:09  0:00:32 8766k
curl: (56) OpenSSL SSL_read: Connection reset by peer, errno 54
clang+llvm-10.0.0-x86_64-apple-darwin/bin/modularize: Lzma library error:  No progress is possible
tar: Error exit delayed from previous errors.
##[error]Process completed with exit code 1.
[command]/usr/local/bin/git version
git version 2.31.1
[command]/usr/local/bin/git config --local --name-only --get-regexp core\.sshCommand
[command]/usr/local/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :

@jyn514
Copy link
Member Author

jyn514 commented Apr 29, 2021

curl: (56) OpenSSL SSL_read: Connection reset by peer, errno 54

@bors retry

@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-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 29, 2021
@bors
Copy link
Contributor

bors commented Apr 29, 2021

⌛ Testing commit 8c25e27 with merge 10a51c0...

@bors
Copy link
Contributor

bors commented Apr 29, 2021

☀️ Test successful - checks-actions
Approved by: Mark-Simulacrum
Pushing 10a51c0 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 29, 2021
@bors bors merged commit 10a51c0 into rust-lang:master Apr 29, 2021
@rustbot rustbot added this to the 1.53.0 milestone Apr 29, 2021
@jyn514 jyn514 deleted the clippy-dev branch April 29, 2021 14:36
flip1995 pushed a commit to flip1995/rust that referenced this pull request May 6, 2021
Implement `x.py test src/tools/clippy --bless`

- Add clippy_dev to the rust workspace

  Before, it would give an error that it wasn't either included or
  excluded from the workspace:

  ```
  error: current package believes it's in a workspace when it's not:
  current:   /home/joshua/rustc/src/tools/clippy/clippy_dev/Cargo.toml
  workspace: /home/joshua/rustc/Cargo.toml

  this may be fixable by adding `src/tools/clippy/clippy_dev` to the `workspace.members` array of the manifest located at: /home/joshua/rustc/Cargo.toml
  Alternatively, to keep it out of the workspace, add the package to the `workspace.exclude` array, or add an empty `[workspace]` table to the package's manifest.
  ```

- Change clippy's copy of compiletest not to special-case
  rust-lang/rust. Using OUT_DIR confused `clippy_dev` and it couldn't find
  the test outputs. This is one of the reasons why `cargo dev bless` used
  to silently do nothing (the others were that `CARGO_TARGET_DIR` and
  `PROFILE` weren't set appropriately).

- Run clippy_dev on test failure

I tested this by removing a couple lines from a stderr file, and they
were correctly replaced.

- Fix clippy_dev warnings
@estebank
Copy link
Contributor

I'm making some changes to the structured suggestion output, and it seems like I'm unable to get my local environment to fail the tests that are failing in CI. I'm not sure if it is because cargo uitest is not actually using my locally built rustc/cargo (maybe due to the toolchain file?). I've tried invoking with ./x.py test src/tools/clippy --stage 2 --bless, which seems like it should do the right thing, but I am currently stuck. Could someone point me in the direction on how to keep clippy's tests in sync with rustc?

@jyn514
Copy link
Member Author

jyn514 commented Aug 11, 2021

That should work. If it's not, I don't know what's going wrong, sorry.

@estebank
Copy link
Contributor

estebank commented Aug 11, 2021

I just lost two hours to being in the wrong branch 🤦‍♂️

Edit: BTW, thank you @jyn514 for improving the workflow here! Had it not been for my PEBKAC problem, the current behavior is almost perfect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-clippy Area: Clippy A-contributor-roadblock Area: Makes things more difficult for new contributors to rust itself 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. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.