1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -05:00

feat(test): rename --allow-none to --permit-no-files (#24809)

This commit is contained in:
Luca Casonato 2024-08-02 15:18:59 +02:00 committed by GitHub
parent 124a13280e
commit 84ff418265
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 49 additions and 2 deletions

View file

@ -2683,10 +2683,19 @@ Directory arguments are expanded to all contained files matching the glob
.value_name("N")
.value_parser(value_parser!(NonZeroUsize)),
)
// TODO(@lucacasonato): remove for Deno 2.0
.arg(
Arg::new("allow-none")
.long("allow-none")
.help("Don't return error code if no test files are found")
.hide(true)
.action(ArgAction::SetTrue),
)
.arg(
Arg::new("permit-no-files")
.long("permit-no-files")
.help("Don't return an error code if no test files were found")
.conflicts_with("allow-none")
.action(ArgAction::SetTrue),
)
.arg(
@ -4437,7 +4446,17 @@ fn test_parse(flags: &mut Flags, matches: &mut ArgMatches) {
);
}
let doc = matches.get_flag("doc");
let allow_none = matches.get_flag("allow-none");
#[allow(clippy::print_stderr)]
let allow_none = matches.get_flag("permit-no-files")
|| if matches.get_flag("allow-none") {
eprintln!(
"⚠️ {}",
crate::colors::yellow("The `--allow-none` flag is deprecated and will be removed in Deno 2.0.\nUse the `--permit-no-files` flag instead."),
);
true
} else {
false
};
let filter = matches.remove_one::<String>("filter");
let clean = matches.get_flag("clean");
@ -8398,7 +8417,7 @@ mod tests {
#[test]
fn test_with_flags() {
#[rustfmt::skip]
let r = flags_from_vec(svec!["deno", "test", "--unstable", "--no-npm", "--no-remote", "--trace-leaks", "--no-run", "--filter", "- foo", "--coverage=cov", "--clean", "--location", "https:foo", "--allow-net", "--allow-none", "dir1/", "dir2/", "--", "arg1", "arg2"]);
let r = flags_from_vec(svec!["deno", "test", "--unstable", "--no-npm", "--no-remote", "--trace-leaks", "--no-run", "--filter", "- foo", "--coverage=cov", "--clean", "--location", "https:foo", "--allow-net", "--permit-no-files", "dir1/", "dir2/", "--", "arg1", "arg2"]);
assert_eq!(
r.unwrap(),
Flags {

View file

@ -0,0 +1,19 @@
{
"tests": {
"error": {
"args": "test",
"output": "error.out",
"exitCode": 1
},
"permit_no_files": {
"args": "test --permit-no-files",
"output": "permit_no_files.out",
"exitCode": 0
},
"allow_none": {
"args": "test --allow-none",
"output": "allow_none.out",
"exitCode": 0
}
}
}

View file

@ -0,0 +1,5 @@
⚠️ The `--allow-none` flag is deprecated and will be removed in Deno 2.0.
Use the `--permit-no-files` flag instead.
ok | 0 passed | 0 failed (0ms)

View file

@ -0,0 +1 @@
error: No test modules found

View file

@ -0,0 +1,3 @@
ok | 0 passed | 0 failed (0ms)