mirror of
https://github.com/rust-lang/cargo
synced 2024-10-13 19:22:33 +00:00
Create a dedicated module for help tests.
This commit is contained in:
parent
e9281208cd
commit
9138d65e4c
|
@ -338,35 +338,6 @@ fn cargo_subcommand_args() {
|
|||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn cargo_help() {
|
||||
cargo_process("").run();
|
||||
cargo_process("help").run();
|
||||
cargo_process("-h").run();
|
||||
cargo_process("help build").run();
|
||||
cargo_process("build -h").run();
|
||||
cargo_process("help help").run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn cargo_help_external_subcommand() {
|
||||
Package::new("cargo-fake-help", "1.0.0")
|
||||
.file(
|
||||
"src/main.rs",
|
||||
r#"
|
||||
fn main() {
|
||||
if ::std::env::args().nth(2) == Some(String::from("--help")) {
|
||||
println!("fancy help output");
|
||||
}
|
||||
}"#,
|
||||
)
|
||||
.publish();
|
||||
cargo_process("install cargo-fake-help").run();
|
||||
cargo_process("help fake-help")
|
||||
.with_stdout("fancy help output\n")
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn explain() {
|
||||
cargo_process("--explain E0001")
|
||||
|
@ -376,15 +347,6 @@ fn explain() {
|
|||
.run();
|
||||
}
|
||||
|
||||
// Test that the output of `cargo -Z help` shows a different help screen with
|
||||
// all the `-Z` flags.
|
||||
#[cargo_test]
|
||||
fn z_flags_help() {
|
||||
cargo_process("-Z help")
|
||||
.with_stdout_contains(" -Z unstable-options -- Allow the usage of unstable options")
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn closed_output_ok() {
|
||||
// Checks that closed output doesn't cause an error.
|
||||
|
|
49
tests/testsuite/help.rs
Normal file
49
tests/testsuite/help.rs
Normal file
|
@ -0,0 +1,49 @@
|
|||
//! Tests for cargo's help output.
|
||||
|
||||
use cargo_test_support::cargo_process;
|
||||
use cargo_test_support::registry::Package;
|
||||
|
||||
#[cargo_test]
|
||||
fn help() {
|
||||
cargo_process("").run();
|
||||
cargo_process("help").run();
|
||||
cargo_process("-h").run();
|
||||
cargo_process("help build").run();
|
||||
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_stdout_contains("[..] --frozen [..]")
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn help_external_subcommand() {
|
||||
// Check that `help external-subcommand` forwards the --help flag to the
|
||||
// given subcommand.
|
||||
Package::new("cargo-fake-help", "1.0.0")
|
||||
.file(
|
||||
"src/main.rs",
|
||||
r#"
|
||||
fn main() {
|
||||
if ::std::env::args().nth(2) == Some(String::from("--help")) {
|
||||
println!("fancy help output");
|
||||
}
|
||||
}"#,
|
||||
)
|
||||
.publish();
|
||||
cargo_process("install cargo-fake-help").run();
|
||||
cargo_process("help fake-help")
|
||||
.with_stdout("fancy help output\n")
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn z_flags_help() {
|
||||
// Test that the output of `cargo -Z help` shows a different help screen with
|
||||
// all the `-Z` flags.
|
||||
cargo_process("-Z help")
|
||||
.with_stdout_contains(" -Z unstable-options -- Allow the usage of unstable options")
|
||||
.run();
|
||||
}
|
|
@ -52,6 +52,7 @@ mod generate_lockfile;
|
|||
mod git;
|
||||
mod git_auth;
|
||||
mod git_gc;
|
||||
mod help;
|
||||
mod init;
|
||||
mod install;
|
||||
mod install_upgrade;
|
||||
|
|
|
@ -244,14 +244,3 @@ fn multiple_query_params() {
|
|||
.with_stdout_contains(SEARCH_RESULTS)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn help() {
|
||||
cargo_process("search -h").run();
|
||||
cargo_process("help search").run();
|
||||
// Ensure that help output goes to stdout, not stderr.
|
||||
cargo_process("search --help").with_stderr("").run();
|
||||
cargo_process("search --help")
|
||||
.with_stdout_contains("[..] --frozen [..]")
|
||||
.run();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue