MCPcopy Create free account
hub / github.com/CodSpeedHQ/codspeed / check

Function check

crates/exec-harness/src/runtime_env/node/tests.rs:76–110  ·  view source on GitHub ↗
(mode: &str, major: u32, v8_log: Option<&str>)

Source from the content-addressed store, hash-verified

74}
75
76fn 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]
113fn node_wrapper_flags(

Callers 2

node_wrapper_flagsFunction · 0.85

Calls 6

write_fake_nodeFunction · 0.85
path_with_node_wrapperFunction · 0.85
expected_flagsFunction · 0.85
pathMethod · 0.80
envMethod · 0.80
argsMethod · 0.80

Tested by

no test coverage detected