summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/args/flags.rs23
-rw-r--r--tests/specs/test/no_files/__test__.jsonc19
-rw-r--r--tests/specs/test/no_files/allow_none.out5
-rw-r--r--tests/specs/test/no_files/error.out1
-rw-r--r--tests/specs/test/no_files/permit_no_files.out3
5 files changed, 49 insertions, 2 deletions
diff --git a/cli/args/flags.rs b/cli/args/flags.rs
index 75987e9d0..e8e363d79 100644
--- a/cli/args/flags.rs
+++ b/cli/args/flags.rs
@@ -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 {
diff --git a/tests/specs/test/no_files/__test__.jsonc b/tests/specs/test/no_files/__test__.jsonc
new file mode 100644
index 000000000..0bb252ec7
--- /dev/null
+++ b/tests/specs/test/no_files/__test__.jsonc
@@ -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
+ }
+ }
+}
diff --git a/tests/specs/test/no_files/allow_none.out b/tests/specs/test/no_files/allow_none.out
new file mode 100644
index 000000000..1cc973bb5
--- /dev/null
+++ b/tests/specs/test/no_files/allow_none.out
@@ -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)
+
diff --git a/tests/specs/test/no_files/error.out b/tests/specs/test/no_files/error.out
new file mode 100644
index 000000000..2878f641a
--- /dev/null
+++ b/tests/specs/test/no_files/error.out
@@ -0,0 +1 @@
+error: No test modules found
diff --git a/tests/specs/test/no_files/permit_no_files.out b/tests/specs/test/no_files/permit_no_files.out
new file mode 100644
index 000000000..228425d10
--- /dev/null
+++ b/tests/specs/test/no_files/permit_no_files.out
@@ -0,0 +1,3 @@
+
+ok | 0 passed | 0 failed (0ms)
+