-
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
Changes from 1 commit
7c28d80
715cba9
3a95c78
3fd3879
eef057e
e5e9f2f
8db30bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
//! Tests for cargo's help output. | ||
|
||
#![allow(deprecated)] | ||
|
||
use cargo_test_support::registry::Package; | ||
use cargo_test_support::{basic_manifest, cargo_exe, cargo_process, paths, process, project}; | ||
use std::fs; | ||
|
@@ -17,9 +15,15 @@ fn help() { | |
cargo_process("build -h").run(); | ||
cargo_process("help help").run(); | ||
// 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. Removed the P.s. I left L11-16 untouched, as the exact command are slightly different from the existing UI tests. |
||
"\ | ||
... | ||
[..] --frozen [..] | ||
... | ||
", | ||
) | ||
.run(); | ||
} | ||
|
||
|
@@ -41,7 +45,7 @@ fn help_external_subcommand() { | |
.publish(); | ||
cargo_process("install cargo-fake-help").run(); | ||
cargo_process("help fake-help") | ||
.with_stdout("fancy help output\n") | ||
.with_stdout_data("fancy help output\n") | ||
.run(); | ||
} | ||
|
||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Should we drop the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
.run_expect_error(); | ||
|
||
// Because `simple-alias` aliases a subcommand with no arguments, help shows the manpage. | ||
|
@@ -162,8 +166,12 @@ fn help_alias() { | |
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. Removed in 3fd3879. |
||
} | ||
|
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 commandSNAPSHOTS=overwrite cargo t --test testsuite help::
This comment was marked as outdated.
Sorry, something went wrong.
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.