Simplify known external tests (#5219)

* Simplify known external tests

* Cargo fmt
This commit is contained in:
Hristo Filaretov 2022-04-17 21:31:03 +02:00 committed by GitHub
parent c9f05f074a
commit cf65f77b02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 18 deletions

View File

@ -1,6 +0,0 @@
/// This function is only meant to be used as part of the test suite
/// as a simple, cross-platform executable with known output.
fn main() {
println!("test-hello");
}

View File

@ -1,17 +1,17 @@
use crate::tests::{fail_test, run_test, TestResult}; use crate::tests::{fail_test, run_test_contains, TestResult};
// cargo version prints a string of the form:
// cargo 1.60.0 (d1fd9fe2c 2022-03-01)
#[test] #[test]
fn known_external_runs() -> TestResult { fn known_external_runs() -> TestResult {
run_test( run_test_contains(r#"extern "cargo version" []; cargo version"#, "cargo")
r#"extern "cargo run" [-q, --example: string, ...args]; cargo run -q --example test_hello"#,
"test-hello",
)
} }
#[test] #[test]
fn known_external_unknown_flag() -> TestResult { fn known_external_unknown_flag() -> TestResult {
fail_test( fail_test(
r#"extern "cargo run" [-q, --example: string, ...args]; cargo run -d"#, r#"extern "cargo version" []; cargo version --no-such-flag"#,
"command doesn't have flag", "command doesn't have flag",
) )
} }
@ -19,17 +19,17 @@ fn known_external_unknown_flag() -> TestResult {
/// GitHub issues #5179, #4618 /// GitHub issues #5179, #4618
#[test] #[test]
fn known_external_alias() -> TestResult { fn known_external_alias() -> TestResult {
run_test( run_test_contains(
r#"extern "cargo run" [-q, --example: string, ...args]; alias cr = cargo run; cr -q --example test_hello"#, r#"extern "cargo version" []; alias cv = cargo version; cv"#,
"test-hello", "cargo",
) )
} }
/// GitHub issues #5179, #4618 /// GitHub issues #5179, #4618
#[test] #[test]
fn known_external_subcommand_alias() -> TestResult { fn known_external_subcommand_alias() -> TestResult {
run_test( run_test_contains(
r#"extern "cargo run" [-q, --example: string, ...args]; alias c = cargo; c run -q --example test_hello"#, r#"extern "cargo version" []; alias c = cargo; c version"#,
"test-hello", "cargo",
) )
} }