Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Merged
merged 5 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions cli/args/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2682,10 +2682,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(
Expand Down Expand Up @@ -4436,7 +4445,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");

Expand Down Expand Up @@ -8397,7 +8416,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 {
Expand Down
19 changes: 19 additions & 0 deletions tests/specs/test/no_files/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -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
}
}
}
5 changes: 5 additions & 0 deletions tests/specs/test/no_files/allow_none.out
Original file line number Diff line number Diff line change
@@ -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)

1 change: 1 addition & 0 deletions tests/specs/test/no_files/error.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
error: No test modules found
3 changes: 3 additions & 0 deletions tests/specs/test/no_files/permit_no_files.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

ok | 0 passed | 0 failed (0ms)