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

[Roadmap] Turn cargo dev into Clippys ./x.py #5394

Open
5 of 9 tasks
flip1995 opened this issue Mar 30, 2020 · 10 comments
Open
5 of 9 tasks

[Roadmap] Turn cargo dev into Clippys ./x.py #5394

flip1995 opened this issue Mar 30, 2020 · 10 comments
Assignees
Labels
A-infra Area: CI issues and issues that require full access for GitHub/CI C-tracking-issue Category: Tracking Issue E-help-wanted Call for participation: Help is requested to fix this issue. P-low Priority: Low

Comments

@flip1995
Copy link
Member

flip1995 commented Mar 30, 2020

There's already cargo dev which makes Clippy development easier and more
pleasant. This can still be expanded, so that it covers more areas of the
development process.

Steps to completion:

  • bless execute UI-tests and update reference files
  • init include setup-toolchain.sh in clippy_dev (outdated)
  • pr (?) Run everything (fmt, update_lints, ...?), so that the changes probably pass CI
  • deprecate to deprecate a Clippy lint. This is especially useful if people want to uplift Clippy lints.
  • Better integrate cargo dev in rust-lang/rust so that commands are also usable there
  • Add git commit hooks running cargo dev commands before committing (Added cargo dev setup git-hook and updated cargo dev setup intellij including a remove command #7361)
  • cargo dev rename_lint(See issue cargo dev rename_lint #7799)
  • cargo dev dogfood --fix
  • ... ideas?

These are some ideas, that I had, maybe we can even further expand the clippy_dev tool.

@flip1995 flip1995 added S-needs-discussion Status: Needs further discussion before merging or work can be started A-infra Area: CI issues and issues that require full access for GitHub/CI C-tracking-issue Category: Tracking Issue labels Mar 30, 2020
bors added a commit that referenced this issue Mar 31, 2020
Stop updating the lint counter with every new lint

r? @Manishearth

This PR does two things:

1. Clean up the clippy_dev module a bit (first 3 commits; cc #5394 )
2. Make the counter in the README count in steps of 50 lints. Also use a `lazy_static` `Vec` for the lint list, so no counter is required there anymore.

changelog: none
@flip1995 flip1995 pinned this issue Apr 1, 2020
@flip1995 flip1995 added the E-help-wanted Call for participation: Help is requested to fix this issue. label Apr 1, 2020
phansch added a commit to phansch/rust-clippy that referenced this issue Apr 26, 2020
`cargo dev` has been the replacement for a while, so I think we can
remove it now.

cc rust-lang#5394
bors added a commit that referenced this issue Apr 26, 2020
Remove util/dev script

`cargo dev` has been the replacement for a while, so I think we can
remove it now.

cc #5394

changelog: none
ThibsG pushed a commit to ThibsG/rust-clippy that referenced this issue May 2, 2020
`cargo dev` has been the replacement for a while, so I think we can
remove it now.

cc rust-lang#5394
bors added a commit that referenced this issue Aug 23, 2020
Fix cargo dev new_lint for late lint passes

Since 30c046e, `LateLintPass` has only one lifetime parameter.

I'm not sure how to easily test this, I think adding this kind of tests would be probably part of #5394

changelog: none
@phansch
Copy link
Member

phansch commented Nov 30, 2020

I'm going to work on adding the bless subcommand to clippy_dev this week.

phansch added a commit to phansch/rust-clippy that referenced this issue Dec 2, 2020
This replaces the `update-all-references` scripts with a single

    cargo dev bless

command.

cc rust-lang#5394
phansch added a commit to phansch/rust-clippy that referenced this issue Dec 12, 2020
This replaces the `update-all-references` scripts with a single

    cargo dev bless

command.

cc rust-lang#5394
bors added a commit that referenced this issue Dec 12, 2020
Rewrite update-all-references bash scripts in Rust

This replaces the `update-all-references` scripts with a single

    cargo dev bless

command. It should behave mostly the same as the bash scripts. The major difference is, that it can be called from the project root and will always update the files in all of the test suites.

cc #5394

changelog: none
@flip1995 flip1995 changed the title Turn cargo dev into Clippys ./x.py [Roadmap] Turn cargo dev into Clippys ./x.py Jan 22, 2021
@flip1995 flip1995 removed the S-needs-discussion Status: Needs further discussion before merging or work can be started label Jan 22, 2021
@flip1995 flip1995 added the P-low Priority: Low label Jan 22, 2021
@xFrednet
Copy link
Member

@rustbot claim

@phansch
Copy link
Member

phansch commented Jan 26, 2021

@xFrednet Assuming, you want to work on the cargo dev bless integration into
x.py, here's a short summary of the current state of blessing in rustc and
Clippy:

Rustc's bless is implemented in the compiletest library living inside the rustc tree.
Clippy is using a custom fork of that library: compiletest-rs.

The custom fork that Clippy is using, currently doesn't have a bless
feature. Instead, Clippy's bless is a custom implementation in clippy_dev.

Two months later, I think that was a bad choice on my end. It would have been
much better to add bless support to compiletest-rs. This way we would have
more similarities between rustc tools and the tools Clippy is using. It would
have also allowed miri to get bless support for their testsuite, I think.
Finally, I believe it would also be easier to integrate it with x.py this way.

Considering all that, I think we would be better off throwing away our custom bless
implementation and adding bless support to compiletest-rs instead.

My proposal would be:

  1. I'm opening a PR to compiletest-rs with the addition of the bless
    feature. That is mostly copy/pasting of code.
  2. The interesting part then,
    would be to change cargo dev bless to use the blessing mechanism of
    compiletest-rs and then integrating cargo dev bless into x.py

cc @flip1995 for the general plan
and cc @camsteffen because we would probably lose the feature added in #6547

@xFrednet
Copy link
Member

I've worked with compiletest-rs before in a different project and having a general bless feature as a part of it would definitely be beneficial to not just Clippy but for the entire Rust ecosystem. Therefore, I'm in favor of your proposal.

The first step sounds pretty straight forward. I'm happy to help if you need any support.

The second part is definitely the interesting part. This step will probably also depend on the bless interface implementation in compiletest-rs. I'll try to get more into compiletest-rs and the current bless implementation until that point.

Is there still some area that needs refinement when it comes to your proposal? It seems like you've already started on the implementation.


Thank you very much for the summary @phansch. It seemed a bit frightening at the beginning, but it's very clear, and gave me good overview! :)

@phansch
Copy link
Member

phansch commented Jan 31, 2021

Is there still some area that needs refinement when it comes to your proposal? It seems like you've already started on the implementation.

The only thing I can think of is a feature like #6547. I don't think that currently exists in any of the compiletest variants. This would first have to be added to Rustc's compiletest. Once that's merged, it could be copied over to compiletest-rs. I think that could be done somewhat independently of the other work as well.

Additionally, while we are waiting for Manishearth/compiletest-rs#232 and Manishearth/compiletest-rs#231 to be merged, I think it would be possible to work on a Clippy PR already that uses the new bless:

  1. Check out Add basic bless support Manishearth/compiletest-rs#231 locally
  2. Point Clippy's compiletest-rs dependency to your local checkout
  3. Start reworking cargo dev bless to use the compiletest blessing mechanism

@xFrednet
Copy link
Member

Hey @phansch congratulations on having the bless PR merged, that is really awesome!

You mentioned two tasks in your previous comment

  1. work on a Clippy PR that uses the new bless

  2. feature like Curse outdated test output #6547

Have you started to work on one of these? I'm not sure if we want to wait on the switch to the new bless for a feature like #6547. I would look into implementing #6547 into the Rustc's compiletest if you haven't started already and if you think that it's worth to wait until it has also reached into laumann/compiletest-rs. What is your opinion on it? 🙃

@phansch
Copy link
Member

phansch commented Feb 13, 2021

@xFrednet I haven't started any new work here, yet. To me it seems better to start with adding #6547 to Rustc's compiletest first.

Do you already have an idea how to implement it? I just know that the code would have to go somewhere here but I don't know on which condition it should skip writing the output file.
For Clippy the condition was easy: If the output file was changed before the last Clippy build, then don't update it again.
But Rustc's compiletest is used for rustdoc, rustc and a few other things, so we would have to check the timestamps of those binaries as well. I guess compiletest has to store the path to the executing binary somewhere, so that's something to check for sure.

@xFrednet
Copy link
Member

Hmm, this definitely makes it more complicated. I expected that it is only used by one binary. My initial idea after your comment was to keep track of which test has been run in the last execution and only update those files. However, that idea seems pretty limiting on second thought.

Checking the timestamps on the binaries seems like a simple solution. But I'm not sure how generalizable it would be. We could think of adding a tag to the file that states the used binary and the binary compilation timestamps. The bless implementation could then specifically check if the test used the latest build. (This tag could be added in the first line of the test output or in a separate file. This tag would obviously be ignored by the comparison function).

Another idea I had was to add some kind of cli interface as it's likely that bless will be invoked by the user. It could look something like this:

> /update-references.sh --bless
Which tests do you want to update?
| No | Test                                  | Timestamp        |
|  0 | Abord                                 |                  |
|  1 | test/ui/atomic_ordering_int           | 2021-02-13 18:04 |
|  2 | test/ui/bind_instead_of_map_multipart | 2021-02-13 18:02 |
|  3 | test/ui/needless_doc_main             | 2021-02-13 18:01 |
|  4 | test/ui/neg_multiply                  | 2021-02-12 13:17 |
|  5 | test/ui/never_loop                    | 2021-02-12 13:01 |

This could also include some kind of auto feature which updates all files since the last build. However, I'm not sure how viable that option is. What are your thoughts on this? @phansch

@phansch
Copy link
Member

phansch commented Feb 15, 2021

Looking a bit more into this, I think there's still an easy way: It looks like compiletest has a rustc_path option that we can use to get the path to the binary here. To make it easier for us, we can also limit this feature to the 'UI' testsuite for a start:
Here you can check that using self.config.mode == Mode::Ui and then do the timestamp comparison.

The CLI interface looks nice, but I think it's something that would require an MCP first because it would potentially change the workflow for many Rust contributors.

bors added a commit that referenced this issue Feb 15, 2021
Upgrade compiletest-rs to 0.6 and tester to 0.9

These updates allow us to specify multiple testnames for `TESTNAME` by
providing a comma separated list of testnames.

The new version of compiletest-rs also includes `bless` support, but is
not enabled with this PR.

cc #5394

changelog: none
@xFrednet
Copy link
Member

Rusts x.py file also has the ability to install a commit hook for git. I think that would be a nice addition at least for new members. It could roughly run the following lines:

cargo dev update_lints
cargo dev fmt

And optionally also cargo test if somebody wants that :)

bors added a commit that referenced this issue Jun 25, 2021
Added `cargo dev setup git-hook` and updated `cargo dev setup intellij` including a `remove` command

This PR enables our dev tool to install a git hook that formats the code before each commit and also runs `update_lints` to make sure that everything is registered correctly. The script is located at `util/etc/pre-commit.sh`. I found it reasonable to locate it in the `util` folder and decided to add a `etc` in correlation to the main rust repo and to bring a bit of structure into it.

* The hook can be installed via: `cargo dev setup git-hook`
* And removed via: `cargo dev remove git-hook`

cc: #5394

The refactoring of `src/ide_setup.rs` to `src/setup/intellij.rs` is an extra commit to simplify the review.

---

Changes:
* Added `cargo dev setup git-hook` for formatting before every commit
* Added `cargo dev remove git-hook` to remove the hook again
* Added `cargo dev remove intellij` to remove rustc source path dependencies
* Changed `cargo dev ide_setup` to `cargo dev setup intellij`

changelog: none

This is only an internal change and therefore not worth an entry in the general change log.

---

Tested on:
* [x] Linux (by `@xFrednet)`
* [ ] Windows (All used commands run inside the git bash, so it's very likely to work as well `@xFrednet)`
* [ ] macOS
bors added a commit that referenced this issue Jun 29, 2021
Added `cargo dev setup vscode-tasks` for simplicity

This PR adds a setup command to `clippy dev` that installs tasks into the Clippy vscode workspace. These might be useful as they be used via shortcuts and are accessible over the GUI. The available tasks are:
* `cargo check` (standard Linux shortcut `[ctrl] + [shift] + b`)
* `cargo dev fmt`
* `cargo uitest` (with a comment how to add the `TESTNAME` environment value)
* `cargo test`
* `cargo dev bless`

---

changelog: none

only internal changes again. cc #5394

r? `@flip1995` This should be pretty much the same as the other `cargo dev setup` commands. Would you mind reviewing this? 🙃
@flip1995 flip1995 unpinned this issue Nov 18, 2021
@xFrednet xFrednet removed their assignment Mar 10, 2022
bors added a commit that referenced this issue Jul 1, 2022
Add `cargo dev dogfood`

changelog: Add `cargo dev dogfood`

Part of #5394
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-infra Area: CI issues and issues that require full access for GitHub/CI C-tracking-issue Category: Tracking Issue E-help-wanted Call for participation: Help is requested to fix this issue. P-low Priority: Low
Projects
None yet
Development

No branches or pull requests

3 participants