Skip to content

Commit

Permalink
feat: add --enable-testing-features-do-not-use (#11499)
Browse files Browse the repository at this point in the history
This flag does nothing yet. It is added in preparation for the addition
of classic workers.
  • Loading branch information
lucacasonato authored Jul 23, 2021
1 parent 8b34f07 commit 28f2f02
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 9 deletions.
75 changes: 70 additions & 5 deletions cli/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,22 +137,23 @@ pub struct Flags {
pub allow_read: Option<Vec<PathBuf>>,
pub allow_run: Option<Vec<String>>,
pub allow_write: Option<Vec<PathBuf>>,
pub location: Option<Url>,
pub cache_blocklist: Vec<String>,
pub ca_file: Option<String>,
pub cache_blocklist: Vec<String>,
pub cached_only: bool,
pub config_path: Option<String>,
pub coverage_dir: Option<String>,
pub enable_testing_features: bool,
pub ignore: Vec<PathBuf>,
pub import_map_path: Option<String>,
pub inspect: Option<SocketAddr>,
pub inspect_brk: Option<SocketAddr>,
pub lock: Option<PathBuf>,
pub inspect: Option<SocketAddr>,
pub location: Option<Url>,
pub lock_write: bool,
pub lock: Option<PathBuf>,
pub log_level: Option<Level>,
pub no_check: bool,
pub prompt: bool,
pub no_remote: bool,
pub prompt: bool,
pub reload: bool,
pub repl: bool,
pub seed: Option<u64>,
Expand Down Expand Up @@ -1267,6 +1268,7 @@ fn runtime_args<'a, 'b>(
.arg(location_arg())
.arg(v8_flags_arg())
.arg(seed_arg())
.arg(enable_testing_features_arg())
}

fn inspect_args<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> {
Expand Down Expand Up @@ -1368,6 +1370,13 @@ fn location_arg<'a, 'b>() -> Arg<'a, 'b> {
.help("Value of 'globalThis.location' used by some web APIs")
}

fn enable_testing_features_arg<'a, 'b>() -> Arg<'a, 'b> {
Arg::with_name("enable-testing-features-do-not-use")
.long("enable-testing-features-do-not-use")
.help("INTERNAL: Enable internal features used during integration testing")
.hidden(true)
}

fn v8_flags_arg<'a, 'b>() -> Arg<'a, 'b> {
Arg::with_name("v8-flags")
.long("v8-flags")
Expand Down Expand Up @@ -1902,6 +1911,7 @@ fn runtime_args_parse(
v8_flags_arg_parse(flags, matches);
seed_arg_parse(flags, matches);
inspect_arg_parse(flags, matches);
enable_testing_features_arg_parse(flags, matches);
}

fn inspect_arg_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
Expand Down Expand Up @@ -1948,6 +1958,15 @@ fn ca_file_arg_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
flags.ca_file = matches.value_of("cert").map(ToOwned::to_owned);
}

fn enable_testing_features_arg_parse(
flags: &mut Flags,
matches: &clap::ArgMatches,
) {
if matches.is_present("enable-testing-features-do-not-use") {
flags.enable_testing_features = true
}
}

fn cached_only_arg_parse(flags: &mut Flags, matches: &ArgMatches) {
if matches.is_present("cached-only") {
flags.cached_only = true;
Expand Down Expand Up @@ -3452,6 +3471,26 @@ mod tests {
);
}

#[test]
fn run_with_enable_testing_features() {
let r = flags_from_vec(svec![
"deno",
"run",
"--enable-testing-features-do-not-use",
"script.ts"
]);
assert_eq!(
r.unwrap(),
Flags {
subcommand: DenoSubcommand::Run {
script: "script.ts".to_string(),
},
enable_testing_features: true,
..Flags::default()
}
);
}

#[test]
fn test_with_fail_fast() {
let r = flags_from_vec(svec!["deno", "test", "--fail-fast=3"]);
Expand All @@ -3474,6 +3513,32 @@ mod tests {
);
}

#[test]
fn test_with_enable_testing_features() {
let r = flags_from_vec(svec![
"deno",
"test",
"--enable-testing-features-do-not-use"
]);
assert_eq!(
r.unwrap(),
Flags {
subcommand: DenoSubcommand::Test {
no_run: false,
doc: false,
fail_fast: None,
filter: None,
allow_none: false,
quiet: false,
shuffle: None,
include: None,
concurrent_jobs: 1,
},
enable_testing_features: true,
..Flags::default()
}
);
}
#[test]
fn test_watch() {
let r = flags_from_vec(svec!["deno", "test", "--watch"]);
Expand Down
9 changes: 5 additions & 4 deletions cli/tools/standalone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,22 +205,23 @@ pub fn compile_to_runtime_flags(
allow_read: flags.allow_read,
allow_run: flags.allow_run,
allow_write: flags.allow_write,
cache_blocklist: vec![],
ca_file: flags.ca_file,
cache_blocklist: vec![],
cached_only: false,
config_path: None,
coverage_dir: flags.coverage_dir,
enable_testing_features: false,
ignore: vec![],
import_map_path: None,
inspect: None,
inspect_brk: None,
inspect: None,
location: flags.location,
lock: None,
lock_write: false,
lock: None,
log_level: flags.log_level,
no_check: false,
prompt: flags.prompt,
no_remote: false,
prompt: flags.prompt,
reload: false,
repl: false,
seed: flags.seed,
Expand Down

0 comments on commit 28f2f02

Please sign in to comment.