fix: test_alpha.sh bugs — CLI output parsing + wait loop #156

Closed
opened 2026-02-27 21:14:48 +00:00 by Zeus · 0 comments
Collaborator

Problem

Running test_alpha.sh fails on every test with parse errors:

test_alpha.sh: line 145: [: ✓ Message sent to Alpha...: integer expression expected

Root Causes

  1. send_filedrop uses filedrop CLI which outputs colored ANSI text + status messages. The function captures this full output and tries to use it as a message ID for integer comparison in wait_for_response.

  2. wait_for_response polls TestRunner inbox but the elapsed comparison ([ "$elapsed" -lt "$timeout" ]) receives the full CLI output string instead of a clean integer.

Fix

Option A: Use filedrop CLI properly

  • Capture only the message ID from filedrop send output (parse the JSON filename)
  • Strip ANSI codes: filedrop send ... 2>&1 | sed "s/\x1b\[[0-9;]*m//g"

Option B: Write JSON directly (no CLI)

  • The send_filedrop function should write the JSON file directly to Alpha inbox instead of using the CLI
  • This avoids CLI output parsing entirely
  • Example:
send_filedrop() {
    local subject="$1" content="$2"
    local ts=$(date +%s)
    local id="${ts}_${SENDER}"
    local file="${AGENT_INBOX}/${id}.json"
    cat > "$file" <<< "{\"from\":\"$SENDER\",\"to\":\"$AGENT\",...}"
    echo "$id"  # Clean output for caller
}

Option B is preferred — simpler, no parsing needed, and the test controls exactly what gets sent.

Also needed

  • Ensure TestRunner is registered in /olymp/agents.json (added manually, should be part of test setup)
  • Test wait_for_response should check for files matching *Alpha* or *alpha* pattern

Ref: #143

## Problem Running `test_alpha.sh` fails on every test with parse errors: ``` test_alpha.sh: line 145: [: ✓ Message sent to Alpha...: integer expression expected ``` ## Root Causes 1. **`send_filedrop` uses `filedrop` CLI** which outputs colored ANSI text + status messages. The function captures this full output and tries to use it as a message ID for integer comparison in `wait_for_response`. 2. **`wait_for_response` polls TestRunner inbox** but the `elapsed` comparison (`[ "$elapsed" -lt "$timeout" ]`) receives the full CLI output string instead of a clean integer. ## Fix ### Option A: Use `filedrop` CLI properly - Capture only the message ID from `filedrop send` output (parse the JSON filename) - Strip ANSI codes: `filedrop send ... 2>&1 | sed "s/\x1b\[[0-9;]*m//g"` ### Option B: Write JSON directly (no CLI) - The `send_filedrop` function should write the JSON file directly to Alpha inbox instead of using the CLI - This avoids CLI output parsing entirely - Example: ```bash send_filedrop() { local subject="$1" content="$2" local ts=$(date +%s) local id="${ts}_${SENDER}" local file="${AGENT_INBOX}/${id}.json" cat > "$file" <<< "{\"from\":\"$SENDER\",\"to\":\"$AGENT\",...}" echo "$id" # Clean output for caller } ``` Option B is preferred — simpler, no parsing needed, and the test controls exactly what gets sent. ### Also needed - Ensure TestRunner is registered in `/olymp/agents.json` (added manually, should be part of test setup) - Test `wait_for_response` should check for files matching `*Alpha*` or `*alpha*` pattern Ref: #143
Zeus closed this issue 2026-02-27 21:16:00 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ultanio/cobot#156
No description provided.