1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-15 18:38:53 -05:00

rename parse_core_args to v8_set_flags_preprocess (#871)

This commit is contained in:
ztplz 2018-10-01 22:23:36 +08:00 committed by Ryan Dahl
parent bcdbfc00f0
commit 1fcc11a19d

View file

@ -166,8 +166,7 @@ fn test_set_flags_4() {
} }
// Returns args passed to V8, followed by args passed to JS // Returns args passed to V8, followed by args passed to JS
// TODO Rename to v8_set_flags_preprocess fn v8_set_flags_preprocess(args: Vec<String>) -> (Vec<String>, Vec<String>) {
fn parse_core_args(args: Vec<String>) -> (Vec<String>, Vec<String>) {
let mut rest = vec![]; let mut rest = vec![];
// Filter out args that shouldn't be passed to V8 // Filter out args that shouldn't be passed to V8
@ -193,9 +192,9 @@ fn parse_core_args(args: Vec<String>) -> (Vec<String>, Vec<String>) {
} }
#[test] #[test]
fn test_parse_core_args_1() { fn test_v8_set_flags_preprocess_1() {
let js_args = let js_args =
parse_core_args(vec!["deno".to_string(), "--v8-options".to_string()]); v8_set_flags_preprocess(vec!["deno".to_string(), "--v8-options".to_string()]);
assert_eq!( assert_eq!(
js_args, js_args,
(vec!["deno".to_string(), "--help".to_string()], vec![]) (vec!["deno".to_string(), "--help".to_string()], vec![])
@ -203,8 +202,8 @@ fn test_parse_core_args_1() {
} }
#[test] #[test]
fn test_parse_core_args_2() { fn test_v8_set_flags_preprocess_2() {
let js_args = parse_core_args(vec!["deno".to_string(), "--help".to_string()]); let js_args = v8_set_flags_preprocess(vec!["deno".to_string(), "--help".to_string()]);
assert_eq!( assert_eq!(
js_args, js_args,
(vec!["deno".to_string()], vec!["--help".to_string()]) (vec!["deno".to_string()], vec!["--help".to_string()])
@ -217,7 +216,7 @@ pub fn v8_set_flags(args: Vec<String>) -> Vec<String> {
// deno_set_v8_flags(int* argc, char** argv) mutates argc and argv to remove // deno_set_v8_flags(int* argc, char** argv) mutates argc and argv to remove
// flags that v8 understands. // flags that v8 understands.
// First parse core args, then converto to a vector of C strings. // First parse core args, then converto to a vector of C strings.
let (argv, rest) = parse_core_args(args); let (argv, rest) = v8_set_flags_preprocess(args);
let mut argv = argv let mut argv = argv
.iter() .iter()
.map(|arg| CString::new(arg.as_str()).unwrap().into_bytes_with_nul()) .map(|arg| CString::new(arg.as_str()).unwrap().into_bytes_with_nul())