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

Replace the metadata collector with tests #13221

Merged
merged 2 commits into from
Aug 13, 2024

Conversation

Alexendoo
Copy link
Member

@Alexendoo Alexendoo commented Aug 5, 2024

The metadata collector handles 3 files: CHANGELOG.md, lint_configuration.md and util/gh-pages/lints.json

  • CHANGELOG.md and lint_configuration.md are now checked by tests/config-metadata.rs, when they are outdated cargo test will fail with a message to run cargo bless --test config-metadata in order to update them

    A plain cargo bless will run all the tests, blessing both this and the UI tests

  • util/gh-pages/lints.json is now generated when running cargo uitest with COLLECT_METADATA=1 (still aliased to cargo collect-metadata)

    It uses a ui_test post test action to retrieve the applicability from the actual diagnostics emitted during UI tests

    Example change from the current to new JSON:

       {
         "id": "chars_next_cmp",
    -    "id_span": {
    -      "path": "src/methods/mod.rs",
    -      "line": 891
    -    },
    +    "id_location": "clippy_lints/src/methods/mod.rs#891",
         "group": "style",
         "level": "warn",
    -    "docs": "\n### What it does ... ```",
    +    "docs": "### What it does ... ```\n",
         "version": "pre 1.29.0",
    -    "applicability": {
    -      "is_multi_part_suggestion": false,
    -      "applicability": "Unresolved"
    -    }
    +    "applicability": "MachineApplicable"
       },

    Hide whitespace makes the compile-test.rs changes much easier to see

r? @flip1995

changelog: none

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Aug 5, 2024
tests/config-metadata.rs Outdated Show resolved Hide resolved
Copy link
Member

@flip1995 flip1995 left a comment

Choose a reason for hiding this comment

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

Still need to finalize my review, but overall this change makes sense to me. As the "metadata collection monster" is @xFrednet's baby, I also want to give them a chance to take a look.

@xFrednet xFrednet self-assigned this Aug 6, 2024
@xFrednet
Copy link
Member

xFrednet commented Aug 6, 2024

I already saw this PR and was a bit sad to see the monster go. But it has served us well, and maybe it's time for retirement.

I've skimmed very quickly skimmed over the changes and like the idea. I'll give it a review this week :D

@bors
Copy link
Collaborator

bors commented Aug 6, 2024

☔ The latest upstream changes (presumably #13225) made this pull request unmergeable. Please resolve the merge conflicts.

tests/compile-test.rs Outdated Show resolved Hide resolved
tests/compile-test.rs Outdated Show resolved Hide resolved
@bors
Copy link
Collaborator

bors commented Aug 8, 2024

☔ The latest upstream changes (presumably #13236) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Member

@xFrednet xFrednet left a comment

Choose a reason for hiding this comment

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

Very nice implementation. I really like how you collected all the information! It's a bit sad to see my metadata collection monster go, but this implementation is way better IMO!

Thank you for putting in the time!

@flip1995, I've reviewed all changes. If you don't have the time, you can r=me :D

@flip1995
Copy link
Member

@bors r=xFrednet

Thanks for reviewing this! I didn't get to review it this weekend (at least not for an in-depth review). I like the new way of testing it though. Great overall improvements!

@bors
Copy link
Collaborator

bors commented Aug 12, 2024

📌 Commit 54a1d76 has been approved by xFrednet

It is now in the queue for this repository.

bors added a commit that referenced this pull request Aug 12, 2024
Replace the metadata collector with tests

The metadata collector handles 3 files: [`CHANGELOG.md`](https://github.com/rust-lang/rust-clippy/blob/c082bc2cb85313901ed3565fcd285592ed93df0f/CHANGELOG.md#L6050), [`lint_configuration.md`](https://github.com/rust-lang/rust-clippy/blob/c082bc2cb85313901ed3565fcd285592ed93df0f/book/src/lint_configuration.md) and `util/gh-pages/lints.json`

- `CHANGELOG.md` and `lint_configuration.md` are now checked by `tests/config-metadata.rs`, when they are outdated `cargo test` will fail with a message to run `cargo bless --test config-metadata` in order to update them

   A plain `cargo bless` will run all the tests, blessing both this and the UI tests

- `util/gh-pages/lints.json` is now generated when running `cargo uitest` with `COLLECT_METADATA=1` (still aliased to `cargo collect-metadata`)

   It uses a `ui_test` [post test action](https://docs.rs/ui_test/latest/ui_test/custom_flags/trait.Flag.html#method.post_test_action) to retrieve the applicability from the actual diagnostics emitted during UI tests

   Example change from the current to new JSON:

   ```diff
      {
        "id": "chars_next_cmp",
   -    "id_span": {
   -      "path": "src/methods/mod.rs",
   -      "line": 891
   -    },
   +    "id_location": "clippy_lints/src/methods/mod.rs#891",
        "group": "style",
        "level": "warn",
   -    "docs": "\n### What it does ... ```",
   +    "docs": "### What it does ... ```\n",
        "version": "pre 1.29.0",
   -    "applicability": {
   -      "is_multi_part_suggestion": false,
   -      "applicability": "Unresolved"
   -    }
   +    "applicability": "MachineApplicable"
      },
   ```

   `Hide whitespace` makes the `compile-test.rs` changes much easier to see

r? `@flip1995`

changelog: none
@bors
Copy link
Collaborator

bors commented Aug 12, 2024

⌛ Testing commit 54a1d76 with merge 8838220...

@bors
Copy link
Collaborator

bors commented Aug 12, 2024

💔 Test failed - checks-action_test

@xFrednet
Copy link
Member

It looks like the metadata_collector test fails for i686-unknown-linux-gnu. We can restrict that test to 64bits and linux to see if that fixes it.

@Alexendoo
Copy link
Member Author

👀

Going to print a diff first, ideally it wouldn't be platform dependent

@Alexendoo
Copy link
Member Author

@bors try

bors added a commit that referenced this pull request Aug 12, 2024
Replace the metadata collector with tests

The metadata collector handles 3 files: [`CHANGELOG.md`](https://github.com/rust-lang/rust-clippy/blob/c082bc2cb85313901ed3565fcd285592ed93df0f/CHANGELOG.md#L6050), [`lint_configuration.md`](https://github.com/rust-lang/rust-clippy/blob/c082bc2cb85313901ed3565fcd285592ed93df0f/book/src/lint_configuration.md) and `util/gh-pages/lints.json`

- `CHANGELOG.md` and `lint_configuration.md` are now checked by `tests/config-metadata.rs`, when they are outdated `cargo test` will fail with a message to run `cargo bless --test config-metadata` in order to update them

   A plain `cargo bless` will run all the tests, blessing both this and the UI tests

- `util/gh-pages/lints.json` is now generated when running `cargo uitest` with `COLLECT_METADATA=1` (still aliased to `cargo collect-metadata`)

   It uses a `ui_test` [post test action](https://docs.rs/ui_test/latest/ui_test/custom_flags/trait.Flag.html#method.post_test_action) to retrieve the applicability from the actual diagnostics emitted during UI tests

   Example change from the current to new JSON:

   ```diff
      {
        "id": "chars_next_cmp",
   -    "id_span": {
   -      "path": "src/methods/mod.rs",
   -      "line": 891
   -    },
   +    "id_location": "clippy_lints/src/methods/mod.rs#891",
        "group": "style",
        "level": "warn",
   -    "docs": "\n### What it does ... ```",
   +    "docs": "### What it does ... ```\n",
        "version": "pre 1.29.0",
   -    "applicability": {
   -      "is_multi_part_suggestion": false,
   -      "applicability": "Unresolved"
   -    }
   +    "applicability": "MachineApplicable"
      },
   ```

   `Hide whitespace` makes the `compile-test.rs` changes much easier to see

r? `@flip1995`

changelog: none
@bors
Copy link
Collaborator

bors commented Aug 12, 2024

⌛ Trying commit a9057aa with merge 0853748...

@bors
Copy link
Collaborator

bors commented Aug 12, 2024

💔 Test failed - checks-action_test

@Alexendoo
Copy link
Member Author

-**Default Value:** `["j", "z", "i", "y", "n", "x", "w"]`
+**Default Value:** `["w", "n", "x", "i", "z", "y", "j"]`

Can't say that's what I expected, I'll take a better look at this later

@xFrednet
Copy link
Member

What o.O, that's weird.

The good news are that #13084 would fix it, but that PR is still WIP

@Alexendoo
Copy link
Member Author

@bors try

@bors
Copy link
Collaborator

bors commented Aug 12, 2024

⌛ Trying commit d6f0a28 with merge 236a77c...

bors added a commit that referenced this pull request Aug 12, 2024
Replace the metadata collector with tests

The metadata collector handles 3 files: [`CHANGELOG.md`](https://github.com/rust-lang/rust-clippy/blob/c082bc2cb85313901ed3565fcd285592ed93df0f/CHANGELOG.md#L6050), [`lint_configuration.md`](https://github.com/rust-lang/rust-clippy/blob/c082bc2cb85313901ed3565fcd285592ed93df0f/book/src/lint_configuration.md) and `util/gh-pages/lints.json`

- `CHANGELOG.md` and `lint_configuration.md` are now checked by `tests/config-metadata.rs`, when they are outdated `cargo test` will fail with a message to run `cargo bless --test config-metadata` in order to update them

   A plain `cargo bless` will run all the tests, blessing both this and the UI tests

- `util/gh-pages/lints.json` is now generated when running `cargo uitest` with `COLLECT_METADATA=1` (still aliased to `cargo collect-metadata`)

   It uses a `ui_test` [post test action](https://docs.rs/ui_test/latest/ui_test/custom_flags/trait.Flag.html#method.post_test_action) to retrieve the applicability from the actual diagnostics emitted during UI tests

   Example change from the current to new JSON:

   ```diff
      {
        "id": "chars_next_cmp",
   -    "id_span": {
   -      "path": "src/methods/mod.rs",
   -      "line": 891
   -    },
   +    "id_location": "clippy_lints/src/methods/mod.rs#891",
        "group": "style",
        "level": "warn",
   -    "docs": "\n### What it does ... ```",
   +    "docs": "### What it does ... ```\n",
        "version": "pre 1.29.0",
   -    "applicability": {
   -      "is_multi_part_suggestion": false,
   -      "applicability": "Unresolved"
   -    }
   +    "applicability": "MachineApplicable"
      },
   ```

   `Hide whitespace` makes the `compile-test.rs` changes much easier to see

r? `@flip1995`

changelog: none
@bors
Copy link
Collaborator

bors commented Aug 12, 2024

💔 Test failed - checks-action_test

@Alexendoo
Copy link
Member Author

oops

@bors try

bors added a commit that referenced this pull request Aug 12, 2024
Replace the metadata collector with tests

The metadata collector handles 3 files: [`CHANGELOG.md`](https://github.com/rust-lang/rust-clippy/blob/c082bc2cb85313901ed3565fcd285592ed93df0f/CHANGELOG.md#L6050), [`lint_configuration.md`](https://github.com/rust-lang/rust-clippy/blob/c082bc2cb85313901ed3565fcd285592ed93df0f/book/src/lint_configuration.md) and `util/gh-pages/lints.json`

- `CHANGELOG.md` and `lint_configuration.md` are now checked by `tests/config-metadata.rs`, when they are outdated `cargo test` will fail with a message to run `cargo bless --test config-metadata` in order to update them

   A plain `cargo bless` will run all the tests, blessing both this and the UI tests

- `util/gh-pages/lints.json` is now generated when running `cargo uitest` with `COLLECT_METADATA=1` (still aliased to `cargo collect-metadata`)

   It uses a `ui_test` [post test action](https://docs.rs/ui_test/latest/ui_test/custom_flags/trait.Flag.html#method.post_test_action) to retrieve the applicability from the actual diagnostics emitted during UI tests

   Example change from the current to new JSON:

   ```diff
      {
        "id": "chars_next_cmp",
   -    "id_span": {
   -      "path": "src/methods/mod.rs",
   -      "line": 891
   -    },
   +    "id_location": "clippy_lints/src/methods/mod.rs#891",
        "group": "style",
        "level": "warn",
   -    "docs": "\n### What it does ... ```",
   +    "docs": "### What it does ... ```\n",
        "version": "pre 1.29.0",
   -    "applicability": {
   -      "is_multi_part_suggestion": false,
   -      "applicability": "Unresolved"
   -    }
   +    "applicability": "MachineApplicable"
      },
   ```

   `Hide whitespace` makes the `compile-test.rs` changes much easier to see

r? `@flip1995`

changelog: none
@bors
Copy link
Collaborator

bors commented Aug 12, 2024

⌛ Trying commit c563b9d with merge 13cc5bd...

@bors
Copy link
Collaborator

bors commented Aug 12, 2024

☀️ Try build successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Build commit: 13cc5bd (13cc5bd862dc9c484cd772726a5d50a1bbe7cc91)

@Alexendoo
Copy link
Member Author

We used FxHashSet in Conf a few times, I'm guessing the order changed because usize hashes differently on 32-bit. I'll leave an actual fix to #13084 but as a temporary measure I replaced them with Vecs

Copy link
Member

@xFrednet xFrednet left a comment

Choose a reason for hiding this comment

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

LGTM! Could you copy the changes from #13261 to correct the indention and include compile_fail for code blocks?

@xFrednet
Copy link
Member

Everything looks good to me, I only now noticed the branch name ^^


Death of a monster

Roses are red,
Violets are blue,
The collector,
is now anew.

Farewell my friend,
ḿy biggest lint,
who started this journey,
we're all in.

RIP
*2021-05-05
†2024-08-13

@bors
Copy link
Collaborator

bors commented Aug 13, 2024

📌 Commit a22ce2d has been approved by xFrednet

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Aug 13, 2024

⌛ Testing commit a22ce2d with merge 61a252f...

@bors
Copy link
Collaborator

bors commented Aug 13, 2024

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: xFrednet
Pushing 61a252f to master...

@bors bors merged commit 61a252f into rust-lang:master Aug 13, 2024
11 checks passed
@Alexendoo Alexendoo deleted the farewell-metadata-collector branch August 13, 2024 12:00
bors added a commit that referenced this pull request Sep 21, 2024
Remove unused `collect_metadata` function

Leftover from #13221

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants