Jakub Žádník
2022-12-22 00:33:26 +02:00
committed by GitHub
parent 440feaf74a
commit 757d7479af
13 changed files with 379 additions and 151 deletions

View File

@ -1,4 +1,4 @@
use crate::tests::{fail_test, run_test_contains, TestResult};
use crate::tests::{fail_test, run_test, run_test_contains, TestResult};
// cargo version prints a string of the form:
// cargo 1.60.0 (d1fd9fe2c 2022-03-01)
@ -10,10 +10,7 @@ fn known_external_runs() -> TestResult {
#[test]
fn known_external_unknown_flag() -> TestResult {
fail_test(
r#"extern "cargo version" []; cargo version --no-such-flag"#,
"command doesn't have flag",
)
run_test_contains(r#"extern "cargo" []; cargo --version"#, "cargo")
}
/// GitHub issues #5179, #4618
@ -33,3 +30,49 @@ fn known_external_subcommand_alias() -> TestResult {
"cargo",
)
}
#[test]
fn known_external_complex_unknown_args() -> TestResult {
run_test_contains(
"extern echo []; echo foo -b -as -9 --abc -- -Dxmy=AKOO - bar",
"foo -b -as -9 --abc -- -Dxmy=AKOO - bar",
)
}
#[test]
fn known_external_batched_short_flag_arg_disallowed() -> TestResult {
fail_test(
"extern echo [-a, -b: int]; echo -ab 10",
"short flag batches",
)
}
#[test]
fn known_external_missing_positional() -> TestResult {
fail_test("extern echo [a]; echo", "missing_positional")
}
#[test]
fn known_external_type_mismatch() -> TestResult {
fail_test("extern echo [a: int]; echo 1.234", "mismatch")
}
#[test]
fn known_external_missing_flag_param() -> TestResult {
fail_test(
"extern echo [--foo: string]; echo --foo",
"missing_flag_param",
)
}
#[test]
fn known_external_misc_values() -> TestResult {
run_test(
r#"
let x = 'abc'
extern echo []
echo $x [ a b c ]
"#,
"abc a b c",
)
}