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

Function symlink_libpython

src/executor/valgrind/helpers/venv_compat.rs:21–48  ·  view source on GitHub ↗
(cwd: Option<&String>)

Source from the content-addressed store, hash-verified

19const VENV_COMPAT_SCRIPT: &str = include_str!("venv_compat.sh");
20
21pub fn symlink_libpython(cwd: Option<&String>) -> anyhow::Result<()> {
22 let rwx = std::fs::Permissions::from_mode(0o777);
23 let mut script_file = tempfile::Builder::new()
24 .suffix(".sh")
25 .permissions(rwx)
26 .tempfile()?;
27 script_file.write_all(VENV_COMPAT_SCRIPT.as_bytes())?;
28
29 let mut cmd = Command::new("bash");
30 cmd.arg(script_file.path());
31
32 if let Some(cwd) = cwd {
33 cmd.current_dir(cwd);
34 }
35
36 debug!("Running the venv compat script");
37 let output = cmd.output()?;
38
39 let stdout = String::from_utf8(output.stdout)?;
40 debug!("Script output: {stdout}");
41
42 if !output.status.success() {
43 let stderr = String::from_utf8(output.stderr)?;
44 bail!("Failed to execute script: {stdout} {stderr}");
45 }
46
47 Ok(())
48}
49
50#[cfg(test)]
51mod tests {

Callers 1

setupMethod · 0.85

Calls 3

argMethod · 0.80
pathMethod · 0.80
current_dirMethod · 0.80

Tested by

no test coverage detected