From a3914f81673e84bfa7003110dfcf06617138e499 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 10 May 2025 13:01:24 +1200 Subject: [PATCH] . --- runner/examples/env_vars.json | 2 +- runner/test.sh | 31 +++++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/runner/examples/env_vars.json b/runner/examples/env_vars.json index 46e3803..2f6f212 100644 --- a/runner/examples/env_vars.json +++ b/runner/examples/env_vars.json @@ -1 +1 @@ -{"command":"bash","args":["-c","echo Hello $NAME, the current directory is $PWD"],"env":{"NAME":"Runner","CUSTOM_VAR":"This is a custom environment variable"}} +{"command":"bash","args":["-c","echo Hello $NAME, the current directory is $PWD"],"env":{"NAME":"Runner","CUSTOM_VAR":"This is a custom environment variable"}} \ No newline at end of file diff --git a/runner/test.sh b/runner/test.sh index fc4e29f..4770593 100755 --- a/runner/test.sh +++ b/runner/test.sh @@ -15,8 +15,11 @@ fi # Run a simple echo command echo "Test 1: Basic command execution" -JSON='{"command":"echo","args":["Hello from runner test!"]}' -BASE64=$(echo -n "$JSON" | base64) +JSON=$(cat <<'EOF' +{"command":"echo","args":["Hello from runner test!"]} +EOF +) +BASE64=$(echo -n "$JSON" | base64 -w0) echo "JSON: $JSON" echo "Running command..." build/runner "$BASE64" @@ -30,8 +33,11 @@ echo # Test with environment variables echo "Test 2: Environment variables" -JSON='{"command":"bash","args":["-c","echo Value of TEST_VAR: $TEST_VAR"],"env":{"TEST_VAR":"This is a test environment variable"}}' -BASE64=$(echo -n "$JSON" | base64) +JSON=$(cat <<'EOF' +{"command":"bash","args":["-c","echo Value of TEST_VAR: $TEST_VAR"],"env":{"TEST_VAR":"This is a test environment variable"}} +EOF +) +BASE64=$(echo -n "$JSON" | base64 -w0) echo "JSON: $JSON" echo "Running command..." build/runner "$BASE64" @@ -45,8 +51,11 @@ echo # Test silent mode echo "Test 3: Silent mode" -JSON='{"command":"echo","args":["This should not be displayed"],"options":{"silent":true}}' -BASE64=$(echo -n "$JSON" | base64) +JSON=$(cat <<'EOF' +{"command":"echo","args":["This should not be displayed"],"options":{"silent":true}} +EOF +) +BASE64=$(echo -n "$JSON" | base64 -w0) echo "JSON: $JSON" echo "Running command (no output expected)..." OUTPUT=$(build/runner "$BASE64") @@ -60,7 +69,10 @@ echo # Test return code handling echo "Test 4: Error return code" -JSON='{"command":"false"}' +JSON=$(cat <<'EOF' +{"command":"false"} +EOF +) BASE64=$(echo -n "$JSON" | base64) echo "JSON: $JSON" echo "Running command (should fail)..." @@ -76,7 +88,10 @@ echo # Test working directory feature echo "Test 5: Working directory" -JSON='{"command":"pwd","working_directory":"/tmp"}' +JSON=$(cat <<'EOF' +{"command":"pwd","working_directory":"/tmp"} +EOF +) BASE64=$(echo -n "$JSON" | base64) echo "JSON: $JSON" echo "Running command (should show /tmp)..."