diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2020-01-26 15:49:34 +0100 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2020-01-26 09:49:34 -0500 |
commit | 97ed0c954d2ae2237bc4aa69ef053f41f99762eb (patch) | |
tree | 99d5320f8ff910c4707995519e463915a06ae528 | |
parent | c824eb5817db675be4d9966a0d1a43d90dfa61fd (diff) |
feat: make eval support --v8-flags=... (#3797)
Closes #3796
-rw-r--r-- | cli/flags.rs | 24 | ||||
-rw-r--r-- | cli/tests/integration_tests.rs | 11 |
2 files changed, 33 insertions, 2 deletions
diff --git a/cli/flags.rs b/cli/flags.rs index 42a876947..10709b780 100644 --- a/cli/flags.rs +++ b/cli/flags.rs @@ -353,6 +353,7 @@ fn repl_parse(flags: &mut DenoFlags, matches: &clap::ArgMatches) { } fn eval_parse(flags: &mut DenoFlags, matches: &clap::ArgMatches) { + v8_flags_arg_parse(flags, matches); flags.subcommand = DenoSubcommand::Eval; flags.allow_net = true; flags.allow_env = true; @@ -797,6 +798,7 @@ This command has implicit access to all permissions (--allow-all) deno eval \"console.log('hello world')\"", ) .arg(Arg::with_name("code").takes_value(true).required(true)) + .arg(v8_flags_arg()) } fn info_subcommand<'a, 'b>() -> App<'a, 'b> { @@ -1550,6 +1552,28 @@ mod tests { } #[test] + fn eval_with_v8_flags() { + let r = + flags_from_vec_safe(svec!["deno", "eval", "--v8-flags=--help", "42"]); + assert_eq!( + r.unwrap(), + DenoFlags { + subcommand: DenoSubcommand::Eval, + argv: svec!["deno", "42"], + v8_flags: Some(svec!["--help"]), + allow_net: true, + allow_env: true, + allow_run: true, + allow_read: true, + allow_write: true, + allow_plugin: true, + allow_hrtime: true, + ..DenoFlags::default() + } + ); + } + + #[test] fn repl() { let r = flags_from_vec_safe(svec!["deno"]); assert_eq!( diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 260ded177..ce3828b8b 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -631,12 +631,19 @@ itest!(unbuffered_stdout { output: "unbuffered_stdout.ts.out", }); -itest!(v8_flags { +// Cannot write the expression to evaluate as "console.log(typeof gc)" +// because itest! splits args on whitespace. +itest!(eval_v8_flags { + args: "eval --v8-flags=--expose-gc console.log(typeof(gc))", + output: "v8_flags.js.out", +}); + +itest!(run_v8_flags { args: "run --v8-flags=--expose-gc v8_flags.js", output: "v8_flags.js.out", }); -itest!(v8_help { +itest!(run_v8_help { args: "run --v8-flags=--help", output: "v8_help.out", }); |