mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
feat(bench): add --no-run
flag (#18433)
This commit is contained in:
parent
701099b2a9
commit
a29d88b43b
6 changed files with 36 additions and 0 deletions
|
@ -60,6 +60,7 @@ pub struct BenchFlags {
|
||||||
pub files: FileFlags,
|
pub files: FileFlags,
|
||||||
pub filter: Option<String>,
|
pub filter: Option<String>,
|
||||||
pub json: bool,
|
pub json: bool,
|
||||||
|
pub no_run: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
|
@ -804,6 +805,12 @@ fn bench_subcommand() -> Command {
|
||||||
.value_parser(value_parser!(PathBuf))
|
.value_parser(value_parser!(PathBuf))
|
||||||
.action(ArgAction::Append),
|
.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(watch_arg(false))
|
||||||
.arg(no_clear_screen_arg())
|
.arg(no_clear_screen_arg())
|
||||||
.arg(script_arg().last(true))
|
.arg(script_arg().last(true))
|
||||||
|
@ -2368,11 +2375,14 @@ fn bench_parse(flags: &mut Flags, matches: &mut ArgMatches) {
|
||||||
Vec::new()
|
Vec::new()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let no_run = matches.get_flag("no-run");
|
||||||
|
|
||||||
watch_arg_parse(flags, matches, false);
|
watch_arg_parse(flags, matches, false);
|
||||||
flags.subcommand = DenoSubcommand::Bench(BenchFlags {
|
flags.subcommand = DenoSubcommand::Bench(BenchFlags {
|
||||||
files: FileFlags { include, ignore },
|
files: FileFlags { include, ignore },
|
||||||
filter,
|
filter,
|
||||||
json,
|
json,
|
||||||
|
no_run,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6482,6 +6492,7 @@ mod tests {
|
||||||
"--unstable",
|
"--unstable",
|
||||||
"--no-npm",
|
"--no-npm",
|
||||||
"--no-remote",
|
"--no-remote",
|
||||||
|
"--no-run",
|
||||||
"--filter",
|
"--filter",
|
||||||
"- foo",
|
"- foo",
|
||||||
"--location",
|
"--location",
|
||||||
|
@ -6499,6 +6510,7 @@ mod tests {
|
||||||
subcommand: DenoSubcommand::Bench(BenchFlags {
|
subcommand: DenoSubcommand::Bench(BenchFlags {
|
||||||
filter: Some("- foo".to_string()),
|
filter: Some("- foo".to_string()),
|
||||||
json: true,
|
json: true,
|
||||||
|
no_run: true,
|
||||||
files: FileFlags {
|
files: FileFlags {
|
||||||
include: vec![PathBuf::from("dir1/"), PathBuf::from("dir2/")],
|
include: vec![PathBuf::from("dir1/"), PathBuf::from("dir2/")],
|
||||||
ignore: vec![],
|
ignore: vec![],
|
||||||
|
@ -6526,6 +6538,7 @@ mod tests {
|
||||||
subcommand: DenoSubcommand::Bench(BenchFlags {
|
subcommand: DenoSubcommand::Bench(BenchFlags {
|
||||||
filter: None,
|
filter: None,
|
||||||
json: false,
|
json: false,
|
||||||
|
no_run: false,
|
||||||
files: FileFlags {
|
files: FileFlags {
|
||||||
include: vec![],
|
include: vec![],
|
||||||
ignore: vec![],
|
ignore: vec![],
|
||||||
|
|
|
@ -119,6 +119,7 @@ pub struct BenchOptions {
|
||||||
pub files: FilesConfig,
|
pub files: FilesConfig,
|
||||||
pub filter: Option<String>,
|
pub filter: Option<String>,
|
||||||
pub json: bool,
|
pub json: bool,
|
||||||
|
pub no_run: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BenchOptions {
|
impl BenchOptions {
|
||||||
|
@ -134,6 +135,7 @@ impl BenchOptions {
|
||||||
),
|
),
|
||||||
filter: bench_flags.filter,
|
filter: bench_flags.filter,
|
||||||
json: bench_flags.json,
|
json: bench_flags.json,
|
||||||
|
no_run: bench_flags.no_run,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,6 +138,12 @@ itest!(filter {
|
||||||
output: "bench/filter.out",
|
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 {
|
itest!(no_prompt_by_default {
|
||||||
args: "bench --quiet bench/no_prompt_by_default.ts",
|
args: "bench --quiet bench/no_prompt_by_default.ts",
|
||||||
exit_code: 1,
|
exit_code: 1,
|
||||||
|
|
5
cli/tests/testdata/bench/no_run.out
vendored
Normal file
5
cli/tests/testdata/bench/no_run.out
vendored
Normal file
|
@ -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
|
2
cli/tests/testdata/bench/no_run.ts
vendored
Normal file
2
cli/tests/testdata/bench/no_run.ts
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
const _value: string = 1;
|
||||||
|
console.log("this should not be run");
|
|
@ -590,6 +590,10 @@ pub async fn run_benchmarks(
|
||||||
|
|
||||||
check_specifiers(&ps, permissions.clone(), specifiers.clone()).await?;
|
check_specifiers(&ps, permissions.clone(), specifiers.clone()).await?;
|
||||||
|
|
||||||
|
if bench_options.no_run {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
bench_specifiers(
|
bench_specifiers(
|
||||||
&ps,
|
&ps,
|
||||||
&permissions,
|
&permissions,
|
||||||
|
@ -742,6 +746,10 @@ pub async fn run_benchmarks_with_watch(
|
||||||
|
|
||||||
check_specifiers(&ps, permissions.clone(), specifiers.clone()).await?;
|
check_specifiers(&ps, permissions.clone(), specifiers.clone()).await?;
|
||||||
|
|
||||||
|
if bench_options.no_run {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
bench_specifiers(
|
bench_specifiers(
|
||||||
&ps,
|
&ps,
|
||||||
permissions,
|
permissions,
|
||||||
|
|
Loading…
Add table
Reference in a new issue