diff options
-rw-r--r-- | cli/args/flags.rs | 13 | ||||
-rw-r--r-- | cli/args/mod.rs | 2 | ||||
-rw-r--r-- | cli/tests/integration/bench_tests.rs | 6 | ||||
-rw-r--r-- | cli/tests/testdata/bench/no_run.out | 5 | ||||
-rw-r--r-- | cli/tests/testdata/bench/no_run.ts | 2 | ||||
-rw-r--r-- | cli/tools/bench.rs | 8 |
6 files changed, 36 insertions, 0 deletions
diff --git a/cli/args/flags.rs b/cli/args/flags.rs index dd2a40913..7d124a6c1 100644 --- a/cli/args/flags.rs +++ b/cli/args/flags.rs @@ -60,6 +60,7 @@ pub struct BenchFlags { pub files: FileFlags, pub filter: Option<String>, pub json: bool, + pub no_run: bool, } #[derive(Clone, Debug, Eq, PartialEq)] @@ -804,6 +805,12 @@ fn bench_subcommand() -> Command { .value_parser(value_parser!(PathBuf)) .action(ArgAction::Append), ) + .arg( + Arg::new("no-run") + .long("no-run") + .help("Cache bench modules, but don't run benchmarks") + .action(ArgAction::SetTrue), + ) .arg(watch_arg(false)) .arg(no_clear_screen_arg()) .arg(script_arg().last(true)) @@ -2368,11 +2375,14 @@ fn bench_parse(flags: &mut Flags, matches: &mut ArgMatches) { Vec::new() }; + let no_run = matches.get_flag("no-run"); + watch_arg_parse(flags, matches, false); flags.subcommand = DenoSubcommand::Bench(BenchFlags { files: FileFlags { include, ignore }, filter, json, + no_run, }); } @@ -6482,6 +6492,7 @@ mod tests { "--unstable", "--no-npm", "--no-remote", + "--no-run", "--filter", "- foo", "--location", @@ -6499,6 +6510,7 @@ mod tests { subcommand: DenoSubcommand::Bench(BenchFlags { filter: Some("- foo".to_string()), json: true, + no_run: true, files: FileFlags { include: vec![PathBuf::from("dir1/"), PathBuf::from("dir2/")], ignore: vec![], @@ -6526,6 +6538,7 @@ mod tests { subcommand: DenoSubcommand::Bench(BenchFlags { filter: None, json: false, + no_run: false, files: FileFlags { include: vec![], ignore: vec![], diff --git a/cli/args/mod.rs b/cli/args/mod.rs index 338637455..bbf3f7efb 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -119,6 +119,7 @@ pub struct BenchOptions { pub files: FilesConfig, pub filter: Option<String>, pub json: bool, + pub no_run: bool, } impl BenchOptions { @@ -134,6 +135,7 @@ impl BenchOptions { ), filter: bench_flags.filter, json: bench_flags.json, + no_run: bench_flags.no_run, }) } } diff --git a/cli/tests/integration/bench_tests.rs b/cli/tests/integration/bench_tests.rs index e5174025e..16ac5852e 100644 --- a/cli/tests/integration/bench_tests.rs +++ b/cli/tests/integration/bench_tests.rs @@ -138,6 +138,12 @@ itest!(filter { output: "bench/filter.out", }); +itest!(no_run { + args: "bench --no-run bench/no_run.ts", + output: "bench/no_run.out", + exit_code: 1, +}); + itest!(no_prompt_by_default { args: "bench --quiet bench/no_prompt_by_default.ts", exit_code: 1, diff --git a/cli/tests/testdata/bench/no_run.out b/cli/tests/testdata/bench/no_run.out new file mode 100644 index 000000000..5d40f1d3b --- /dev/null +++ b/cli/tests/testdata/bench/no_run.out @@ -0,0 +1,5 @@ +Check [WILDCARD]/bench/no_run.ts +error: TS2322 [ERROR]: Type 'number' is not assignable to type 'string'. +const _value: string = 1; + ~~~~~~ + at [WILDCARD]/bench/no_run.ts:1:7 diff --git a/cli/tests/testdata/bench/no_run.ts b/cli/tests/testdata/bench/no_run.ts new file mode 100644 index 000000000..c7a5dc1e8 --- /dev/null +++ b/cli/tests/testdata/bench/no_run.ts @@ -0,0 +1,2 @@ +const _value: string = 1; +console.log("this should not be run"); diff --git a/cli/tools/bench.rs b/cli/tools/bench.rs index 56ddb99fb..ebfa8f4d2 100644 --- a/cli/tools/bench.rs +++ b/cli/tools/bench.rs @@ -590,6 +590,10 @@ pub async fn run_benchmarks( check_specifiers(&ps, permissions.clone(), specifiers.clone()).await?; + if bench_options.no_run { + return Ok(()); + } + bench_specifiers( &ps, &permissions, @@ -742,6 +746,10 @@ pub async fn run_benchmarks_with_watch( check_specifiers(&ps, permissions.clone(), specifiers.clone()).await?; + if bench_options.no_run { + return Ok(()); + } + bench_specifiers( &ps, permissions, |