1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-08 15:19:40 -05:00

feat: make eval support --v8-flags=... (#3797)

Closes #3796
This commit is contained in:
Ben Noordhuis 2020-01-26 15:49:34 +01:00 committed by Ryan Dahl
parent c824eb5817
commit 97ed0c954d
2 changed files with 33 additions and 2 deletions

View file

@ -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> {
@ -1549,6 +1551,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"]);

View file

@ -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",
});