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

test: migrate help to snapbox #14060

Merged
merged 7 commits into from
Jun 15, 2024

Conversation

choznerol
Copy link
Contributor

@choznerol choznerol commented Jun 13, 2024

What does this PR try to resolve?

Part of #14039.

Migrate tests/testsuite/help.rs to snapbox.

How should we test and review this PR?

I followed #14039. The #![allow(deprecated)] was removed and tests/testsuite/help.rs is still passing.

Additional information

I accidentally noticed that L155 would always pass despite the .with_stderr_data("whatever I write here"), either before or after this PR. It's probably related to run_expect_error(). Will investigate and open an issue. 👉 Filed #14076

@rustbot
Copy link
Collaborator

rustbot commented Jun 13, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @weihanglo (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 13, 2024
cargo_process("search --help")
.with_stdout_contains("[..] --frozen [..]")
.with_stdout_data(
Copy link
Member

Choose a reason for hiding this comment

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

You could use str![] and regenerate snapshots by running this command SNAPSHOTS=overwrite cargo t --test testsuite help::

Suggested change
.with_stdout_data(
.with_stdout_data(str![])

This comment was marked as outdated.

This comment was marked as outdated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Just get SNAPSHOTS=overwrite working and pushed 8db30bc.

choznerol added a commit to choznerol/cargo that referenced this pull request Jun 13, 2024
The `with_stderr_contains()` (as well as the new `with_stderr_data()` too, see rust-lang#14060) has no effect when using with `run_expect_error()`.
Comment on lines 17 to 20
// Ensure that help output goes to stdout, not stderr.
cargo_process("search --help").with_stderr("").run();
cargo_process("search --help").with_stderr_data("").run();
cargo_process("search --help")
.with_stdout_contains("[..] --frozen [..]")
.with_stdout_data(
Copy link
Contributor

Choose a reason for hiding this comment

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

We can probably delete this test because we have help UI tests for every command, like

https://github.com/rust-lang/cargo/blob/master/tests/testsuite/cargo_search/help/mod.rs

Copy link
Contributor Author

@choznerol choznerol Jun 15, 2024

Choose a reason for hiding this comment

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

Thanks. Removed the search --help cases in eef057e.

P.s. I left L11-16 untouched, as the exact command are slightly different from the existing UI tests.

@@ -147,7 +151,7 @@ fn help_alias() {
// The `empty-alias` returns an error.
cargo_process("help empty-alias")
.env("PATH", Path::new(""))
.with_stderr_contains("[..]The subcommand 'empty-alias' wasn't recognized[..]")
.with_stderr_data("[..] The subcommand 'empty-alias' wasn't recognized [..]")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we drop the [..]s? We are trying to move away from them where it makes sense because they get in the way of snapshot updating

Copy link
Contributor Author

@choznerol choznerol Jun 15, 2024

Choose a reason for hiding this comment

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

Removed in e5e9f2f, but in fact there is another issue #14076 with this test case. I mentioned that as well in the same commit.

Fixed in 8db30bc

Comment on lines 166 to 176
fn alias_z_flag_help() {
for cmd in ["build", "run", "check", "test", "b", "r", "c", "t"] {
cargo_process(&format!("{cmd} -Z help"))
.with_stdout_contains(
" -Z allow-features[..] Allow *only* the listed unstable features",
.with_stdout_data(
"\
...
-Z allow-features[..] Allow *only* the listed unstable features
...
",
)
.run();
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Removed in 3fd3879.

@choznerol choznerol marked this pull request as ready for review June 15, 2024 07:49
Comment on lines 143 to 148
.with_stderr_data("The subcommand 'empty-alias' wasn't recognized

FIXME: #14076 This assertion isn't working, as this line should have caused a test failure but didn't.
",
)
.run_expect_error();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.with_stderr_data("The subcommand 'empty-alias' wasn't recognized
FIXME: #14076 This assertion isn't working, as this line should have caused a test failure but didn't.
",
)
.run_expect_error();
.with_status(101)
.with_stderr_data(str![[r#"
[ERROR] no such command: `empty-alias`
Did you mean `empty-alias`?
View all installed commands with `cargo --list`
Find a package to install `empty-alias` with `cargo search cargo-empty-alias`
"#]])
.run();

Something like this should work. See #14076 (comment).

(just realized that the error message regressed…)

Copy link
Member

Choose a reason for hiding this comment

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

Would you mind posting another PR fixing #14076 and then update this afterward?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Just get SNAPSHOTS=overwrite working and pushed 8db30bc.

Would you mind posting another PR fixing #14076 and then update this afterward?

Sure! Will address #14076 first with #14078, and then resolve the conflict here.

choznerol added a commit to choznerol/cargo that referenced this pull request Jun 15, 2024
The `with_stderr_contains()` (as well as the new `with_stderr_data()` too, see rust-lang#14060) has no effect when using with `run_expect_error()`.
choznerol added a commit to choznerol/cargo that referenced this pull request Jun 15, 2024
choznerol added a commit to choznerol/cargo that referenced this pull request Jun 15, 2024
choznerol added a commit to choznerol/cargo that referenced this pull request Jun 15, 2024
choznerol added a commit to choznerol/cargo that referenced this pull request Jun 15, 2024
The `with_stderr_contains()` (as well as the new `with_stderr_data()` too, see rust-lang#14060) has no effect when using with `run_expect_error()`.
@choznerol
Copy link
Contributor Author

@rustbot review

@weihanglo
Copy link
Member

Thanks!

@bors r+

@bors
Copy link
Collaborator

bors commented Jun 15, 2024

📌 Commit 8db30bc has been approved by weihanglo

It is now in the queue for this repository.

@bors bors removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 15, 2024
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jun 15, 2024
@bors
Copy link
Collaborator

bors commented Jun 15, 2024

⌛ Testing commit 8db30bc with merge ea16f96...

@bors
Copy link
Collaborator

bors commented Jun 15, 2024

☀️ Test successful - checks-actions
Approved by: weihanglo
Pushing ea16f96 to master...

@bors bors merged commit ea16f96 into rust-lang:master Jun 15, 2024
22 checks passed
choznerol added a commit to choznerol/cargo that referenced this pull request Jun 16, 2024
The `with_stderr_contains()` (as well as the new `with_stderr_data()` too, see rust-lang#14060) has no effect when using with `run_expect_error()`.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 19, 2024
Update cargo

13 commits in a1f47ec3f7cd076986f1bfcd7061f2e8cb1a726e..3ed207e416fb2f678a40cc79c02dcf4f936a21ce
2024-06-15 01:10:07 +0000 to 2024-06-18 19:18:22 +0000
- test: prefer raw string for regex reduction (rust-lang/cargo#14099)
- test: migrate tree and tree_graph_features to snapbox (rust-lang/cargo#14094)
- test: Migrate some files to snapbox (rust-lang/cargo#14069)
- remove some legacy public dependency code from the resolver (rust-lang/cargo#14090)
- fix(fix): Address problems with implicit -> explicit feature migration (rust-lang/cargo#14018)
- refactor: 1.79 cleanup (rust-lang/cargo#14088)
- test: migrate `git_(gc|shallow)` to snapbox (rust-lang/cargo#14087)
- test: migrate timings_works to snapbox (rust-lang/cargo#14082)
- test: migrate minimal_versions to snapbox (rust-lang/cargo#14080)
- Remove `run_expect_error` to avoid tests incorrectly passing (rust-lang/cargo#14078)
- test: migrate help to snapbox (rust-lang/cargo#14060)
- test: Migrate tests/testsuite/co*.rs to snapbox (rust-lang/cargo#14079)
- Use `std::fs::absolute` instead of reimplementing it (rust-lang/cargo#14075)

<!--
r? ghost
-->
@rustbot rustbot added this to the 1.81.0 milestone Jun 19, 2024
@choznerol choznerol changed the title test: migrate help to snapbox test: migrate help to snapbox Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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