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

Rustdoc json tests: New @ismany test command #99474

Merged

Conversation

aDotInTheVoid
Copy link
Member

Alot of the time, we wanted to assert that a module had an exact set of items. Most of the time this was done by asserting that the @count of the module was n, and then doing n @has checks on the module.

This was tedious, so often shortcuts were done.

This PR adds a new command to jsondocck to allow consistently expressing this behavior, and then uses it to clean up the tests.

@rustbot modify labels: +A-rustdoc-json +A-testsuite

@rustbot rustbot added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jul 19, 2022
@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

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

@rustbot rustbot added A-rustdoc-json Area: Rustdoc JSON backend A-testsuite Area: The testsuite used to check the correctness of rustc labels Jul 19, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 19, 2022
@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@Enselic Enselic left a comment

Choose a reason for hiding this comment

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

I skimmed it over and it looks like a nice simplification/improvement. I left some comments. Mostly nit-picks I'm afraid (as in: I probably should not have bothered to comment at all)

@@ -4,15 +4,20 @@
#![feature(no_core)]

// @is glob_extern.json "$.index[*][?(@.name=='mod1')].kind" \"module\"
// @is glob_extern.json "$.index[*][?(@.name=='mod1')].inner.is_stripped" "true"
// @is - "$.index[*][?(@.name=='mod1')].inner.is_stripped" "true"
Copy link
Member

@Enselic Enselic Jul 19, 2022

Choose a reason for hiding this comment

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

Sorry to nit-pick, but I wonder: Is it worth to use - instead of the whole filename? That messes up the alignment and makes the code harder to read, IMHO.

Edit: Well, if all other lines use - then the alignment becomes good for them at least...

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, most of the tests use - for all but the first item. (Side note, I should add a feature to set the - to the obvious value initialy, because I don't think this is ever used, but just a hold over from the HTML side)

src/tools/jsondocck/src/main.rs Outdated Show resolved Hide resolved
@@ -50,13 +50,15 @@ pub enum CommandKind {
Has,
Count,
Is,
HasExact,
Copy link
Member

Choose a reason for hiding this comment

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

Bikeshedding: Maybe call it "HasOnly"? That makes more semantic sense to me, but not sure it makes more sense to others.

src/tools/jsondocck/src/main.rs Outdated Show resolved Hide resolved
src/tools/jsondocck/src/main.rs Outdated Show resolved Hide resolved
src/test/rustdoc-json/reexport/auxiliary/pub-struct.rs Outdated Show resolved Hide resolved
src/test/rustdoc-json/reexport/glob_private.rs Outdated Show resolved Hide resolved
src/test/rustdoc-json/reexport/simple_private.rs Outdated Show resolved Hide resolved
@aDotInTheVoid aDotInTheVoid force-pushed the rustdoc-json-noinline-test-cleanup branch from feff909 to 6d2104b Compare July 19, 2022 21:32
@rust-log-analyzer

This comment has been minimized.

@aDotInTheVoid aDotInTheVoid force-pushed the rustdoc-json-noinline-test-cleanup branch from 6d2104b to 09d080e Compare July 20, 2022 08:57

// Serde json doesn't implement Ord or Hash for Value, so we must
// use a Vec here. While in theory that makes setwize equality
// O(n^2), in practice n will never be large enought to matter.
Copy link
Member

Choose a reason for hiding this comment

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

I feel like a 'hasexact' would make me expect that it would check the order too, not just presence -- and that would avoid any question of n^2 comparison time. I agree that n^2 comparison time isn't itself an issue, though, so maybe this is fine as-is.

Copy link
Member Author

Choose a reason for hiding this comment

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

It needs to not check order, as that's not a property that's stable, so the intension is to a setwise comparison.

HasExact should definatly be renamed, as it's been confusing twice now.

@Mark-Simulacrum
Copy link
Member

r? rust-lang/rustdoc

@notriddle
Copy link
Contributor

r? @CraftSpider

@CraftSpider
Copy link
Contributor

Looked it over, and the code looks good to me, aside from the mention of HasExact being not a great name. Maybe something like ContainsExact or ItemsExact? Otherwise, r=me.

@camelid
Copy link
Member

camelid commented Aug 9, 2022

I suggested the name @hasmany on Zulip, which I think captures the meaning well.

@CraftSpider
Copy link
Contributor

I see today that it looks like ismany was the mentioned final choice - once that is in, I'll gladly approve this change.

@aDotInTheVoid aDotInTheVoid force-pushed the rustdoc-json-noinline-test-cleanup branch from 09d080e to 0e563c8 Compare August 12, 2022 17:11
@aDotInTheVoid aDotInTheVoid force-pushed the rustdoc-json-noinline-test-cleanup branch from 0e563c8 to 5b5c1fa Compare August 12, 2022 17:12
@aDotInTheVoid
Copy link
Member Author

Renamed to @ismany

@rustbot ready

@rust-log-analyzer

This comment has been minimized.

@aDotInTheVoid aDotInTheVoid force-pushed the rustdoc-json-noinline-test-cleanup branch from 5b5c1fa to 760b972 Compare August 12, 2022 22:56
@CraftSpider
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Aug 16, 2022

📌 Commit 760b972 has been approved by CraftSpider

It is now in the queue for this repository.

@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 Aug 16, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 17, 2022
…-test-cleanup, r=CraftSpider

Rustdoc json tests: New @hasexact test command

Alot of the time, we wanted to assert that a module had an exact set of items. Most of the time this was done by asserting that the ``@count`` of the module was `n`, and then doing `n` ``@has`` checks on the module.

This was tedious, so often shortcuts were done.

This PR adds a new command to jsondocck to allow consistently expressing this behavior, and then uses it to clean up the tests.

`@rustbot` modify labels: +A-rustdoc-json +A-testsuite
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 17, 2022
…iaskrgr

Rollup of 15 pull requests

Successful merges:

 - rust-lang#99474 (Rustdoc json tests: New `@hasexact` test command)
 - rust-lang#99972 (interpret: only consider 1-ZST when searching for receiver)
 - rust-lang#100018 (Clean up `LitKind`)
 - rust-lang#100379 (triagebot: add translation-related mention groups)
 - rust-lang#100389 (Do not report cycle error when inferring return type for suggestion)
 - rust-lang#100489 (`is_knowable` use `Result` instead of `Option`)
 - rust-lang#100532 (unwind: don't build dependency when building for Miri)
 - rust-lang#100608 (needless separation of impl blocks)
 - rust-lang#100621 (Pass +atomics-32 feature for {arm,thumb}v4t-none-eabi)
 - rust-lang#100646 (Migrate emoji identifier diagnostics to `SessionDiagnostic` in rustc_interface)
 - rust-lang#100652 (Remove deferred sized checks (make them eager))
 - rust-lang#100655 (Update books)
 - rust-lang#100656 (Update cargo)
 - rust-lang#100660 (Fixed a few documentation errors)
 - rust-lang#100661 (Fixed a few documentation errors)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@aDotInTheVoid aDotInTheVoid changed the title Rustdoc json tests: New @hasexact test command Rustdoc json tests: New @IsMany test command Aug 17, 2022
@aDotInTheVoid aDotInTheVoid changed the title Rustdoc json tests: New @IsMany test command Rustdoc json tests: New @ismany test command Aug 17, 2022
@bors bors merged commit 0491fda into rust-lang:master Aug 17, 2022
@rustbot rustbot added this to the 1.65.0 milestone Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-json Area: Rustdoc JSON backend A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants