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

Function write_cwd_check_script

tests/working_directory.rs:26–40  ·  view source on GitHub ↗

Create a bash script that validates CWD matches the expected absolute path.

(path: &Path, expected_dir: &Path)

Source from the content-addressed store, hash-verified

24
25 /// Create a bash script that validates CWD matches the expected absolute path.
26 fn write_cwd_check_script(path: &Path, expected_dir: &Path) {
27 let expected = expected_dir.to_string_lossy();
28 let content = format!(
29 r#"#!/bin/bash
30ACTUAL=$(pwd)
31EXPECTED="{expected}"
32if [ "$ACTUAL" != "$EXPECTED" ]; then
33 echo "FAIL: expected $EXPECTED, got $ACTUAL" >&2
34 exit 1
35fi
36"#
37 );
38 fs::write(path, content).unwrap();
39 fs::set_permissions(path, fs::Permissions::from_mode(0o755)).unwrap();
40 }
41
42 /// Write a codspeed.yml config file.
43 fn write_config(path: &Path, content: &str) {

Calls

no outgoing calls