diff options
Diffstat (limited to 'cli/args/flags.rs')
-rw-r--r-- | cli/args/flags.rs | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/cli/args/flags.rs b/cli/args/flags.rs index 9384dacf8..d57f78aff 100644 --- a/cli/args/flags.rs +++ b/cli/args/flags.rs @@ -517,6 +517,7 @@ pub struct Flags { pub unstable_config: UnstableConfig, pub unsafely_ignore_certificate_errors: Option<Vec<String>>, pub v8_flags: Vec<String>, + pub code_cache_enabled: bool, } fn join_paths(allowlist: &[String], d: &str) -> String { @@ -2236,6 +2237,7 @@ fn run_subcommand() -> Command { .trailing_var_arg(true), ) .arg(env_file_arg()) + .arg(no_code_cache_arg()) .about("Run a JavaScript or TypeScript program") .long_about( "Run a JavaScript or TypeScript program @@ -3222,6 +3224,13 @@ fn no_clear_screen_arg() -> Arg { .help("Do not clear terminal screen when under watch mode") } +fn no_code_cache_arg() -> Arg { + Arg::new("no-code-cache") + .long("no-code-cache") + .help("Disable V8 code cache feature") + .action(ArgAction::SetTrue) +} + fn watch_exclude_arg() -> Arg { Arg::new("watch-exclude") .long("watch-exclude") @@ -3829,6 +3838,8 @@ fn run_parse( ) -> clap::error::Result<()> { runtime_args_parse(flags, matches, true, true); + flags.code_cache_enabled = !matches.get_flag("no-code-cache"); + let mut script_arg = matches.remove_many::<String>("script_arg").ok_or_else(|| { let mut app = app; @@ -4469,6 +4480,7 @@ mod tests { ..Default::default() }, log_level: Some(Level::Error), + code_cache_enabled: true, ..Flags::default() } ); @@ -4540,6 +4552,7 @@ mod tests { "script.ts".to_string() )), reload: true, + code_cache_enabled: true, ..Flags::default() } ); @@ -4561,6 +4574,7 @@ mod tests { exclude: vec![], }), }), + code_cache_enabled: true, ..Flags::default() } ); @@ -4585,6 +4599,7 @@ mod tests { exclude: vec![], }), }), + code_cache_enabled: true, ..Flags::default() } ); @@ -4609,6 +4624,7 @@ mod tests { exclude: vec![], }), }), + code_cache_enabled: true, ..Flags::default() } ); @@ -4633,6 +4649,7 @@ mod tests { exclude: vec![], }), }), + code_cache_enabled: true, ..Flags::default() } ); @@ -4659,6 +4676,7 @@ mod tests { exclude: vec![], }), }), + code_cache_enabled: true, ..Flags::default() } ); @@ -4687,6 +4705,7 @@ mod tests { exclude: vec![], }), }), + code_cache_enabled: true, ..Flags::default() } ); @@ -4715,6 +4734,7 @@ mod tests { exclude: vec![String::from("foo")], }), }), + code_cache_enabled: true, ..Flags::default() } ); @@ -4739,6 +4759,7 @@ mod tests { exclude: vec![String::from("bar")], }), }), + code_cache_enabled: true, ..Flags::default() } ); @@ -4764,6 +4785,7 @@ mod tests { exclude: vec![String::from("foo"), String::from("bar")], }), }), + code_cache_enabled: true, ..Flags::default() } ); @@ -4789,6 +4811,7 @@ mod tests { exclude: vec![String::from("baz"), String::from("qux"),], }), }), + code_cache_enabled: true, ..Flags::default() } ); @@ -4806,6 +4829,7 @@ mod tests { "script.ts".to_string() )), allow_write: Some(vec![]), + code_cache_enabled: true, ..Flags::default() } ); @@ -4819,6 +4843,7 @@ mod tests { Flags { subcommand: DenoSubcommand::Run(RunFlags::new_default("_".to_string())), v8_flags: svec!["--help"], + code_cache_enabled: true, ..Flags::default() } ); @@ -4836,6 +4861,7 @@ mod tests { "script.ts".to_string() )), v8_flags: svec!["--expose-gc", "--gc-stats=1"], + code_cache_enabled: true, ..Flags::default() } ); @@ -4889,6 +4915,7 @@ mod tests { )), argv: svec!["--title", "X"], allow_net: Some(vec![]), + code_cache_enabled: true, ..Flags::default() } ); @@ -4912,6 +4939,7 @@ mod tests { allow_write: Some(vec![]), allow_ffi: Some(vec![]), allow_hrtime: true, + code_cache_enabled: true, ..Flags::default() } ); @@ -4927,6 +4955,7 @@ mod tests { "gist.ts".to_string() )), allow_read: Some(vec![]), + code_cache_enabled: true, ..Flags::default() } ); @@ -4942,6 +4971,7 @@ mod tests { "gist.ts".to_string() )), deny_read: Some(vec![]), + code_cache_enabled: true, ..Flags::default() } ); @@ -4957,6 +4987,7 @@ mod tests { "gist.ts".to_string(), )), allow_hrtime: true, + code_cache_enabled: true, ..Flags::default() } ); @@ -4972,6 +5003,7 @@ mod tests { "gist.ts".to_string(), )), deny_hrtime: true, + code_cache_enabled: true, ..Flags::default() } ); @@ -4999,6 +5031,7 @@ mod tests { )), argv: svec!["--", "-D", "--allow-net"], allow_write: Some(vec![]), + code_cache_enabled: true, ..Flags::default() } ); @@ -5713,6 +5746,7 @@ mod tests { "script.ts".to_string(), )), config_flag: ConfigFlag::Path("tsconfig.json".to_owned()), + code_cache_enabled: true, ..Flags::default() } ); @@ -6007,6 +6041,7 @@ mod tests { subcommand: DenoSubcommand::Run(RunFlags::new_default( "script.ts".to_string(), )), + code_cache_enabled: true, ..Flags::default() } ); @@ -6031,6 +6066,7 @@ mod tests { subcommand: DenoSubcommand::Run(RunFlags::new_default( "script.ts".to_string(), )), + code_cache_enabled: true, ..Flags::default() } ); @@ -6055,6 +6091,7 @@ mod tests { subcommand: DenoSubcommand::Run(RunFlags::new_default( "script.ts".to_string(), )), + code_cache_enabled: true, ..Flags::default() } ); @@ -6079,6 +6116,7 @@ mod tests { subcommand: DenoSubcommand::Run(RunFlags::new_default( "script.ts".to_string(), )), + code_cache_enabled: true, ..Flags::default() } ); @@ -6099,6 +6137,7 @@ mod tests { "script.ts".to_string(), )), allow_net: Some(svec!["127.0.0.1"]), + code_cache_enabled: true, ..Flags::default() } ); @@ -6115,6 +6154,7 @@ mod tests { "script.ts".to_string(), )), deny_net: Some(svec!["127.0.0.1"]), + code_cache_enabled: true, ..Flags::default() } ); @@ -6131,6 +6171,7 @@ mod tests { "script.ts".to_string(), )), allow_env: Some(svec!["HOME"]), + code_cache_enabled: true, ..Flags::default() } ); @@ -6147,6 +6188,7 @@ mod tests { "script.ts".to_string(), )), deny_env: Some(svec!["HOME"]), + code_cache_enabled: true, ..Flags::default() } ); @@ -6167,6 +6209,7 @@ mod tests { "script.ts".to_string(), )), allow_env: Some(svec!["HOME", "PATH"]), + code_cache_enabled: true, ..Flags::default() } ); @@ -6183,6 +6226,7 @@ mod tests { "script.ts".to_string(), )), deny_env: Some(svec!["HOME", "PATH"]), + code_cache_enabled: true, ..Flags::default() } ); @@ -6224,6 +6268,7 @@ mod tests { "script.ts".to_string(), )), allow_sys: Some(vec![]), + code_cache_enabled: true, ..Flags::default() } ); @@ -6239,6 +6284,7 @@ mod tests { "script.ts".to_string(), )), deny_sys: Some(vec![]), + code_cache_enabled: true, ..Flags::default() } ); @@ -6255,6 +6301,7 @@ mod tests { "script.ts".to_string(), )), allow_sys: Some(svec!["hostname"]), + code_cache_enabled: true, ..Flags::default() } ); @@ -6271,6 +6318,7 @@ mod tests { "script.ts".to_string(), )), deny_sys: Some(svec!["hostname"]), + code_cache_enabled: true, ..Flags::default() } ); @@ -6291,6 +6339,7 @@ mod tests { "script.ts".to_string(), )), allow_sys: Some(svec!["hostname", "osRelease"]), + code_cache_enabled: true, ..Flags::default() } ); @@ -6311,6 +6360,7 @@ mod tests { "script.ts".to_string(), )), deny_sys: Some(svec!["hostname", "osRelease"]), + code_cache_enabled: true, ..Flags::default() } ); @@ -6618,6 +6668,7 @@ mod tests { "script.ts".to_string(), )), import_map_path: Some("import_map.json".to_owned()), + code_cache_enabled: true, ..Flags::default() } ); @@ -6699,6 +6750,22 @@ mod tests { "script.ts".to_string(), )), env_file: Some(".env".to_owned()), + code_cache_enabled: true, + ..Flags::default() + } + ); + } + + #[test] + fn run_no_code_cache() { + let r = + flags_from_vec(svec!["deno", "run", "--no-code-cache", "script.ts"]); + assert_eq!( + r.unwrap(), + Flags { + subcommand: DenoSubcommand::Run(RunFlags::new_default( + "script.ts".to_string(), + )), ..Flags::default() } ); @@ -6715,6 +6782,7 @@ mod tests { "script.ts".to_string(), )), env_file: Some(".another_env".to_owned()), + code_cache_enabled: true, ..Flags::default() } ); @@ -6746,6 +6814,7 @@ mod tests { )), seed: Some(250_u64), v8_flags: svec!["--random-seed=250"], + code_cache_enabled: true, ..Flags::default() } ); @@ -6769,6 +6838,7 @@ mod tests { )), seed: Some(250_u64), v8_flags: svec!["--expose-gc", "--random-seed=250"], + code_cache_enabled: true, ..Flags::default() } ); @@ -6907,6 +6977,7 @@ mod tests { "script.ts".to_string(), )), log_level: Some(Level::Debug), + code_cache_enabled: true, ..Flags::default() } ); @@ -6922,6 +6993,7 @@ mod tests { "script.ts".to_string(), )), log_level: Some(Level::Error), + code_cache_enabled: true, ..Flags::default() } ); @@ -6955,6 +7027,7 @@ mod tests { "script.ts".to_string(), )), argv: svec!["--allow-read", "--allow-net"], + code_cache_enabled: true, ..Flags::default() } ); @@ -6980,6 +7053,7 @@ mod tests { location: Some(Url::parse("https://foo/").unwrap()), allow_read: Some(vec![]), argv: svec!["--allow-net", "-r", "--help", "--foo", "bar"], + code_cache_enabled: true, ..Flags::default() } ); @@ -6992,6 +7066,7 @@ mod tests { "script.ts".to_string(), )), argv: svec!["foo", "bar"], + code_cache_enabled: true, ..Flags::default() } ); @@ -7003,6 +7078,7 @@ mod tests { "script.ts".to_string(), )), argv: svec!["-"], + code_cache_enabled: true, ..Flags::default() } ); @@ -7016,6 +7092,7 @@ mod tests { "script.ts".to_string(), )), argv: svec!["-", "foo", "bar"], + code_cache_enabled: true, ..Flags::default() } ); @@ -7031,6 +7108,7 @@ mod tests { "script.ts".to_string(), )), type_check_mode: TypeCheckMode::None, + code_cache_enabled: true, ..Flags::default() } ); @@ -7047,6 +7125,7 @@ mod tests { "script.ts".to_string(), )), type_check_mode: TypeCheckMode::Local, + code_cache_enabled: true, ..Flags::default() } ); @@ -7091,6 +7170,7 @@ mod tests { "script.ts".to_string(), )), unsafely_ignore_certificate_errors: Some(vec![]), + code_cache_enabled: true, ..Flags::default() } ); @@ -7118,6 +7198,7 @@ mod tests { "[::1]", "1.2.3.4" ]), + code_cache_enabled: true, ..Flags::default() } ); @@ -7161,6 +7242,7 @@ mod tests { "script.ts".to_string(), )), no_remote: true, + code_cache_enabled: true, ..Flags::default() } ); @@ -7176,6 +7258,7 @@ mod tests { "script.ts".to_string(), )), no_npm: true, + code_cache_enabled: true, ..Flags::default() } ); @@ -7192,6 +7275,7 @@ mod tests { "script.ts".to_string(), )), node_modules_dir: Some(true), + code_cache_enabled: true, ..Flags::default() } ); @@ -7209,6 +7293,7 @@ mod tests { "script.ts".to_string(), )), node_modules_dir: Some(false), + code_cache_enabled: true, ..Flags::default() } ); @@ -7224,6 +7309,7 @@ mod tests { "script.ts".to_string(), )), vendor: Some(true), + code_cache_enabled: true, ..Flags::default() } ); @@ -7236,6 +7322,7 @@ mod tests { "script.ts".to_string(), )), vendor: Some(false), + code_cache_enabled: true, ..Flags::default() } ); @@ -7251,6 +7338,7 @@ mod tests { "script.ts".to_string(), )), cached_only: true, + code_cache_enabled: true, ..Flags::default() } ); @@ -7279,6 +7367,7 @@ mod tests { "127.0.0.1:4545", "localhost:4545" ]), + code_cache_enabled: true, ..Flags::default() } ); @@ -7307,6 +7396,7 @@ mod tests { "127.0.0.1:4545", "localhost:4545" ]), + code_cache_enabled: true, ..Flags::default() } ); @@ -7338,6 +7428,7 @@ mod tests { "localhost:5678", "[::1]:8080" ]), + code_cache_enabled: true, ..Flags::default() } ); @@ -7369,6 +7460,7 @@ mod tests { "localhost:5678", "[::1]:8080" ]), + code_cache_enabled: true, ..Flags::default() } ); @@ -7391,6 +7483,7 @@ mod tests { )), lock_write: true, lock: Some(String::from("lock.json")), + code_cache_enabled: true, ..Flags::default() } ); @@ -7403,6 +7496,7 @@ mod tests { "script.ts".to_string(), )), no_lock: true, + code_cache_enabled: true, ..Flags::default() } ); @@ -7422,6 +7516,7 @@ mod tests { )), lock_write: true, lock: Some(String::from("./deno.lock")), + code_cache_enabled: true, ..Flags::default() } ); @@ -7442,6 +7537,7 @@ mod tests { )), lock_write: true, lock: Some(String::from("lock.json")), + code_cache_enabled: true, ..Flags::default() } ); @@ -7454,6 +7550,7 @@ mod tests { "script.ts".to_string(), )), lock_write: true, + code_cache_enabled: true, ..Flags::default() } ); @@ -7546,6 +7643,7 @@ mod tests { "script.ts".to_string(), )), ca_data: Some(CaData::File("example.crt".to_owned())), + code_cache_enabled: true, ..Flags::default() } ); @@ -7566,6 +7664,7 @@ mod tests { "script.ts".to_string(), )), enable_testing_features: true, + code_cache_enabled: true, ..Flags::default() } ); @@ -8244,6 +8343,7 @@ mod tests { "foo.js".to_string(), )), inspect: Some("127.0.0.1:9229".parse().unwrap()), + code_cache_enabled: true, ..Flags::default() } ); @@ -8259,6 +8359,7 @@ mod tests { "foo.js".to_string(), )), inspect_wait: Some("127.0.0.1:9229".parse().unwrap()), + code_cache_enabled: true, ..Flags::default() } ); @@ -8276,6 +8377,7 @@ mod tests { "foo.js".to_string(), )), inspect_wait: Some("127.0.0.1:3567".parse().unwrap()), + code_cache_enabled: true, ..Flags::default() } ); @@ -8802,6 +8904,7 @@ mod tests { "script.ts".to_string(), )), type_check_mode: TypeCheckMode::Local, + code_cache_enabled: true, ..Flags::default() } ); @@ -8814,6 +8917,7 @@ mod tests { "script.ts".to_string(), )), type_check_mode: TypeCheckMode::All, + code_cache_enabled: true, ..Flags::default() } ); @@ -8826,6 +8930,7 @@ mod tests { "script.ts".to_string(), )), type_check_mode: TypeCheckMode::None, + code_cache_enabled: true, ..Flags::default() } ); @@ -8850,6 +8955,7 @@ mod tests { "script.ts".to_string(), )), config_flag: ConfigFlag::Disabled, + code_cache_enabled: true, ..Flags::default() } ); |