mirror of
https://github.com/denoland/deno.git
synced 2024-11-29 16:30:56 -05:00
fix(test): use --no-prompt by default (#13777)
This commit changes "deno test" subcommand, to always never prompt for permissions (ie. as if "deno test" was run with "--no-prompt" flag).
This commit is contained in:
parent
4a20435d3c
commit
4bea1d06c7
6 changed files with 42 additions and 0 deletions
10
cli/flags.rs
10
cli/flags.rs
|
@ -2199,6 +2199,9 @@ fn run_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
|
||||||
|
|
||||||
fn test_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
|
fn test_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
|
||||||
runtime_args_parse(flags, matches, true, true);
|
runtime_args_parse(flags, matches, true, true);
|
||||||
|
// NOTE: `deno test` always uses `--no-prompt`, tests shouldn't ever do
|
||||||
|
// interactive prompts, unless done by user code
|
||||||
|
flags.no_prompt = true;
|
||||||
|
|
||||||
let ignore = match matches.values_of("ignore") {
|
let ignore = match matches.values_of("ignore") {
|
||||||
Some(f) => f.map(PathBuf::from).collect(),
|
Some(f) => f.map(PathBuf::from).collect(),
|
||||||
|
@ -4453,6 +4456,7 @@ mod tests {
|
||||||
trace_ops: true,
|
trace_ops: true,
|
||||||
}),
|
}),
|
||||||
unstable: true,
|
unstable: true,
|
||||||
|
no_prompt: true,
|
||||||
coverage_dir: Some("cov".to_string()),
|
coverage_dir: Some("cov".to_string()),
|
||||||
location: Some(Url::parse("https://foo/").unwrap()),
|
location: Some(Url::parse("https://foo/").unwrap()),
|
||||||
allow_net: Some(vec![]),
|
allow_net: Some(vec![]),
|
||||||
|
@ -4521,6 +4525,7 @@ mod tests {
|
||||||
concurrent_jobs: NonZeroUsize::new(4).unwrap(),
|
concurrent_jobs: NonZeroUsize::new(4).unwrap(),
|
||||||
trace_ops: false,
|
trace_ops: false,
|
||||||
}),
|
}),
|
||||||
|
no_prompt: true,
|
||||||
..Flags::default()
|
..Flags::default()
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -4547,6 +4552,7 @@ mod tests {
|
||||||
concurrent_jobs: NonZeroUsize::new(1).unwrap(),
|
concurrent_jobs: NonZeroUsize::new(1).unwrap(),
|
||||||
trace_ops: false,
|
trace_ops: false,
|
||||||
}),
|
}),
|
||||||
|
no_prompt: true,
|
||||||
..Flags::default()
|
..Flags::default()
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -4577,6 +4583,7 @@ mod tests {
|
||||||
concurrent_jobs: NonZeroUsize::new(1).unwrap(),
|
concurrent_jobs: NonZeroUsize::new(1).unwrap(),
|
||||||
trace_ops: false,
|
trace_ops: false,
|
||||||
}),
|
}),
|
||||||
|
no_prompt: true,
|
||||||
enable_testing_features: true,
|
enable_testing_features: true,
|
||||||
..Flags::default()
|
..Flags::default()
|
||||||
}
|
}
|
||||||
|
@ -4601,6 +4608,7 @@ mod tests {
|
||||||
concurrent_jobs: NonZeroUsize::new(1).unwrap(),
|
concurrent_jobs: NonZeroUsize::new(1).unwrap(),
|
||||||
trace_ops: false,
|
trace_ops: false,
|
||||||
}),
|
}),
|
||||||
|
no_prompt: true,
|
||||||
watch: None,
|
watch: None,
|
||||||
..Flags::default()
|
..Flags::default()
|
||||||
}
|
}
|
||||||
|
@ -4625,6 +4633,7 @@ mod tests {
|
||||||
concurrent_jobs: NonZeroUsize::new(1).unwrap(),
|
concurrent_jobs: NonZeroUsize::new(1).unwrap(),
|
||||||
trace_ops: false,
|
trace_ops: false,
|
||||||
}),
|
}),
|
||||||
|
no_prompt: true,
|
||||||
watch: Some(vec![]),
|
watch: Some(vec![]),
|
||||||
..Flags::default()
|
..Flags::default()
|
||||||
}
|
}
|
||||||
|
@ -4652,6 +4661,7 @@ mod tests {
|
||||||
}),
|
}),
|
||||||
watch: Some(vec![]),
|
watch: Some(vec![]),
|
||||||
no_clear_screen: true,
|
no_clear_screen: true,
|
||||||
|
no_prompt: true,
|
||||||
..Flags::default()
|
..Flags::default()
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -262,3 +262,15 @@ itest!(steps_invalid_usage {
|
||||||
exit_code: 1,
|
exit_code: 1,
|
||||||
output: "test/steps/invalid_usage.out",
|
output: "test/steps/invalid_usage.out",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
itest!(no_prompt_by_default {
|
||||||
|
args: "test test/no_prompt_by_default.ts",
|
||||||
|
exit_code: 1,
|
||||||
|
output: "test/no_prompt_by_default.out",
|
||||||
|
});
|
||||||
|
|
||||||
|
itest!(no_prompt_with_denied_perms {
|
||||||
|
args: "test --allow-read test/no_prompt_with_denied_perms.ts",
|
||||||
|
exit_code: 1,
|
||||||
|
output: "test/no_prompt_with_denied_perms.out",
|
||||||
|
});
|
||||||
|
|
7
cli/tests/testdata/test/no_prompt_by_default.out
vendored
Normal file
7
cli/tests/testdata/test/no_prompt_by_default.out
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
Check [WILDCARD]/no_prompt_by_default.ts
|
||||||
|
running 1 test from [WILDCARD]/no_prompt_by_default.ts
|
||||||
|
test no prompt ...
|
||||||
|
test result: FAILED. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD])
|
||||||
|
|
||||||
|
error: Uncaught (in promise) PermissionDenied: Requires read access to "./some_file.txt", run again with the --allow-read flag
|
||||||
|
[WILDCARD]
|
3
cli/tests/testdata/test/no_prompt_by_default.ts
vendored
Normal file
3
cli/tests/testdata/test/no_prompt_by_default.ts
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
Deno.test("no prompt", () => {
|
||||||
|
Deno.readTextFile("./some_file.txt");
|
||||||
|
});
|
7
cli/tests/testdata/test/no_prompt_with_denied_perms.out
vendored
Normal file
7
cli/tests/testdata/test/no_prompt_with_denied_perms.out
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
Check [WILDCARD]/no_prompt_with_denied_perms.ts
|
||||||
|
running 1 test from [WILDCARD]/no_prompt_with_denied_perms.ts
|
||||||
|
test no prompt ...
|
||||||
|
test result: FAILED. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD])
|
||||||
|
|
||||||
|
error: Uncaught (in promise) PermissionDenied: Requires read access to "./some_file.txt", run again with the --allow-read flag
|
||||||
|
[WILDCARD]
|
3
cli/tests/testdata/test/no_prompt_with_denied_perms.ts
vendored
Normal file
3
cli/tests/testdata/test/no_prompt_with_denied_perms.ts
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
Deno.test("no prompt", { permissions: { read: false } }, () => {
|
||||||
|
Deno.readTextFile("./some_file.txt");
|
||||||
|
});
|
Loading…
Reference in a new issue