Skip to content

Commit

Permalink
BREAKING: remove --allow-none flag (#25337)
Browse files Browse the repository at this point in the history
Towards #22079

Signed-off-by: Luca Casonato <[email protected]>
Co-authored-by: Luca Casonato <[email protected]>
  • Loading branch information
iuioiua and lucacasonato authored Sep 2, 2024
1 parent e804175 commit f6eab6c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 41 deletions.
38 changes: 10 additions & 28 deletions cli/args/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ pub struct TestFlags {
pub clean: bool,
pub fail_fast: Option<NonZeroUsize>,
pub files: FileFlags,
pub allow_none: bool,
pub permit_no_files: bool,
pub filter: Option<String>,
pub shuffle: Option<u64>,
pub concurrent_jobs: Option<NonZeroUsize>,
Expand Down Expand Up @@ -2808,19 +2808,10 @@ Directory arguments are expanded to all contained files matching the glob
.value_name("N")
.value_parser(value_parser!(NonZeroUsize))
.help_heading(TEST_HEADING))
// 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)
.help_heading(TEST_HEADING),
)
Expand Down Expand Up @@ -4657,16 +4648,7 @@ fn test_parse(flags: &mut Flags, matches: &mut ArgMatches) {
let trace_leaks = matches.get_flag("trace-leaks");
let doc = matches.get_flag("doc");
#[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 permit_no_files = matches.get_flag("permit-no-files");
let filter = matches.remove_one::<String>("filter");
let clean = matches.get_flag("clean");

Expand Down Expand Up @@ -4732,7 +4714,7 @@ fn test_parse(flags: &mut Flags, matches: &mut ArgMatches) {
files: FileFlags { include, ignore },
filter,
shuffle,
allow_none,
permit_no_files,
concurrent_jobs,
trace_leaks,
watch: watch_arg_parse_with_paths(matches),
Expand Down Expand Up @@ -8484,7 +8466,7 @@ mod tests {
doc: false,
fail_fast: None,
filter: Some("- foo".to_string()),
allow_none: true,
permit_no_files: true,
files: FileFlags {
include: vec!["dir1/".to_string(), "dir2/".to_string()],
ignore: vec![],
Expand Down Expand Up @@ -8572,7 +8554,7 @@ mod tests {
doc: false,
fail_fast: Some(NonZeroUsize::new(3).unwrap()),
filter: None,
allow_none: false,
permit_no_files: false,
shuffle: None,
files: FileFlags {
include: vec![],
Expand Down Expand Up @@ -8615,7 +8597,7 @@ mod tests {
doc: false,
fail_fast: None,
filter: None,
allow_none: false,
permit_no_files: false,
shuffle: None,
files: FileFlags {
include: vec![],
Expand Down Expand Up @@ -8752,7 +8734,7 @@ mod tests {
doc: false,
fail_fast: None,
filter: None,
allow_none: false,
permit_no_files: false,
shuffle: Some(1),
files: FileFlags {
include: vec![],
Expand Down Expand Up @@ -8788,7 +8770,7 @@ mod tests {
doc: false,
fail_fast: None,
filter: None,
allow_none: false,
permit_no_files: false,
shuffle: None,
files: FileFlags {
include: vec![],
Expand Down Expand Up @@ -8823,7 +8805,7 @@ mod tests {
doc: false,
fail_fast: None,
filter: None,
allow_none: false,
permit_no_files: false,
shuffle: None,
files: FileFlags {
include: vec!["./".to_string()],
Expand Down Expand Up @@ -8860,7 +8842,7 @@ mod tests {
doc: false,
fail_fast: None,
filter: None,
allow_none: false,
permit_no_files: false,
shuffle: None,
files: FileFlags {
include: vec![],
Expand Down
4 changes: 2 additions & 2 deletions cli/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ pub struct WorkspaceTestOptions {
pub doc: bool,
pub no_run: bool,
pub fail_fast: Option<NonZeroUsize>,
pub allow_none: bool,
pub permit_no_files: bool,
pub filter: Option<String>,
pub shuffle: Option<u64>,
pub concurrent_jobs: NonZeroUsize,
Expand All @@ -382,7 +382,7 @@ pub struct WorkspaceTestOptions {
impl WorkspaceTestOptions {
pub fn resolve(test_flags: &TestFlags) -> Self {
Self {
allow_none: test_flags.allow_none,
permit_no_files: test_flags.permit_no_files,
concurrent_jobs: test_flags
.concurrent_jobs
.unwrap_or_else(|| NonZeroUsize::new(1).unwrap()),
Expand Down
3 changes: 2 additions & 1 deletion cli/tools/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1778,7 +1778,8 @@ pub async fn run_tests(
)
.await?;

if !workspace_test_options.allow_none && specifiers_with_mode.is_empty() {
if !workspace_test_options.permit_no_files && specifiers_with_mode.is_empty()
{
return Err(generic_error("No test modules found"));
}

Expand Down
5 changes: 0 additions & 5 deletions tests/specs/test/no_files/__test__.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
"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: 0 additions & 5 deletions tests/specs/test/no_files/allow_none.out

This file was deleted.

0 comments on commit f6eab6c

Please sign in to comment.