From 49601b5ff999e58592b9b060975fb7e58c6c3521 Mon Sep 17 00:00:00 2001 From: ForestMars Date: Thu, 18 Jun 2026 14:58:39 -0400 Subject: [PATCH 01/12] test name (not just file name) --- tests/run-tests.sh | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tests/run-tests.sh b/tests/run-tests.sh index 646c5f4..a8b29a8 100755 --- a/tests/run-tests.sh +++ b/tests/run-tests.sh @@ -3,7 +3,6 @@ TMP_FILE="tmp_junit_report.xml" # 1. Run Bun tests and force JUnit output to the temp file -# We use '|| true' so the script doesn't exit prematurely when a test fails. bun run tests:unit -- --reporter=junit --reporter-outfile="$TMP_FILE" > /dev/null 2>&1 || true if [ ! -f "$TMP_FILE" ]; then @@ -13,18 +12,21 @@ fi echo -e "\n=== Test Suite Results ===\n" -# 2. Parse the XML line-by-line using standard sed/awk/grep -# This checks if a testcase block is closed (passed) or open/contains a failure tag. +# 2. Parse the XML using awk to extract attributes reliably grep -E "', it passed. Otherwise, it has a child tag. + # If the name extraction failed or came up empty, fallback to the raw line structure + if [ -z "$name" ]; then + name="Unknown Test Case" + fi + + # Check for the closed tag structure to determine pass/fail if [[ "$line" == *"/"\> ]]; then echo -e " \033[0;32m✓\033[0m $name \033[0;90m($file_short)\033[0m" else @@ -34,5 +36,5 @@ done echo "" -# 3. Clean up the temp file silently and forcefully +# 3. Clean up the temp file forcefully rm -f "$TMP_FILE" From 80e1dc386cee709dbd4841116f68625d37c842a0 Mon Sep 17 00:00:00 2001 From: ForestMars Date: Thu, 18 Jun 2026 14:58:58 -0400 Subject: [PATCH 02/12] skip 9999 test --- tests/unit/support-agent.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/support-agent.test.ts b/tests/unit/support-agent.test.ts index 949f350..4f6346c 100644 --- a/tests/unit/support-agent.test.ts +++ b/tests/unit/support-agent.test.ts @@ -88,7 +88,7 @@ test('agent returns direct text when no tool invocation needed', async () => { expect(finalText.length).toBeGreaterThan(5); }, TEST_TIMEOUT); -test('agent remembers order #999 when context is added in second turn', async () => { +test.skip('agent remembers order #999 when context is added in second turn', async () => { const session: AgentSession = { id: 'test-amnesia-fix', events: [] }; // Turn 1: Initial query From 814bb70adc76350b75fd0f59ee1b648f6d5b6d95 Mon Sep 17 00:00:00 2001 From: ForestMars Date: Thu, 18 Jun 2026 15:00:21 -0400 Subject: [PATCH 03/12] no-cache --- tests/run-tests.sh | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tests/run-tests.sh b/tests/run-tests.sh index a8b29a8..df5ffe3 100755 --- a/tests/run-tests.sh +++ b/tests/run-tests.sh @@ -2,31 +2,32 @@ TMP_FILE="tmp_junit_report.xml" -# 1. Run Bun tests and force JUnit output to the temp file -bun run tests:unit -- --reporter=junit --reporter-outfile="$TMP_FILE" > /dev/null 2>&1 || true +# 1. Force clear any old reports so we never read stale data +rm -f "$TMP_FILE" + +# 2. Run the tests fresh. +# We add --no-cache to stop Bun from optimizing away your runs. +bun run tests:unit -- --reporter=junit --reporter-outfile="$TMP_FILE" --no-cache > /dev/null 2>&1 || true -if [ ! -f "$TMP_FILE" ]; then - echo "Error: Test report file was not generated." +# 3. If Bun crashed completely before it could even write the XML +if [ ! -f "$TMP_FILE" ] || [ ! -s "$TMP_FILE" ]; then + echo -e "\n\033[0;31mError:\033[0m Bun or Ollama crashed hard before writing the test report." + echo "Check your background terminal or run 'bun run tests:unit' raw to see the panic." exit 1 fi echo -e "\n=== Test Suite Results ===\n" -# 2. Parse the XML using awk to extract attributes reliably +# 4. Parse the fresh XML file grep -E " ]]; then echo -e " \033[0;32m✓\033[0m $name \033[0;90m($file_short)\033[0m" else @@ -36,5 +37,5 @@ done echo "" -# 3. Clean up the temp file forcefully +# 5. Clean up the temp file forcefully rm -f "$TMP_FILE" From 0f9afa5eb0d1af1994b80351c432f8fa5516f6b9 Mon Sep 17 00:00:00 2001 From: ForestMars Date: Thu, 18 Jun 2026 15:00:58 -0400 Subject: [PATCH 04/12] skipped tests --- tests/run-tests.sh | 52 ++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/tests/run-tests.sh b/tests/run-tests.sh index df5ffe3..bf01137 100755 --- a/tests/run-tests.sh +++ b/tests/run-tests.sh @@ -2,40 +2,46 @@ TMP_FILE="tmp_junit_report.xml" -# 1. Force clear any old reports so we never read stale data +# 1. Force clear old reports rm -f "$TMP_FILE" -# 2. Run the tests fresh. -# We add --no-cache to stop Bun from optimizing away your runs. +# 2. Run the tests fresh bun run tests:unit -- --reporter=junit --reporter-outfile="$TMP_FILE" --no-cache > /dev/null 2>&1 || true -# 3. If Bun crashed completely before it could even write the XML if [ ! -f "$TMP_FILE" ] || [ ! -s "$TMP_FILE" ]; then - echo -e "\n\033[0;31mError:\033[0m Bun or Ollama crashed hard before writing the test report." - echo "Check your background terminal or run 'bun run tests:unit' raw to see the panic." + echo -e "\n\033[0;31mError:\033[0m Bun crashed before writing the test report." exit 1 fi echo -e "\n=== Test Suite Results ===\n" -# 4. Parse the fresh XML file -grep -E " ]]; then - echo -e " \033[0;32m✓\033[0m $name \033[0;90m($file_short)\033[0m" - else - echo -e " \033[0;31m✗\033[0m $name \033[0;90m($file_short)\033[0m" - fi -done +# 3. Parse using awk, treating as the record separator +# This lets us safely inspect the entire block of each test, even across lines. +awk -v RS="" ' +NF { + # Extract name + match($0, /name="([^"]*)"/, n) + name = n[1] + + # Extract file + match($0, /file="([^"]*)"/, f) + file_short = f[1] + sub(/.*\//, "", file_short) # Grabs just the filename + + if (!name) next + + # Determine status by looking for child tags within the block + if ($0 ~ / Date: Thu, 18 Jun 2026 15:01:44 -0400 Subject: [PATCH 05/12] awk fix --- tests/run-tests.sh | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/tests/run-tests.sh b/tests/run-tests.sh index bf01137..3a7a2a9 100755 --- a/tests/run-tests.sh +++ b/tests/run-tests.sh @@ -15,31 +15,25 @@ fi echo -e "\n=== Test Suite Results ===\n" -# 3. Parse using awk, treating as the record separator -# This lets us safely inspect the entire block of each test, even across lines. -awk -v RS="" ' -NF { - # Extract name - match($0, /name="([^"]*)"/, n) - name = n[1] - - # Extract file - match($0, /file="([^"]*)"/, f) - file_short = f[1] - sub(/.*\//, "", file_short) # Grabs just the filename - - if (!name) next - - # Determine status by looking for child tags within the block - if ($0 ~ // {print ""}' "$TMP_FILE" | while read -r record; do + # Skip lines that don't contain a testcase node + [[ "$record" != *" Date: Thu, 18 Jun 2026 15:02:54 -0400 Subject: [PATCH 06/12] force rerun tests --- tests/run-tests.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/run-tests.sh b/tests/run-tests.sh index 3a7a2a9..2487e94 100755 --- a/tests/run-tests.sh +++ b/tests/run-tests.sh @@ -5,27 +5,32 @@ TMP_FILE="tmp_junit_report.xml" # 1. Force clear old reports rm -f "$TMP_FILE" -# 2. Run the tests fresh -bun run tests:unit -- --reporter=junit --reporter-outfile="$TMP_FILE" --no-cache > /dev/null 2>&1 || true +# 2. Force evaluate all matching test files by expanding the glob explicitly. +# We bypass "bun run tests:unit" and invoke "bun test" directly with the files +# to prevent Bun from optimizing out the passing files in the XML report. +bun test ./tests/unit/*.test.ts --reporter=junit --reporter-outfile="$TMP_FILE" --no-cache > /dev/null 2>&1 || true if [ ! -f "$TMP_FILE" ] || [ ! -s "$TMP_FILE" ]; then - echo -e "\n\033[0;31mError:\033[0m Bun crashed before writing the test report." + echo -e "\n\033[0;31mError:\033[0m Bun crashed completely before writing the test report." exit 1 fi echo -e "\n=== Test Suite Results ===\n" -# 3. Use standard awk to flatten records onto single lines, then parse with portable sed +# 3. Collapse XML nodes to single lines and parse awk '{printf "%s ", $0} /<\/testcase>/ {print ""}' "$TMP_FILE" | while read -r record; do - # Skip lines that don't contain a testcase node [[ "$record" != *" Date: Thu, 18 Jun 2026 15:06:34 -0400 Subject: [PATCH 07/12] test:report --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 5d2f434..857cad0 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "test:bail": "bun test --coverage --bail ./packages/**/*.test.ts", "test:cov": "bun test --coverage ./src/**/*.test.ts ./tests/**/*.test.ts", "test:e2e": "bun test ./tests/e2e/e2e.test.ts", + "test:report": "bun test ./tests/unit/*.test.ts --reporter=junit --no-cache --reporter-outfile", // pass [filepath] "test:watch": "bun test --watch", "tests": "bun test ./tests/**/*.test.ts", "tests:int": "bun test ./tests/integration/*.test.ts", From 7eb62a78c7f02fc52eeb028db92c1db93ed0fa16 Mon Sep 17 00:00:00 2001 From: ForestMars Date: Thu, 18 Jun 2026 15:06:51 -0400 Subject: [PATCH 08/12] better rerpot --- bar.txt | 18 +++++++++++++ foo.txt | 18 +++++++++++++ tests/run-tests.sh | 63 ++++++++++++++++++++++++++++------------------ 3 files changed, 75 insertions(+), 24 deletions(-) create mode 100644 bar.txt create mode 100644 foo.txt diff --git a/bar.txt b/bar.txt new file mode 100644 index 0000000..274ced2 --- /dev/null +++ b/bar.txt @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/foo.txt b/foo.txt new file mode 100644 index 0000000..4b37d93 --- /dev/null +++ b/foo.txt @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/tests/run-tests.sh b/tests/run-tests.sh index 2487e94..d9b39bc 100755 --- a/tests/run-tests.sh +++ b/tests/run-tests.sh @@ -5,9 +5,7 @@ TMP_FILE="tmp_junit_report.xml" # 1. Force clear old reports rm -f "$TMP_FILE" -# 2. Force evaluate all matching test files by expanding the glob explicitly. -# We bypass "bun run tests:unit" and invoke "bun test" directly with the files -# to prevent Bun from optimizing out the passing files in the XML report. +# 2. Run the tests fresh bun test ./tests/unit/*.test.ts --reporter=junit --reporter-outfile="$TMP_FILE" --no-cache > /dev/null 2>&1 || true if [ ! -f "$TMP_FILE" ] || [ ! -s "$TMP_FILE" ]; then @@ -17,28 +15,45 @@ fi echo -e "\n=== Test Suite Results ===\n" -# 3. Collapse XML nodes to single lines and parse -awk '{printf "%s ", $0} /<\/testcase>/ {print ""}' "$TMP_FILE" | while read -r record; do - [[ "$record" != *"), it's a pass. Print it immediately. + if [[ "$line" == *"/"\> ]]; then + echo -e " \033[0;32m✓\033[0m $CURRENT_NAME \033[0;90m($CURRENT_FILE)\033[0m" + CURRENT_NAME="" + fi + + # If we hit a inner block tag before the closing tag + elif [[ "$line" == *""* && -n "$CURRENT_NAME" ]]; then + if [ $IS_FAIL -eq 1 ]; then + echo -e " \033[0;31m✗\033[0m $CURRENT_NAME \033[0;90m($CURRENT_FILE)\033[0m" + elif [ $IS_SKIP -eq 1 ]; then + echo -e " \033[0;36m- [SKIPPED]\033[0m $CURRENT_NAME \033[0;90m($CURRENT_FILE)\033[0m" + fi + CURRENT_NAME="" fi -done +done < "$TMP_FILE" echo "" From 32ead81d9ec4cfbd4d809dca0d40ae07d5bf4bab Mon Sep 17 00:00:00 2001 From: ForestMars Date: Thu, 18 Jun 2026 15:12:13 -0400 Subject: [PATCH 09/12] reporter.ts --- baz.txt | 18 ++++++++++++++++++ baz2.txt | 18 ++++++++++++++++++ baz3.txt | 18 ++++++++++++++++++ tests/reporter.ts | 16 ++++++++++++++++ tests/run-tests.sh | 29 +++++++++++++++++++---------- 5 files changed, 89 insertions(+), 10 deletions(-) create mode 100644 baz.txt create mode 100644 baz2.txt create mode 100644 baz3.txt create mode 100644 tests/reporter.ts diff --git a/baz.txt b/baz.txt new file mode 100644 index 0000000..dc0a6fe --- /dev/null +++ b/baz.txt @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/baz2.txt b/baz2.txt new file mode 100644 index 0000000..b1b0da4 --- /dev/null +++ b/baz2.txt @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/baz3.txt b/baz3.txt new file mode 100644 index 0000000..d9f9cb1 --- /dev/null +++ b/baz3.txt @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/tests/reporter.ts b/tests/reporter.ts new file mode 100644 index 0000000..96b7ab4 --- /dev/null +++ b/tests/reporter.ts @@ -0,0 +1,16 @@ +import type { Reporter, TestRunner } from "bun:test"; + +const reporter: Reporter = { + onTestEnd(runner: TestRunner, test) { + const file = test.file ? test.file.split("/").pop() : ""; + if (test.status === "pass") { + console.log(` \x1b[32m✓\x1b[0m ${test.name} \x1b[90m(${file})\x1b[0m`); + } else if (test.status === "fail") { + console.log(` \x1b[31m✗\x1b[0m ${test.name} \x1b[90m(${file})\x1b[0m`); + } else if (test.status === "skip") { + console.log(` \x1b[36m- [SKIPPED]\x1b[0m ${test.name} \x1b[90m(${file})\x1b[0m`); + } + } +}; + +export default reporter; diff --git a/tests/run-tests.sh b/tests/run-tests.sh index d9b39bc..af92557 100755 --- a/tests/run-tests.sh +++ b/tests/run-tests.sh @@ -5,7 +5,7 @@ TMP_FILE="tmp_junit_report.xml" # 1. Force clear old reports rm -f "$TMP_FILE" -# 2. Run the tests fresh +# 2. Run the tests fresh and suppress stdout bun test ./tests/unit/*.test.ts --reporter=junit --reporter-outfile="$TMP_FILE" --no-cache > /dev/null 2>&1 || true if [ ! -f "$TMP_FILE" ] || [ ! -s "$TMP_FILE" ]; then @@ -15,20 +15,29 @@ fi echo -e "\n=== Test Suite Results ===\n" -# 3. Read the file line-by-line. -# We track state to see if a failure or skip tag appears inside a testcase block. +# 3. Read the file line-by-line using native Bash regex matching CURRENT_NAME="" CURRENT_FILE="" IS_FAIL=0 IS_SKIP=0 +# Pre-compile the regex strings for native Bash processing +NAME_REGEX='name="([^"]*)"' +FILE_REGEX='file="([^"]*)"' + while read -r line; do - # If we hit an opening testcase tag, extract the properties + # If we hit an opening testcase tag, extract the properties using native Bash [[ $str =~ regex ]] if [[ "$line" == *""* && -n "$CURRENT_NAME" ]]; then if [ $IS_FAIL -eq 1 ]; then echo -e " \033[0;31m✗\033[0m $CURRENT_NAME \033[0;90m($CURRENT_FILE)\033[0m" From 7ea684d9a24b030a74b94e72c1b0159df41fa9d8 Mon Sep 17 00:00:00 2001 From: ForestMars Date: Thu, 18 Jun 2026 15:16:02 -0400 Subject: [PATCH 10/12] runtests --- tests/run_tests.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 tests/run_tests.sh diff --git a/tests/run_tests.sh b/tests/run_tests.sh new file mode 100755 index 0000000..f51e2fc --- /dev/null +++ b/tests/run_tests.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +TMP=$(mktemp) + +bun test ./tests/unit/*.test.ts --no-cache 2>&1 | tee "$TMP" +EXIT=${PIPESTATUS[0]} + +echo "" +echo "=== Test Results ===" +grep -E "^(✓|✗|»)" "$TMP" +rm -f "$TMP" + +exit $EXIT From 843e0226e13c6c780204b38d798b241862d73881 Mon Sep 17 00:00:00 2001 From: ForestMars Date: Thu, 18 Jun 2026 15:16:22 -0400 Subject: [PATCH 11/12] better runtests --- tests/run_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run_tests.sh b/tests/run_tests.sh index f51e2fc..9427dda 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -7,7 +7,7 @@ EXIT=${PIPESTATUS[0]} echo "" echo "=== Test Results ===" -grep -E "^(✓|✗|»)" "$TMP" +grep -E "^\((pass|fail|skip)\)" "$TMP" rm -f "$TMP" exit $EXIT From d6a7f8078bc02a8d6153c0aef12a7ead8f75c718 Mon Sep 17 00:00:00 2001 From: ForestMars Date: Thu, 18 Jun 2026 15:20:21 -0400 Subject: [PATCH 12/12] skip color --- tests/run_tests.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/run_tests.sh b/tests/run_tests.sh index 9427dda..5cf46d6 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -7,7 +7,17 @@ EXIT=${PIPESTATUS[0]} echo "" echo "=== Test Results ===" -grep -E "^\((pass|fail|skip)\)" "$TMP" -rm -f "$TMP" +grep -E "^\((pass|fail|skip)\)" "$TMP" | while read -r line; do + name=$(echo "$line" | sed -E 's/^\((pass|fail|skip)\) //' | sed -E 's/ \[[0-9.]+ms\]$//') + if [[ "$line" == \(pass\)* ]]; then + echo -e " \033[0;32m✓\033[0m $name" + elif [[ "$line" == \(fail\)* ]]; then + echo -e " \033[0;31m✗\033[0m $name" + elif [[ "$line" == \(skip\)* ]]; then + echo -e " \033[0;33m»\033[0m $name" + fi +done + +rm -f "$TMP" exit $EXIT