|
397 | 397 | "$BINARY" config reset auto_index 2>/dev/null |
398 | 398 | echo "OK: config set/get/reset round-trip" |
399 | 399 |
|
| 400 | +# 6e: Simulated binary replacement (update flow without network) |
| 401 | +# Simulates the update command's Steps 3-6: extract, replace, verify. |
| 402 | +# Uses a copy of the test binary as the "downloaded" version. |
| 403 | +echo "--- Phase 6e: simulated binary replacement ---" |
| 404 | +REPLACE_DIR=$(mktemp -d) |
| 405 | +INSTALL_DIR="$REPLACE_DIR/install" |
| 406 | +mkdir -p "$INSTALL_DIR" |
| 407 | + |
| 408 | +# 1. Copy binary to "install dir" as the "currently installed" version |
| 409 | +cp "$BINARY" "$INSTALL_DIR/codebase-memory-mcp" |
| 410 | +chmod 755 "$INSTALL_DIR/codebase-memory-mcp" |
| 411 | + |
| 412 | +# Verify installed binary works |
| 413 | +INSTALLED_VER=$("$INSTALL_DIR/codebase-memory-mcp" --version 2>&1) |
| 414 | +if ! echo "$INSTALLED_VER" | grep -qE 'v?[0-9]+\.[0-9]+|dev'; then |
| 415 | + echo "FAIL: installed binary --version failed: $INSTALLED_VER" |
| 416 | + rm -rf "$REPLACE_DIR" |
| 417 | + exit 1 |
| 418 | +fi |
| 419 | + |
| 420 | +# 2. Copy binary as the "downloaded" new version |
| 421 | +cp "$BINARY" "$REPLACE_DIR/smoke-codebase-memory-mcp" |
| 422 | + |
| 423 | +# 3. Simulate cbm_replace_binary: unlink old, copy new |
| 424 | +rm -f "$INSTALL_DIR/codebase-memory-mcp" |
| 425 | +cp "$REPLACE_DIR/smoke-codebase-memory-mcp" "$INSTALL_DIR/codebase-memory-mcp" |
| 426 | +chmod 755 "$INSTALL_DIR/codebase-memory-mcp" |
| 427 | + |
| 428 | +# 4. Verify replaced binary works |
| 429 | +REPLACED_VER=$("$INSTALL_DIR/codebase-memory-mcp" --version 2>&1) |
| 430 | +if ! echo "$REPLACED_VER" | grep -qE 'v?[0-9]+\.[0-9]+|dev'; then |
| 431 | + echo "FAIL: replaced binary --version failed: $REPLACED_VER" |
| 432 | + rm -rf "$REPLACE_DIR" |
| 433 | + exit 1 |
| 434 | +fi |
| 435 | +echo "OK: binary replacement succeeded (version: $REPLACED_VER)" |
| 436 | + |
| 437 | +# 5. Test replacement of read-only binary (edge case — cbm_replace_binary |
| 438 | +# handles this via unlink-before-write, which works even on read-only files) |
| 439 | +chmod 444 "$INSTALL_DIR/codebase-memory-mcp" |
| 440 | +rm -f "$INSTALL_DIR/codebase-memory-mcp" |
| 441 | +cp "$REPLACE_DIR/smoke-codebase-memory-mcp" "$INSTALL_DIR/codebase-memory-mcp" |
| 442 | +chmod 755 "$INSTALL_DIR/codebase-memory-mcp" |
| 443 | +READONLY_VER=$("$INSTALL_DIR/codebase-memory-mcp" --version 2>&1) |
| 444 | +if ! echo "$READONLY_VER" | grep -qE 'v?[0-9]+\.[0-9]+|dev'; then |
| 445 | + echo "FAIL: read-only replacement --version failed: $READONLY_VER" |
| 446 | + rm -rf "$REPLACE_DIR" |
| 447 | + exit 1 |
| 448 | +fi |
| 449 | +echo "OK: read-only binary replacement succeeded" |
| 450 | + |
| 451 | +rm -rf "$REPLACE_DIR" |
| 452 | + |
400 | 453 | echo "" |
401 | 454 | echo "=== Phase 7: MCP advanced tool calls ===" |
402 | 455 |
|
|
0 commit comments