|
| 1 | +#!/usr/bin/env bash |
| 2 | +# filter-test-output.sh — Strip passing test indicators, keep failures and summaries |
| 3 | +# Pipe usage: test_command 2>&1 | bash filter-test-output.sh |
| 4 | +# |
| 5 | +# Supported: vitest, jest, mocha, pytest, go test, cargo test, rspec, |
| 6 | +# flutter/dart test, swift test, dotnet test, gradle/mvn test, |
| 7 | +# mix test, phpunit |
| 8 | +# Bypass: OMA_TEST_FILTER=0 |
| 9 | + |
| 10 | +if [[ "${OMA_TEST_FILTER:-1}" == "0" ]]; then |
| 11 | + cat |
| 12 | + exit 0 |
| 13 | +fi |
| 14 | + |
| 15 | +awk ' |
| 16 | + # vitest/jest/mocha: remove individual passing tests |
| 17 | + /^[[:space:]]*[✓√✔][[:space:]]/ { next } |
| 18 | +
|
| 19 | + # jest: remove PASS file headers |
| 20 | + /^[[:space:]]*PASS[[:space:]]/ { next } |
| 21 | +
|
| 22 | + # go test: remove passing tests and ok package lines |
| 23 | + /^--- PASS:/ { next } |
| 24 | + /^[[:space:]]*ok[[:space:]]+[a-zA-Z]/ { next } |
| 25 | +
|
| 26 | + # pytest: remove PASSED lines |
| 27 | + /PASSED[[:space:]]*$/ { next } |
| 28 | +
|
| 29 | + # cargo test: remove "test ... ok" lines |
| 30 | + /^test .+ \.\.\. ok$/ { next } |
| 31 | +
|
| 32 | + # flutter/dart: remove passing tests (+N without -N, excluding summary) |
| 33 | + /^[0-9][0-9]:[0-9][0-9] \+[0-9]+: / && !/\-[0-9]+/ && !/All tests/ { next } |
| 34 | +
|
| 35 | + # swift: remove passed test cases |
| 36 | + /Test Case .* passed/ { next } |
| 37 | +
|
| 38 | + # dotnet: remove individual Passed lines (keep "Passed!" summary) |
| 39 | + /^[[:space:]]*Passed[[:space:]]/ && !/Passed!/ { next } |
| 40 | +
|
| 41 | + # gradle/mvn: remove individual test pass indicators |
| 42 | + /^[[:space:]]*Tests run:.*Failures: 0.*Errors: 0/ { next } |
| 43 | +
|
| 44 | + # phpunit: remove dots-only progress lines |
| 45 | + /^[.]+$/ { next } |
| 46 | +
|
| 47 | + # rspec: remove passing example dots (single-char lines) |
| 48 | + /^[.]+[[:space:]]*$/ { next } |
| 49 | +
|
| 50 | + # keep everything else |
| 51 | + { print } |
| 52 | +' |
0 commit comments