-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
test: migrate help
to snapbox
#14060
Conversation
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 (
|
tests/testsuite/help.rs
Outdated
cargo_process("search --help") | ||
.with_stdout_contains("[..] --frozen [..]") | ||
.with_stdout_data( |
There was a problem hiding this comment.
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::
.with_stdout_data( | |
.with_stdout_data(str![]) |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
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.
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()`.
tests/testsuite/help.rs
Outdated
// 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( |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
tests/testsuite/help.rs
Outdated
@@ -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 [..]") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests/testsuite/help.rs
Outdated
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also might be able to remove this as well
https://github.com/rust-lang/cargo/blob/master/tests/testsuite/cargo/z_help/stdout.term.svg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Removed in 3fd3879.
…p::` # Conflicts: # tests/testsuite/help.rs
…uite help::`" This reverts commit cbaa4a89e60507366401ac0076d652f5eafc4998.
# Conflicts: # tests/testsuite/help.rs
tests/testsuite/help.rs
Outdated
.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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.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…)
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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()`.
This reverts commit 18f4c3f.
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()`.
@rustbot review |
Thanks! @bors r+ |
☀️ Test successful - checks-actions |
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()`.
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 -->
help
to snapbox
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 andtests/testsuite/help.rs
is still passing.Additional information
I accidentally noticed that L155 would always pass despite the👉 Filed #14076.with_stderr_data("whatever I write here")
, either before or after this PR. It's probably related torun_expect_error()
. Will investigate and open an issue.