(mode: &str, major: u32, v8_log: Option<&str>)
| 74 | } |
| 75 | |
| 76 | fn check(mode: &str, major: u32, v8_log: Option<&str>) { |
| 77 | let fake_dir = tempfile::tempdir().unwrap(); |
| 78 | write_fake_node(fake_dir.path(), major); |
| 79 | // Keep the system PATH after the fake node: the wrapper needs bash, tr, grep and paste. |
| 80 | let system_path = std::env::var_os("PATH").unwrap_or_default(); |
| 81 | let base_path = std::env::join_paths( |
| 82 | std::iter::once(fake_dir.path().to_path_buf()).chain(std::env::split_paths(&system_path)), |
| 83 | ) |
| 84 | .unwrap(); |
| 85 | let path = path_with_node_wrapper(&base_path).unwrap(); |
| 86 | |
| 87 | let mut cmd = Command::new("node"); |
| 88 | cmd.args(USER_ARGS) |
| 89 | .env("PATH", &path) |
| 90 | .env(RUNNER_MODE_ENV, mode); |
| 91 | match v8_log { |
| 92 | Some(dir) => cmd.env(V8_LOG_ENV, dir), |
| 93 | None => cmd.env_remove(V8_LOG_ENV), |
| 94 | }; |
| 95 | let output = cmd.output().unwrap(); |
| 96 | assert!( |
| 97 | output.status.success(), |
| 98 | "{}", |
| 99 | String::from_utf8_lossy(&output.stderr) |
| 100 | ); |
| 101 | |
| 102 | let mut expected = expected_flags(mode, major, v8_log); |
| 103 | expected.extend(USER_ARGS.map(str::to_owned)); |
| 104 | let actual: Vec<String> = String::from_utf8(output.stdout) |
| 105 | .unwrap() |
| 106 | .split_whitespace() |
| 107 | .map(str::to_owned) |
| 108 | .collect(); |
| 109 | assert_eq!(actual, expected); |
| 110 | } |
| 111 | |
| 112 | #[rstest] |
| 113 | fn node_wrapper_flags( |
no test coverage detected