This commit is contained in:
Your Name 2025-05-10 13:14:11 +12:00
parent a3914f8167
commit 4087b6e596

View File

@ -73,13 +73,15 @@ JSON=$(cat <<'EOF'
{"command":"false"} {"command":"false"}
EOF EOF
) )
BASE64=$(echo -n "$JSON" | base64) BASE64=$(echo -n "$JSON" | base64 -w0)
echo "JSON: $JSON" echo "JSON: $JSON"
echo "Running command (should fail)..." echo "Running command (should fail)..."
build/runner "$BASE64" || true set +e # Temporarily disable exiting on error
build/runner "$BASE64"
RC=$? RC=$?
set -e # Re-enable exiting on error
if [ $RC -ne 0 ]; then 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 else
echo "❌ Test 4 failed (command should have returned non-zero)" echo "❌ Test 4 failed (command should have returned non-zero)"
exit 1 exit 1
@ -92,7 +94,7 @@ JSON=$(cat <<'EOF'
{"command":"pwd","working_directory":"/tmp"} {"command":"pwd","working_directory":"/tmp"}
EOF EOF
) )
BASE64=$(echo -n "$JSON" | base64) BASE64=$(echo -n "$JSON" | base64 -w0)
echo "JSON: $JSON" echo "JSON: $JSON"
echo "Running command (should show /tmp)..." echo "Running command (should show /tmp)..."
OUTPUT=$(build/runner "$BASE64") OUTPUT=$(build/runner "$BASE64")
@ -105,8 +107,6 @@ fi
echo echo
# Optional SSH test (disabled by default) # 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)" 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 if [ -f "examples/local_ssh.json" ]; then
echo "Using examples/local_ssh.json for the test..." echo "Using examples/local_ssh.json for the test..."
@ -127,6 +127,11 @@ if [ "${ENABLE_SSH_TEST}" = "1" ]; then
if [ -f "examples/ssh_working_dir.json" ]; then if [ -f "examples/ssh_working_dir.json" ]; then
echo "Using examples/ssh_working_dir.json for the test..." echo "Using examples/ssh_working_dir.json for the test..."
OUTPUT=$(./run.sh examples/ssh_working_dir.json | grep "/tmp") 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 if [[ "$OUTPUT" == *"/tmp"* ]]; then
echo "✅ Test 7 passed (SSH command ran in the correct directory)" echo "✅ Test 7 passed (SSH command ran in the correct directory)"
else else
@ -139,9 +144,5 @@ if [ "${ENABLE_SSH_TEST}" = "1" ]; then
exit 1 exit 1
fi fi
echo echo
else
echo "Test 6-7: SSH tests disabled (set ENABLE_SSH_TEST=1 to enable)"
echo
fi
echo "All tests passed! 🎉" echo "All tests passed! 🎉"