diff --git a/runner/test.sh b/runner/test.sh index 4770593..6b230b4 100755 --- a/runner/test.sh +++ b/runner/test.sh @@ -73,13 +73,15 @@ JSON=$(cat <<'EOF' {"command":"false"} EOF ) -BASE64=$(echo -n "$JSON" | base64) +BASE64=$(echo -n "$JSON" | base64 -w0) echo "JSON: $JSON" echo "Running command (should fail)..." -build/runner "$BASE64" || true +set +e # Temporarily disable exiting on error +build/runner "$BASE64" RC=$? +set -e # Re-enable exiting on error if [ $RC -ne 0 ]; then - echo "✅ Test 4 passed (command correctly reported failure)" + echo "✅ Test 4 passed (command correctly reported failure, exit code: $RC)" else echo "❌ Test 4 failed (command should have returned non-zero)" exit 1 @@ -92,7 +94,7 @@ JSON=$(cat <<'EOF' {"command":"pwd","working_directory":"/tmp"} EOF ) -BASE64=$(echo -n "$JSON" | base64) +BASE64=$(echo -n "$JSON" | base64 -w0) echo "JSON: $JSON" echo "Running command (should show /tmp)..." OUTPUT=$(build/runner "$BASE64") @@ -105,43 +107,42 @@ fi echo # Optional SSH test (disabled by default) -# Set ENABLE_SSH_TEST=1 to enable this test -if [ "${ENABLE_SSH_TEST}" = "1" ]; then - echo "Test 6: SSH to localhost (make sure SSH server is running and you can connect to localhost)" - if [ -f "examples/local_ssh.json" ]; then - echo "Using examples/local_ssh.json for the test..." - ./run.sh examples/local_ssh.json || { - echo "❌ Test 6 failed" - echo "Note: This test requires SSH server running on localhost and proper key-based authentication." - echo "Check your SSH configuration or disable this test." - exit 1 - } - echo "✅ Test 6 passed" - else - echo "❌ Test 6 failed: examples/local_ssh.json not found" +echo "Test 6: SSH to localhost (make sure SSH server is running and you can connect to localhost)" +if [ -f "examples/local_ssh.json" ]; then + echo "Using examples/local_ssh.json for the test..." + ./run.sh examples/local_ssh.json || { + echo "❌ Test 6 failed" + echo "Note: This test requires SSH server running on localhost and proper key-based authentication." + echo "Check your SSH configuration or disable this test." exit 1 - fi - echo - - echo "Test 7: SSH with working directory (make sure SSH server is running and you can connect to localhost)" - if [ -f "examples/ssh_working_dir.json" ]; then - echo "Using examples/ssh_working_dir.json for the test..." - OUTPUT=$(./run.sh examples/ssh_working_dir.json | grep "/tmp") - if [[ "$OUTPUT" == *"/tmp"* ]]; then - echo "✅ Test 7 passed (SSH command ran in the correct directory)" - else - echo "❌ Test 7 failed, directory was not changed correctly" - echo "Note: This test requires SSH server running on localhost and proper key-based authentication." - exit 1 - fi - else - echo "❌ Test 7 failed: examples/ssh_working_dir.json not found" - exit 1 - fi - echo + } + echo "✅ Test 6 passed" else - echo "Test 6-7: SSH tests disabled (set ENABLE_SSH_TEST=1 to enable)" - echo + echo "❌ Test 6 failed: examples/local_ssh.json not found" + exit 1 fi +echo + +echo "Test 7: SSH with working directory (make sure SSH server is running and you can connect to localhost)" +if [ -f "examples/ssh_working_dir.json" ]; then + echo "Using examples/ssh_working_dir.json for the test..." + OUTPUT=$(./run.sh examples/ssh_working_dir.json | grep "/tmp") + if [ $? -ne 0 ]; then + echo "❌ Test 7 failed, command did not run" + exit 1 + fi + + if [[ "$OUTPUT" == *"/tmp"* ]]; then + echo "✅ Test 7 passed (SSH command ran in the correct directory)" + else + echo "❌ Test 7 failed, directory was not changed correctly" + echo "Note: This test requires SSH server running on localhost and proper key-based authentication." + exit 1 + fi +else + echo "❌ Test 7 failed: examples/ssh_working_dir.json not found" + exit 1 +fi +echo echo "All tests passed! 🎉" \ No newline at end of file