mirror of
https://github.com/denoland/deno.git
synced 2025-01-08 23:28:18 -05:00
parent
c824eb5817
commit
97ed0c954d
2 changed files with 33 additions and 2 deletions
24
cli/flags.rs
24
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) {
|
fn eval_parse(flags: &mut DenoFlags, matches: &clap::ArgMatches) {
|
||||||
|
v8_flags_arg_parse(flags, matches);
|
||||||
flags.subcommand = DenoSubcommand::Eval;
|
flags.subcommand = DenoSubcommand::Eval;
|
||||||
flags.allow_net = true;
|
flags.allow_net = true;
|
||||||
flags.allow_env = 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')\"",
|
deno eval \"console.log('hello world')\"",
|
||||||
)
|
)
|
||||||
.arg(Arg::with_name("code").takes_value(true).required(true))
|
.arg(Arg::with_name("code").takes_value(true).required(true))
|
||||||
|
.arg(v8_flags_arg())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn info_subcommand<'a, 'b>() -> App<'a, 'b> {
|
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]
|
#[test]
|
||||||
fn repl() {
|
fn repl() {
|
||||||
let r = flags_from_vec_safe(svec!["deno"]);
|
let r = flags_from_vec_safe(svec!["deno"]);
|
||||||
|
|
|
@ -631,12 +631,19 @@ itest!(unbuffered_stdout {
|
||||||
output: "unbuffered_stdout.ts.out",
|
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",
|
args: "run --v8-flags=--expose-gc v8_flags.js",
|
||||||
output: "v8_flags.js.out",
|
output: "v8_flags.js.out",
|
||||||
});
|
});
|
||||||
|
|
||||||
itest!(v8_help {
|
itest!(run_v8_help {
|
||||||
args: "run --v8-flags=--help",
|
args: "run --v8-flags=--help",
|
||||||
output: "v8_help.out",
|
output: "v8_help.out",
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue