mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 10:59:13 +00:00
feat(test): add --parallel
flag, soft deprecate --jobs
(#15259)
Co-authored-by: mrkldshv <markladyshev@gmail.com>
This commit is contained in:
parent
5f5bbd597a
commit
26cea0e2ca
3 changed files with 39 additions and 23 deletions
|
@ -480,10 +480,9 @@ static ENV_VARIABLES_HELP: &str = r#"ENVIRONMENT VARIABLES:
|
|||
DENO_NO_PROMPT Set to disable permission prompts on access
|
||||
(alternative to passing --no-prompt on invocation)
|
||||
DENO_WEBGPU_TRACE Directory to use for wgpu traces
|
||||
DENO_JOBS Number of parallel workers used for test subcommand.
|
||||
Defaults to number of available CPUs when used with
|
||||
--jobs flag and no value is provided.
|
||||
Defaults to 1 when --jobs flag is not used.
|
||||
DENO_JOBS Number of parallel workers used for the --parallel
|
||||
flag with the test subcommand. Defaults to number
|
||||
of available CPUs.
|
||||
HTTP_PROXY Proxy address for HTTP requests
|
||||
(module downloads, fetch)
|
||||
HTTPS_PROXY Proxy address for HTTPS requests
|
||||
|
@ -1548,11 +1547,19 @@ fn test_subcommand<'a>() -> Command<'a> {
|
|||
.conflicts_with("inspect-brk")
|
||||
.help("UNSTABLE: Collect coverage profile data into DIR"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("parallel")
|
||||
.long("parallel")
|
||||
.help("Run test modules in parallel. Parallelism defaults to the number of available CPUs or the value in the DENO_JOBS environment variable.")
|
||||
.conflicts_with("jobs")
|
||||
.takes_value(false)
|
||||
)
|
||||
.arg(
|
||||
Arg::new("jobs")
|
||||
.short('j')
|
||||
.long("jobs")
|
||||
.help("Number of parallel workers, defaults to number of available CPUs when no value is provided. Defaults to 1 when the option is not present.")
|
||||
.help("deprecated: Number of parallel workers, defaults to number of available CPUs when no value is provided. Defaults to 1 when the option is not present.")
|
||||
.hide(true)
|
||||
.min_values(0)
|
||||
.max_values(1)
|
||||
.takes_value(true)
|
||||
|
@ -2667,10 +2674,8 @@ fn test_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
|
|||
}
|
||||
}
|
||||
|
||||
let concurrent_jobs = if matches.is_present("jobs") {
|
||||
if let Some(value) = matches.value_of("jobs") {
|
||||
value.parse().unwrap()
|
||||
} else if let Ok(value) = env::var("DENO_JOBS") {
|
||||
let concurrent_jobs = if matches.is_present("parallel") {
|
||||
if let Ok(value) = env::var("DENO_JOBS") {
|
||||
value
|
||||
.parse::<NonZeroUsize>()
|
||||
.unwrap_or(NonZeroUsize::new(1).unwrap())
|
||||
|
@ -2678,6 +2683,17 @@ fn test_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
|
|||
std::thread::available_parallelism()
|
||||
.unwrap_or(NonZeroUsize::new(1).unwrap())
|
||||
}
|
||||
} else if matches.is_present("jobs") {
|
||||
println!(
|
||||
"{}",
|
||||
crate::colors::yellow("Warning: --jobs flag is deprecated. Use the --parallel flag with possibly the 'DENO_JOBS' environment variable."),
|
||||
);
|
||||
if let Some(value) = matches.value_of("jobs") {
|
||||
value.parse().unwrap()
|
||||
} else {
|
||||
std::thread::available_parallelism()
|
||||
.unwrap_or(NonZeroUsize::new(1).unwrap())
|
||||
}
|
||||
} else {
|
||||
NonZeroUsize::new(1).unwrap()
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue