Skip to content

Commit 3769b98

Browse files
committed
chore: add better tests
1 parent 64d9e87 commit 3769b98

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

src/run/runner/tests.rs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,31 @@ const DIRECTORY_CHECK_SCRIPT: &str = "cd /tmp
2020
if [ $(basename $(pwd)) != \"tmp\" ]; then
2121
exit 1
2222
fi";
23+
const QUOTE_ESCAPE_SCRIPT: &str = "#!/bin/bash
24+
VALUE=\"He said \\\"Hello 'world'\\\" & echo \\$HOME\"
25+
if [ \"$VALUE\" = \"He said \\\"Hello 'world'\\\" & echo \\$HOME\" ]; then
26+
echo \"Quote test passed\"
27+
else
28+
echo \"ERROR: Quote handling failed\"
29+
exit 1
30+
fi";
31+
const COMMAND_SUBSTITUTION_SCRIPT: &str = "#!/bin/bash
32+
RESULT=$(echo \"test 'nested' \\\"quotes\\\" here\")
33+
COUNT=$(echo \"$RESULT\" | wc -w)
34+
if [ \"$COUNT\" -eq \"4\" ]; then
35+
echo \"Command substitution test passed\"
36+
else
37+
echo \"ERROR: Expected 4 words, got $COUNT\"
38+
exit 1
39+
fi";
2340

24-
const TESTS: [&str; 4] = [
41+
const TESTS: [&str; 6] = [
2542
SIMPLE_ECHO_SCRIPT,
2643
MULTILINE_ECHO_SCRIPT,
2744
MULTILINE_ECHO_WITH_SEMICOLONS,
2845
DIRECTORY_CHECK_SCRIPT,
46+
QUOTE_ESCAPE_SCRIPT,
47+
COMMAND_SUBSTITUTION_SCRIPT,
2948
];
3049

3150
fn env_var_validation_script(env: &str, expected: &str) -> String {
@@ -102,6 +121,8 @@ mod valgrind {
102121
#[case(TESTS[1])]
103122
#[case(TESTS[2])]
104123
#[case(TESTS[3])]
124+
#[case(TESTS[4])]
125+
#[case(TESTS[5])]
105126
#[tokio::test]
106127
async fn test_valgrind_executor(#[case] cmd: &str) {
107128
let (system_info, run_data, _temp_dir) = create_test_setup().await;
@@ -184,6 +205,10 @@ mod walltime {
184205
#[case(TESTS[2], true)]
185206
#[case(TESTS[3], false)]
186207
#[case(TESTS[3], true)]
208+
#[case(TESTS[4], false)]
209+
#[case(TESTS[4], true)]
210+
#[case(TESTS[5], false)]
211+
#[case(TESTS[5], true)]
187212
#[tokio::test]
188213
async fn test_walltime_executor(#[case] cmd: &str, #[case] enable_perf: bool) {
189214
let (system_info, run_data, _temp_dir) = create_test_setup().await;
@@ -224,8 +249,6 @@ mod walltime {
224249
let (env_var, env_value) = env_case;
225250
temp_env::async_with_vars(&[(env_var, Some(env_value))], async {
226251
let cmd = env_var_validation_script(env_var, env_value);
227-
eprintln!("{cmd}");
228-
eprintln!("env_value: {env_value}");
229252
let config = walltime_config(&cmd, enable_perf);
230253
executor
231254
.run(&config, &system_info, &run_data, &None)

0 commit comments

Comments
 (0)