Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f27d2c353 |
No files matched your search
@@ -0,0 +1,141 @@
|
||||
name: Integration Tests
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [master]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
integration:
|
||||
name: integration (${{ matrix.os }})
|
||||
if: github.event_name == 'workflow_dispatch' || github.head_ref == 'develop'
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
|
||||
- name: Build release binary
|
||||
run: cargo build --release
|
||||
|
||||
- name: Install binary to PATH
|
||||
run: |
|
||||
sudo cp target/release/rtk /usr/local/bin/rtk
|
||||
rtk --version
|
||||
|
||||
- name: Install system tools (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
run: sudo apt-get install -y tree
|
||||
|
||||
- name: Install system tools (macOS)
|
||||
if: runner.os == 'macOS'
|
||||
run: brew install tree
|
||||
|
||||
- name: Install Python tools
|
||||
run: pip install ruff pytest mypy
|
||||
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: 'stable'
|
||||
|
||||
- name: Install Go tools
|
||||
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
||||
|
||||
- name: Run ignored integration tests
|
||||
run: cargo test --ignored
|
||||
|
||||
- name: Run smoke test suite
|
||||
run: |
|
||||
export RTK_REPORT_FILE="rtk-report.md"
|
||||
bash scripts/test-all.sh || true
|
||||
if [ ! -f "$RTK_REPORT_FILE" ]; then
|
||||
echo "Report file not generated"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Upload report
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: report-${{ matrix.os }}
|
||||
path: rtk-report.md
|
||||
|
||||
- name: Fail if tests failed
|
||||
run: grep -q ":x:" rtk-report.md && exit 1 || exit 0
|
||||
|
||||
comment:
|
||||
name: PR comment
|
||||
needs: integration
|
||||
if: always() && github.event_name == 'pull_request'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Download reports
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: report-*
|
||||
merge-multiple: false
|
||||
|
||||
- name: Build and post PR comment
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
PR_NUMBER="${{ github.event.pull_request.number }}"
|
||||
MARKER="<!-- rtk-integration-results -->"
|
||||
|
||||
# Parse each platform report into a combined comment
|
||||
{
|
||||
echo "${MARKER}"
|
||||
echo "## RTK Integration Test Results"
|
||||
echo ""
|
||||
echo "Commit: \`${{ github.event.pull_request.head.sha }}\`"
|
||||
echo ""
|
||||
|
||||
for dir in report-*/; do
|
||||
platform=$(echo "$dir" | sed 's/report-//;s/\///')
|
||||
report="${dir}rtk-report.md"
|
||||
if [ -f "$report" ]; then
|
||||
echo "### ${platform}"
|
||||
echo ""
|
||||
# Skip the HTML marker and title from individual reports
|
||||
tail -n +3 "$report"
|
||||
echo ""
|
||||
echo "---"
|
||||
echo ""
|
||||
else
|
||||
echo "### ${platform}"
|
||||
echo ""
|
||||
echo ":warning: Report not available (job may have failed to build)"
|
||||
echo ""
|
||||
echo "---"
|
||||
echo ""
|
||||
fi
|
||||
done
|
||||
} > combined-report.md
|
||||
|
||||
BODY=$(cat combined-report.md)
|
||||
|
||||
# Find existing comment with our marker
|
||||
COMMENT_ID=$(gh api "repos/${{ github.repository }}/issues/${PR_NUMBER}/comments" \
|
||||
--jq ".[] | select(.body | startswith(\"${MARKER}\")) | .id" 2>/dev/null | head -1)
|
||||
|
||||
if [ -n "$COMMENT_ID" ]; then
|
||||
gh api "repos/${{ github.repository }}/issues/comments/${COMMENT_ID}" \
|
||||
-X PATCH -f body="$BODY"
|
||||
else
|
||||
gh api "repos/${{ github.repository }}/issues/${PR_NUMBER}/comments" \
|
||||
-f body="$BODY"
|
||||
fi
|
||||
+15
-1
@@ -246,9 +246,23 @@ For how to write tests (fixtures, snapshots, token savings verification), see [d
|
||||
|------|-------|----------|
|
||||
| **Unit tests** | `#[cfg(test)] mod tests` in each module | `cargo test` |
|
||||
| **Snapshot tests** | `assert_snapshot!()` via `insta` crate | `cargo test` + `cargo insta review` |
|
||||
| **Smoke tests** | `scripts/test-all.sh` (69 assertions) | `bash scripts/test-all.sh` |
|
||||
| **Smoke tests** | `scripts/test-all.sh` (150+ assertions) | `bash scripts/test-all.sh` |
|
||||
| **Integration tests** | `#[ignore]` tests requiring installed binary | `cargo test --ignored` |
|
||||
|
||||
### Integration Test Requirement
|
||||
|
||||
New features **must** include smoke test coverage in `scripts/test-all.sh`. This script is executed by the CI integration workflow on every develop-to-master PR and can be triggered manually via workflow dispatch.
|
||||
|
||||
For new commands/filters, add at minimum:
|
||||
- `assert_help` for `--help` output
|
||||
- `assert_ok` for basic execution
|
||||
- `assert_contains` or `assert_output_contains` for expected output content
|
||||
|
||||
For pipeline/transparency-critical features, add:
|
||||
- Exit code propagation tests (exact code, not just non-zero)
|
||||
- Stdin/stderr transparency tests where applicable
|
||||
- Passthrough equivalence tests (compare with raw command output)
|
||||
|
||||
### Pre-Commit Gate (mandatory)
|
||||
|
||||
All three must pass before any PR:
|
||||
|
||||
+426
-11
@@ -11,6 +11,13 @@ FAIL=0
|
||||
SKIP=0
|
||||
FAILURES=()
|
||||
|
||||
# Section tracking (for layer report)
|
||||
CURRENT_SECTION=""
|
||||
SECTION_PASS=0
|
||||
SECTION_FAIL=0
|
||||
SECTION_SKIP=0
|
||||
SECTION_RESULTS=()
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
@@ -87,6 +94,24 @@ assert_help() {
|
||||
assert_contains "$name --help" "Usage:" "$@" --help
|
||||
}
|
||||
|
||||
assert_output_contains() {
|
||||
local name="$1"
|
||||
local needle="$2"
|
||||
shift 2
|
||||
local output
|
||||
output=$("$@" 2>&1) || true
|
||||
if echo "$output" | grep -q "$needle"; then
|
||||
PASS=$((PASS + 1))
|
||||
printf " ${GREEN}PASS${NC} %s\n" "$name"
|
||||
else
|
||||
FAIL=$((FAIL + 1))
|
||||
FAILURES+=("$name")
|
||||
printf " ${RED}FAIL${NC} %s\n" "$name"
|
||||
printf " expected: '%s'\n" "$needle"
|
||||
printf " got: %s\n" "$(echo "$output" | head -3)"
|
||||
fi
|
||||
}
|
||||
|
||||
skip_test() {
|
||||
local name="$1"
|
||||
local reason="$2"
|
||||
@@ -95,9 +120,29 @@ skip_test() {
|
||||
}
|
||||
|
||||
section() {
|
||||
# Finalize previous section stats
|
||||
if [[ -n "$CURRENT_SECTION" ]]; then
|
||||
local sp=$((PASS - SECTION_PASS))
|
||||
local sf=$((FAIL - SECTION_FAIL))
|
||||
local ss=$((SKIP - SECTION_SKIP))
|
||||
SECTION_RESULTS+=("${CURRENT_SECTION}|${sp}|${sf}|${ss}")
|
||||
fi
|
||||
CURRENT_SECTION="$1"
|
||||
SECTION_PASS=$PASS
|
||||
SECTION_FAIL=$FAIL
|
||||
SECTION_SKIP=$SKIP
|
||||
printf "\n${BOLD}${CYAN}── %s ──${NC}\n" "$1"
|
||||
}
|
||||
|
||||
finalize_sections() {
|
||||
if [[ -n "$CURRENT_SECTION" ]]; then
|
||||
local sp=$((PASS - SECTION_PASS))
|
||||
local sf=$((FAIL - SECTION_FAIL))
|
||||
local ss=$((SKIP - SECTION_SKIP))
|
||||
SECTION_RESULTS+=("${CURRENT_SECTION}|${sp}|${sf}|${ss}")
|
||||
fi
|
||||
}
|
||||
|
||||
# ── Preamble ─────────────────────────────────────────
|
||||
|
||||
RTK=$(command -v rtk || echo "")
|
||||
@@ -125,6 +170,7 @@ section "Version & Help"
|
||||
|
||||
assert_contains "rtk --version" "rtk" rtk --version
|
||||
assert_contains "rtk --help" "Usage:" rtk --help
|
||||
assert_fails "unknown command rejected" rtk nonexistent-cmd-xyz
|
||||
|
||||
# ── 2. Ls ────────────────────────────────────────────
|
||||
|
||||
@@ -230,7 +276,7 @@ assert_help "rtk cargo" rtk cargo
|
||||
|
||||
section "Curl (new)"
|
||||
|
||||
assert_contains "rtk curl JSON detect" "string" rtk curl https://httpbin.org/json
|
||||
assert_contains "rtk curl JSON detect" "slideshow" rtk curl https://httpbin.org/json
|
||||
assert_ok "rtk curl plain text" rtk curl https://httpbin.org/robots.txt
|
||||
assert_help "rtk curl" rtk curl
|
||||
|
||||
@@ -246,11 +292,13 @@ assert_help "rtk npx" rtk npx
|
||||
section "Pnpm"
|
||||
|
||||
assert_help "rtk pnpm" rtk pnpm
|
||||
assert_help "rtk pnpm build" rtk pnpm build
|
||||
assert_help "rtk pnpm typecheck" rtk pnpm typecheck
|
||||
|
||||
if command -v pnpm >/dev/null 2>&1; then
|
||||
assert_help "rtk pnpm build" rtk pnpm build
|
||||
assert_ok "rtk pnpm help" rtk pnpm help
|
||||
else
|
||||
skip_test "rtk pnpm build" "pnpm not installed"
|
||||
fi
|
||||
|
||||
# ── 10. Grep ─────────────────────────────────────────
|
||||
@@ -282,7 +330,7 @@ TMPJSON=$(mktemp /tmp/rtk-test-XXXXX.json)
|
||||
echo '{"name":"test","count":42,"items":[1,2,3]}' > "$TMPJSON"
|
||||
|
||||
assert_ok "rtk json file" rtk json "$TMPJSON"
|
||||
assert_contains "rtk json shows schema" "string" rtk json "$TMPJSON"
|
||||
assert_contains "rtk json shows content" "count" rtk json "$TMPJSON"
|
||||
|
||||
rm -f "$TMPJSON"
|
||||
|
||||
@@ -351,7 +399,7 @@ assert_ok "rtk init --show" rtk init --show
|
||||
section "Wget"
|
||||
|
||||
if command -v wget >/dev/null 2>&1; then
|
||||
assert_ok "rtk wget stdout" rtk wget https://httpbin.org/robots.txt -O
|
||||
assert_ok "rtk wget stdout" rtk wget https://httpbin.org/robots.txt -O -
|
||||
else
|
||||
skip_test "rtk wget" "wget not installed"
|
||||
fi
|
||||
@@ -464,6 +512,7 @@ fi
|
||||
section "Global flags"
|
||||
|
||||
assert_ok "rtk -u ls ." rtk -u ls .
|
||||
assert_ok "rtk -v verbose" rtk -v ls .
|
||||
assert_ok "rtk --skip-env npm --help" rtk --skip-env npm --help
|
||||
|
||||
# ── 32. CcEconomics ─────────────────────────────────
|
||||
@@ -483,10 +532,10 @@ assert_ok "rtk learn (no sessions)" rtk learn --since 0 2>&1 || true
|
||||
|
||||
section "Rewrite"
|
||||
|
||||
assert_contains "rewrite git status" "rtk git status" rtk rewrite "git status"
|
||||
assert_contains "rewrite cargo test" "rtk cargo test" rtk rewrite "cargo test"
|
||||
assert_contains "rewrite compound &&" "rtk git status" rtk rewrite "git status && cargo test"
|
||||
assert_contains "rewrite pipe preserves" "| head" rtk rewrite "git log | head"
|
||||
assert_output_contains "rewrite git status" "rtk git status" rtk rewrite "git status"
|
||||
assert_output_contains "rewrite cargo test" "rtk cargo test" rtk rewrite "cargo test"
|
||||
assert_output_contains "rewrite compound &&" "rtk git status" rtk rewrite "git status && cargo test"
|
||||
assert_output_contains "rewrite pipe preserves" "| head" rtk rewrite "git log | head"
|
||||
|
||||
section "Rewrite (#345: RTK_DISABLED skip)"
|
||||
|
||||
@@ -495,14 +544,14 @@ assert_fails "rewrite env RTK_DISABLED skip" rtk rewrit
|
||||
|
||||
section "Rewrite (#346: 2>&1 preserved)"
|
||||
|
||||
assert_contains "rewrite 2>&1 preserved" "2>&1" rtk rewrite "cargo test 2>&1 | head"
|
||||
assert_output_contains "rewrite 2>&1 preserved" "2>&1" rtk rewrite "cargo test 2>&1 | head"
|
||||
|
||||
section "Rewrite (#196: gh --json skip)"
|
||||
|
||||
assert_fails "rewrite gh --json skip" rtk rewrite "gh pr list --json number"
|
||||
assert_fails "rewrite gh --jq skip" rtk rewrite "gh api /repos --jq .name"
|
||||
assert_fails "rewrite gh --template skip" rtk rewrite "gh pr view 1 --template '{{.title}}'"
|
||||
assert_contains "rewrite gh normal works" "rtk gh pr list" rtk rewrite "gh pr list"
|
||||
assert_output_contains "rewrite gh normal works" "rtk gh pr list" rtk rewrite "gh pr list"
|
||||
|
||||
# ── 33. Verify ────────────────────────────────────────
|
||||
|
||||
@@ -562,12 +611,257 @@ fi
|
||||
|
||||
section "Hook check (#344)"
|
||||
|
||||
assert_contains "rtk init --show hook version" "version" rtk init --show
|
||||
assert_contains "rtk init --show configuration" "Configuration" rtk init --show
|
||||
|
||||
# ── 42. GitLab CLI ──────────────────────────────────
|
||||
|
||||
section "GitLab CLI (help only)"
|
||||
|
||||
assert_help "rtk glab" rtk glab
|
||||
|
||||
# ── 43. Dotnet / AWS / PostgreSQL ───────────────────
|
||||
|
||||
section "Dotnet / AWS (help only)"
|
||||
|
||||
assert_help "rtk dotnet" rtk dotnet
|
||||
assert_help "rtk aws" rtk aws
|
||||
|
||||
section "PostgreSQL (conditional)"
|
||||
|
||||
# psql uses disable_help_flag = true, so --help is forwarded to the real psql binary.
|
||||
if command -v psql &>/dev/null; then
|
||||
assert_help "rtk psql" rtk psql
|
||||
else
|
||||
skip_test "rtk psql" "psql not installed"
|
||||
fi
|
||||
|
||||
# ── 44. Jest / Format / Telemetry (help only) ──────
|
||||
|
||||
section "Jest (help only)"
|
||||
|
||||
assert_help "rtk jest" rtk jest
|
||||
|
||||
section "Format (help only)"
|
||||
|
||||
assert_help "rtk format" rtk format
|
||||
|
||||
section "Telemetry (help only)"
|
||||
|
||||
assert_help "rtk telemetry" rtk telemetry
|
||||
|
||||
# ── 45. Run ─────────────────────────────────────────
|
||||
|
||||
section "Run"
|
||||
|
||||
assert_contains "rtk run -c echo" "hello" rtk run -c "echo hello"
|
||||
assert_contains "rtk run positional" "hello" rtk run echo hello
|
||||
|
||||
# ── 46. Pipe ────────────────────────────────────────
|
||||
|
||||
section "Pipe"
|
||||
|
||||
assert_ok "rtk pipe --passthrough" bash -c 'echo "hello world" | rtk pipe --passthrough'
|
||||
assert_ok "rtk pipe --filter cargo-test" bash -c 'echo "test result: ok. 5 passed" | rtk pipe --filter cargo-test'
|
||||
|
||||
# ── 47. Session ─────────────────────────────────────
|
||||
|
||||
section "Session"
|
||||
|
||||
assert_ok "rtk session" rtk session
|
||||
|
||||
# ── 48. Trust & Hook Audit ──────────────────────────
|
||||
|
||||
section "Trust"
|
||||
|
||||
assert_ok "rtk trust --list" rtk trust --list
|
||||
|
||||
section "Hook Audit"
|
||||
|
||||
assert_ok "rtk hook-audit" rtk hook-audit
|
||||
|
||||
# ── 49. Gain reset ──────────────────────────────────
|
||||
|
||||
section "Gain reset"
|
||||
|
||||
RESET_DB=$(mktemp /tmp/rtk-reset-XXXXX.db)
|
||||
RTK_DB_PATH="$RESET_DB" rtk ls . >/dev/null 2>&1 || true
|
||||
assert_ok "rtk gain --reset --yes" env RTK_DB_PATH="$RESET_DB" rtk gain --reset --yes
|
||||
rm -f "$RESET_DB"
|
||||
|
||||
# ── 50. Npx routing ────────────────────────────────
|
||||
|
||||
section "Npx routing"
|
||||
|
||||
assert_contains "rtk npx routes to npx" "npx" rtk npx --help
|
||||
|
||||
# ── 51. Agent Permissions ───────────────────────────
|
||||
|
||||
section "Agent Permissions: Hook Check"
|
||||
|
||||
assert_contains "hook check claude" "rtk git status" rtk hook check --agent claude git status
|
||||
assert_contains "hook check cursor" "rtk cargo test" rtk hook check --agent cursor cargo test
|
||||
assert_contains "hook check gemini" "rtk git status" rtk hook check --agent gemini git status
|
||||
assert_fails "hook check unsupported" rtk hook check htop
|
||||
|
||||
section "Agent Permissions: Rewrite Exit Codes"
|
||||
|
||||
# Exit 0 (allow) or 3 (ask) both mean "rewrite found"
|
||||
code=0; rtk rewrite "git status" >/dev/null 2>&1 || code=$?
|
||||
if [ "$code" -eq 0 ] || [ "$code" -eq 3 ]; then
|
||||
PASS=$((PASS + 1))
|
||||
printf " ${GREEN}PASS${NC} rewrite found (exit %d)\n" "$code"
|
||||
else
|
||||
FAIL=$((FAIL + 1))
|
||||
FAILURES+=("rewrite found exit code")
|
||||
printf " ${RED}FAIL${NC} rewrite found: expected 0 or 3, got %d\n" "$code"
|
||||
fi
|
||||
assert_output_contains "rewrite output" "rtk git status" rtk rewrite "git status"
|
||||
assert_fails "rewrite passthrough (exit 1)" rtk rewrite "ssh user@host"
|
||||
|
||||
# Verify exact exit code 1 (not 2 or 3)
|
||||
code=0; rtk rewrite "htop" >/dev/null 2>&1 || code=$?
|
||||
if [ "$code" -eq 1 ]; then
|
||||
PASS=$((PASS + 1))
|
||||
printf " ${GREEN}PASS${NC} rewrite passthrough exit code is exactly 1\n"
|
||||
else
|
||||
FAIL=$((FAIL + 1))
|
||||
FAILURES+=("rewrite passthrough exit code")
|
||||
printf " ${RED}FAIL${NC} rewrite passthrough exit code: expected 1, got %d\n" "$code"
|
||||
fi
|
||||
|
||||
skip_test "rewrite deny (exit 2)" "requires deny rule in config"
|
||||
skip_test "rewrite ask (exit 3)" "requires ask rule in config"
|
||||
|
||||
section "Agent Permissions: Init (Isolated)"
|
||||
|
||||
TMPHOME=$(mktemp -d /tmp/rtk-init-XXXXX)
|
||||
mkdir -p "$TMPHOME/.claude" "$TMPHOME/.gemini"
|
||||
|
||||
assert_ok "init claude --global" env HOME="$TMPHOME" rtk init --agent claude --global
|
||||
assert_ok "init gemini --global" bash -c "HOME='$TMPHOME' rtk init --gemini --global </dev/null"
|
||||
assert_ok "init copilot" env HOME="$TMPHOME" rtk init --copilot
|
||||
assert_ok "init codex" env HOME="$TMPHOME" rtk init --codex
|
||||
assert_ok "init --uninstall (idempotent)" env HOME="$TMPHOME" rtk init --uninstall --global
|
||||
|
||||
rm -rf "$TMPHOME"
|
||||
|
||||
section "Agent Permissions: Init Edge Cases"
|
||||
|
||||
assert_fails "init cursor (local, should fail)" rtk init --agent cursor
|
||||
|
||||
# ── 52. Transparency: Exit Codes ────────────────────
|
||||
|
||||
section "Transparency: Exit Codes"
|
||||
|
||||
assert_ok "exit 0 preserved" rtk proxy true
|
||||
assert_fails "exit 1 preserved" rtk proxy false
|
||||
|
||||
# Exact exit code propagation (42, not just non-zero)
|
||||
code=0; rtk proxy sh -c "exit 42" 2>/dev/null || code=$?
|
||||
if [ "$code" -eq 42 ]; then
|
||||
PASS=$((PASS + 1))
|
||||
printf " ${GREEN}PASS${NC} exit 42 preserved (got %d)\n" "$code"
|
||||
else
|
||||
FAIL=$((FAIL + 1))
|
||||
FAILURES+=("exit 42 preserved")
|
||||
printf " ${RED}FAIL${NC} exit 42 preserved (expected 42, got %d)\n" "$code"
|
||||
fi
|
||||
|
||||
section "Transparency: Std Channels"
|
||||
|
||||
# Stderr not swallowed (use proxy, which preserves raw output)
|
||||
err_output=$(rtk proxy sh -c "echo ERR_MARKER >&2; echo OK" 2>&1)
|
||||
if echo "$err_output" | grep -q "ERR_MARKER"; then
|
||||
PASS=$((PASS + 1))
|
||||
printf " ${GREEN}PASS${NC} stderr not swallowed\n"
|
||||
else
|
||||
FAIL=$((FAIL + 1))
|
||||
FAILURES+=("stderr not swallowed")
|
||||
printf " ${RED}FAIL${NC} stderr not swallowed (ERR_MARKER missing)\n"
|
||||
fi
|
||||
|
||||
assert_contains "stdout present" "hello" rtk proxy echo hello
|
||||
|
||||
# Stdin piping
|
||||
assert_ok "stdin read pipe" bash -c 'echo "fn main() {}" | rtk read -'
|
||||
assert_ok "stdin pipe passthrough" bash -c 'echo "hello" | rtk pipe --passthrough'
|
||||
assert_ok "stdin pipe filter" bash -c 'echo "test result: ok. 5 passed" | rtk pipe --filter cargo-test'
|
||||
|
||||
# No stdin hang (must exit quickly)
|
||||
timeout 5 rtk ls . >/dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
PASS=$((PASS + 1))
|
||||
printf " ${GREEN}PASS${NC} no stdin hang (ls exits quickly)\n"
|
||||
else
|
||||
FAIL=$((FAIL + 1))
|
||||
FAILURES+=("no stdin hang")
|
||||
printf " ${RED}FAIL${NC} no stdin hang (ls timed out)\n"
|
||||
fi
|
||||
|
||||
# Failing command stderr + exit code
|
||||
code=0; rtk proxy sh -c "echo FAIL >&2 && exit 1" 2>/dev/null || code=$?
|
||||
if [ "$code" -eq 1 ]; then
|
||||
PASS=$((PASS + 1))
|
||||
printf " ${GREEN}PASS${NC} failing command preserves exit 1\n"
|
||||
else
|
||||
FAIL=$((FAIL + 1))
|
||||
FAILURES+=("failing command exit code")
|
||||
printf " ${RED}FAIL${NC} failing command exit code: expected 1, got %d\n" "$code"
|
||||
fi
|
||||
|
||||
# ── 53. Run Modes ───────────────────────────────────
|
||||
|
||||
section "Run Modes: Filtered"
|
||||
|
||||
# Filtered mode produces different (compressed) output vs raw command
|
||||
raw_ls=$(ls . 2>/dev/null | wc -c)
|
||||
rtk_ls=$(rtk ls . 2>/dev/null | wc -c)
|
||||
if [ "$rtk_ls" != "$raw_ls" ]; then
|
||||
PASS=$((PASS + 1))
|
||||
printf " ${GREEN}PASS${NC} filtered ls differs from raw (raw=%s, rtk=%s)\n" "$raw_ls" "$rtk_ls"
|
||||
else
|
||||
FAIL=$((FAIL + 1))
|
||||
FAILURES+=("filtered ls differs from raw")
|
||||
printf " ${RED}FAIL${NC} filtered ls same as raw (%s bytes)\n" "$raw_ls"
|
||||
fi
|
||||
assert_ok "filtered grep" rtk grep "fn main" src/
|
||||
|
||||
section "Run Modes: Streamed"
|
||||
|
||||
assert_ok "streamed err" rtk err echo ok
|
||||
assert_ok "streamed test" rtk test echo ok
|
||||
|
||||
section "Run Modes: Passthrough"
|
||||
|
||||
# Passthrough must produce identical output to raw command
|
||||
raw_head=$(git rev-parse HEAD 2>/dev/null)
|
||||
rtk_head=$(rtk git rev-parse HEAD 2>/dev/null)
|
||||
if [ "$raw_head" = "$rtk_head" ]; then
|
||||
PASS=$((PASS + 1))
|
||||
printf " ${GREEN}PASS${NC} passthrough git rev-parse HEAD matches raw\n"
|
||||
else
|
||||
FAIL=$((FAIL + 1))
|
||||
FAILURES+=("passthrough matches raw")
|
||||
printf " ${RED}FAIL${NC} passthrough mismatch: raw='%s' rtk='%s'\n" "$raw_head" "$rtk_head"
|
||||
fi
|
||||
|
||||
raw_remote=$(git remote -v 2>/dev/null)
|
||||
rtk_remote=$(rtk git remote -v 2>/dev/null)
|
||||
if [ "$raw_remote" = "$rtk_remote" ]; then
|
||||
PASS=$((PASS + 1))
|
||||
printf " ${GREEN}PASS${NC} passthrough git remote -v matches raw\n"
|
||||
else
|
||||
FAIL=$((FAIL + 1))
|
||||
FAILURES+=("passthrough git remote -v matches raw")
|
||||
printf " ${RED}FAIL${NC} passthrough mismatch for git remote -v\n"
|
||||
fi
|
||||
|
||||
# ══════════════════════════════════════════════════════
|
||||
# Report
|
||||
# ══════════════════════════════════════════════════════
|
||||
|
||||
finalize_sections
|
||||
|
||||
printf "\n${BOLD}══════════════════════════════════════${NC}\n"
|
||||
printf "${BOLD}Results: ${GREEN}%d passed${NC}, ${RED}%d failed${NC}, ${YELLOW}%d skipped${NC}\n" "$PASS" "$FAIL" "$SKIP"
|
||||
|
||||
@@ -580,4 +874,125 @@ fi
|
||||
|
||||
printf "${BOLD}══════════════════════════════════════${NC}\n"
|
||||
|
||||
# ── Layer Report (for CI PR comment) ──────────────────
|
||||
# Maps sections to layers and writes markdown to RTK_REPORT_FILE if set.
|
||||
|
||||
if [[ -n "${RTK_REPORT_FILE:-}" ]]; then
|
||||
declare -A LAYER_MAP
|
||||
# Layer 0: Binary Basics
|
||||
LAYER_MAP["Version & Help"]="L0: Binary Basics"
|
||||
# Layer 2: System Commands
|
||||
for s in "Ls" "Tree" "Read" "Read (stdin support)" "Grep" "Grep (extra args passthrough)" \
|
||||
"Find" "Json" "Json (edge cases)" "Deps" "Env" "Log" "Summary" "Wc" "Diff" "Smart"; do
|
||||
LAYER_MAP["$s"]="L2: System Commands"
|
||||
done
|
||||
# Layer 3: Git & VCS
|
||||
for s in "Git (existing)" "Git (new: branch, fetch, stash, worktree)" \
|
||||
"Git (passthrough: unsupported subcommands)" "GitHub CLI" "GitLab CLI (help only)" \
|
||||
"Graphite (conditional)"; do
|
||||
LAYER_MAP["$s"]="L3: Git & VCS"
|
||||
done
|
||||
# Layer 4: Cargo/Rust
|
||||
for s in "Cargo (new)" "Err" "Test runner"; do
|
||||
LAYER_MAP["$s"]="L4: Cargo/Rust"
|
||||
done
|
||||
# Layer 5: RTK Meta
|
||||
for s in "Gain" "Gain reset" "Config & Init" "CcEconomics" "Learn" "Discover" "Session"; do
|
||||
LAYER_MAP["$s"]="L5: RTK Meta"
|
||||
done
|
||||
# Layer 6: Hook System
|
||||
for s in "Rewrite" "Rewrite (#345: RTK_DISABLED skip)" "Rewrite (#346: 2>&1 preserved)" \
|
||||
"Rewrite (#196: gh --json skip)" "Verify" "Trust" "Hook Audit" "Hook check (#344)"; do
|
||||
LAYER_MAP["$s"]="L6: Hook System"
|
||||
done
|
||||
# Layer 7: Pipeline/Proxy
|
||||
for s in "Proxy" "Run" "Pipe"; do
|
||||
LAYER_MAP["$s"]="L7: Pipeline/Proxy"
|
||||
done
|
||||
# Layer 8: Network
|
||||
for s in "Curl (new)" "Wget"; do
|
||||
LAYER_MAP["$s"]="L8: Network"
|
||||
done
|
||||
# Layer 9: JS/TS
|
||||
for s in "Npm / Npx (new)" "Pnpm" "JS Tooling (help only, no project context)" \
|
||||
"Prisma (help only)" "Vitest (help only)" "Jest (help only)" "Npx routing"; do
|
||||
LAYER_MAP["$s"]="L9: JS/TS Ecosystem"
|
||||
done
|
||||
# Layer 10: Python
|
||||
LAYER_MAP["Python (conditional)"]="L10: Python"
|
||||
# Layer 11: Go
|
||||
LAYER_MAP["Go (conditional)"]="L11: Go"
|
||||
# Layer 12: Ruby/Dotnet/Cloud
|
||||
for s in "Ruby (conditional)" "Dotnet / AWS (help only)" "PostgreSQL (conditional)" \
|
||||
"Docker / Kubectl (help only)" "Docker (conditional)"; do
|
||||
LAYER_MAP["$s"]="L12: Ruby/Dotnet/Cloud"
|
||||
done
|
||||
# Layer 13: Agent Permissions
|
||||
for s in "Agent Permissions: Hook Check" "Agent Permissions: Rewrite Exit Codes" \
|
||||
"Agent Permissions: Init (Isolated)" "Agent Permissions: Init Edge Cases"; do
|
||||
LAYER_MAP["$s"]="L13: Agent Permissions"
|
||||
done
|
||||
# Layer 14: Transparency
|
||||
for s in "Transparency: Exit Codes" "Transparency: Std Channels"; do
|
||||
LAYER_MAP["$s"]="L14: Transparency"
|
||||
done
|
||||
# Layer 15: Run Modes
|
||||
for s in "Run Modes: Filtered" "Run Modes: Streamed" "Run Modes: Passthrough"; do
|
||||
LAYER_MAP["$s"]="L15: Run Modes"
|
||||
done
|
||||
# Layer 16: Global Flags
|
||||
LAYER_MAP["Global flags"]="L16: Global Flags"
|
||||
# Layer 1: Command Routing (help tests spread across sections)
|
||||
for s in "Format (help only)" "Telemetry (help only)"; do
|
||||
LAYER_MAP["$s"]="L1: Command Routing"
|
||||
done
|
||||
|
||||
# Aggregate per-layer
|
||||
declare -A LP LF LS
|
||||
for entry in "${SECTION_RESULTS[@]}"; do
|
||||
IFS='|' read -r sname sp sf ss <<< "$entry"
|
||||
lname="${LAYER_MAP[$sname]:-Other}"
|
||||
LP["$lname"]=$(( ${LP["$lname"]:-0} + sp ))
|
||||
LF["$lname"]=$(( ${LF["$lname"]:-0} + sf ))
|
||||
LS["$lname"]=$(( ${LS["$lname"]:-0} + ss ))
|
||||
done
|
||||
|
||||
# Write markdown report
|
||||
{
|
||||
printf "<!-- rtk-integration-results -->\n"
|
||||
printf "## RTK Integration Test Results\n\n"
|
||||
printf "**Binary**: \`%s\` | **Date**: %s\n\n" "$(rtk --version)" "$(date '+%Y-%m-%d %H:%M')"
|
||||
if [ "$FAIL" -eq 0 ]; then
|
||||
printf "**Status**: All tests passed\n\n"
|
||||
else
|
||||
printf "**Status**: %d failures detected\n\n" "$FAIL"
|
||||
fi
|
||||
printf "| Layer | Pass | Fail | Skip | Status |\n"
|
||||
printf "|-------|------|------|------|--------|\n"
|
||||
for lname in "L0: Binary Basics" "L1: Command Routing" "L2: System Commands" \
|
||||
"L3: Git & VCS" "L4: Cargo/Rust" "L5: RTK Meta" "L6: Hook System" \
|
||||
"L7: Pipeline/Proxy" "L8: Network" "L9: JS/TS Ecosystem" \
|
||||
"L10: Python" "L11: Go" "L12: Ruby/Dotnet/Cloud" \
|
||||
"L13: Agent Permissions" "L14: Transparency" "L15: Run Modes" \
|
||||
"L16: Global Flags"; do
|
||||
p=${LP["$lname"]:-0}
|
||||
f=${LF["$lname"]:-0}
|
||||
s=${LS["$lname"]:-0}
|
||||
if [ "$f" -eq 0 ]; then
|
||||
printf "| %s | %d | %d | %d | :white_check_mark: |\n" "$lname" "$p" "$f" "$s"
|
||||
else
|
||||
printf "| %s | %d | %d | %d | :x: |\n" "$lname" "$p" "$f" "$s"
|
||||
fi
|
||||
done
|
||||
printf "\n**Total**: %d passed, %d failed, %d skipped\n" "$PASS" "$FAIL" "$SKIP"
|
||||
if [[ ${#FAILURES[@]} -gt 0 ]]; then
|
||||
printf "\n<details><summary>Failures</summary>\n\n"
|
||||
for f in "${FAILURES[@]}"; do
|
||||
printf "- \`%s\`\n" "$f"
|
||||
done
|
||||
printf "\n</details>\n"
|
||||
fi
|
||||
} > "$RTK_REPORT_FILE"
|
||||
fi
|
||||
|
||||
exit "$FAIL"
|
||||
Reference in new issue
Block a user