Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions bar.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="bun test" tests="7" assertions="12" failures="1" skipped="1" time="0.098587">
<testsuite name="tests/unit/styles.test.ts" file="tests/unit/styles.test.ts" tests="4" assertions="6" failures="0" skipped="0" time="0" hostname="Forests-Air.lan">
<testcase name="friendly style summarizes order tool result" classname="" time="0.000326" file="tests/unit/styles.test.ts" line="8" assertions="2" />
<testcase name="formal style produces concise summary" classname="" time="0.000023" file="tests/unit/styles.test.ts" line="14" assertions="2" />
<testcase name="raw style returns raw data" classname="" time="0.000026" file="tests/unit/styles.test.ts" line="20" assertions="1" />
<testcase name="generic object summarization" classname="" time="0.0001" file="tests/unit/styles.test.ts" line="25" assertions="1" />
</testsuite>
<testsuite name="tests/unit/support-agent.test.ts" file="tests/unit/support-agent.test.ts" tests="3" assertions="6" failures="1" skipped="1" time="0.008" hostname="Forests-Air.lan">
<testcase name="agent calls entityLookupTool when LLM triggers tool path" classname="" time="0.00894" file="tests/unit/support-agent.test.ts" line="27" assertions="1">
<failure type="AssertionError" />
</testcase>
<testcase name="agent returns direct text when no tool invocation needed" classname="" time="0.000582" file="tests/unit/support-agent.test.ts" line="62" assertions="5" />
<testcase name="agent remembers order #999 when context is added in second turn" classname="" time="0" file="tests/unit/support-agent.test.ts" line="91" assertions="0">
<skipped />
</testcase>
</testsuite>
</testsuites>
18 changes: 18 additions & 0 deletions baz.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="bun test" tests="7" assertions="12" failures="1" skipped="1" time="0.099915">
<testsuite name="tests/unit/styles.test.ts" file="tests/unit/styles.test.ts" tests="4" assertions="6" failures="0" skipped="0" time="0" hostname="Forests-Air.lan">
<testcase name="friendly style summarizes order tool result" classname="" time="0" file="tests/unit/styles.test.ts" line="8" assertions="2" />
<testcase name="formal style produces concise summary" classname="" time="0.000667" file="tests/unit/styles.test.ts" line="14" assertions="2" />
<testcase name="raw style returns raw data" classname="" time="0.000027" file="tests/unit/styles.test.ts" line="20" assertions="1" />
<testcase name="generic object summarization" classname="" time="0.000079" file="tests/unit/styles.test.ts" line="25" assertions="1" />
</testsuite>
<testsuite name="tests/unit/support-agent.test.ts" file="tests/unit/support-agent.test.ts" tests="3" assertions="6" failures="1" skipped="1" time="0.008" hostname="Forests-Air.lan">
<testcase name="agent calls entityLookupTool when LLM triggers tool path" classname="" time="0.008312" file="tests/unit/support-agent.test.ts" line="27" assertions="1">
<failure type="AssertionError" />
</testcase>
<testcase name="agent returns direct text when no tool invocation needed" classname="" time="0.000539" file="tests/unit/support-agent.test.ts" line="62" assertions="5" />
<testcase name="agent remembers order #999 when context is added in second turn" classname="" time="0" file="tests/unit/support-agent.test.ts" line="91" assertions="0">
<skipped />
</testcase>
</testsuite>
</testsuites>
18 changes: 18 additions & 0 deletions baz2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="bun test" tests="7" assertions="12" failures="1" skipped="1" time="0.103077">
<testsuite name="tests/unit/styles.test.ts" file="tests/unit/styles.test.ts" tests="4" assertions="6" failures="0" skipped="0" time="0" hostname="Forests-Air.lan">
<testcase name="friendly style summarizes order tool result" classname="" time="0.000323" file="tests/unit/styles.test.ts" line="8" assertions="2" />
<testcase name="formal style produces concise summary" classname="" time="0.000046" file="tests/unit/styles.test.ts" line="14" assertions="2" />
<testcase name="raw style returns raw data" classname="" time="0.000029" file="tests/unit/styles.test.ts" line="20" assertions="1" />
<testcase name="generic object summarization" classname="" time="0.000092" file="tests/unit/styles.test.ts" line="25" assertions="1" />
</testsuite>
<testsuite name="tests/unit/support-agent.test.ts" file="tests/unit/support-agent.test.ts" tests="3" assertions="6" failures="1" skipped="1" time="0.008" hostname="Forests-Air.lan">
<testcase name="agent calls entityLookupTool when LLM triggers tool path" classname="" time="0.008547" file="tests/unit/support-agent.test.ts" line="27" assertions="1">
<failure type="AssertionError" />
</testcase>
<testcase name="agent returns direct text when no tool invocation needed" classname="" time="0.000557" file="tests/unit/support-agent.test.ts" line="62" assertions="5" />
<testcase name="agent remembers order #999 when context is added in second turn" classname="" time="0" file="tests/unit/support-agent.test.ts" line="91" assertions="0">
<skipped />
</testcase>
</testsuite>
</testsuites>
18 changes: 18 additions & 0 deletions baz3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="bun test" tests="7" assertions="12" failures="1" skipped="1" time="0.10086">
<testsuite name="tests/unit/styles.test.ts" file="tests/unit/styles.test.ts" tests="4" assertions="6" failures="0" skipped="0" time="0" hostname="Forests-Air.lan">
<testcase name="friendly style summarizes order tool result" classname="" time="0" file="tests/unit/styles.test.ts" line="8" assertions="2" />
<testcase name="formal style produces concise summary" classname="" time="0.000923" file="tests/unit/styles.test.ts" line="14" assertions="2" />
<testcase name="raw style returns raw data" classname="" time="0.000028" file="tests/unit/styles.test.ts" line="20" assertions="1" />
<testcase name="generic object summarization" classname="" time="0.000085" file="tests/unit/styles.test.ts" line="25" assertions="1" />
</testsuite>
<testsuite name="tests/unit/support-agent.test.ts" file="tests/unit/support-agent.test.ts" tests="3" assertions="6" failures="1" skipped="1" time="0.009" hostname="Forests-Air.lan">
<testcase name="agent calls entityLookupTool when LLM triggers tool path" classname="" time="0.009911" file="tests/unit/support-agent.test.ts" line="27" assertions="1">
<failure type="AssertionError" />
</testcase>
<testcase name="agent returns direct text when no tool invocation needed" classname="" time="0.000553" file="tests/unit/support-agent.test.ts" line="62" assertions="5" />
<testcase name="agent remembers order #999 when context is added in second turn" classname="" time="0" file="tests/unit/support-agent.test.ts" line="91" assertions="0">
<skipped />
</testcase>
</testsuite>
</testsuites>
18 changes: 18 additions & 0 deletions foo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="bun test" tests="7" assertions="12" failures="1" skipped="1" time="0.117321">
<testsuite name="tests/unit/styles.test.ts" file="tests/unit/styles.test.ts" tests="4" assertions="6" failures="0" skipped="0" time="0" hostname="Forests-Air.lan">
<testcase name="friendly style summarizes order tool result" classname="" time="0.000962" file="tests/unit/styles.test.ts" line="8" assertions="2" />
<testcase name="formal style produces concise summary" classname="" time="0.000296" file="tests/unit/styles.test.ts" line="14" assertions="2" />
<testcase name="raw style returns raw data" classname="" time="0.000045" file="tests/unit/styles.test.ts" line="20" assertions="1" />
<testcase name="generic object summarization" classname="" time="0.000096" file="tests/unit/styles.test.ts" line="25" assertions="1" />
</testsuite>
<testsuite name="tests/unit/support-agent.test.ts" file="tests/unit/support-agent.test.ts" tests="3" assertions="6" failures="1" skipped="1" time="0.009" hostname="Forests-Air.lan">
<testcase name="agent calls entityLookupTool when LLM triggers tool path" classname="" time="0.009205" file="tests/unit/support-agent.test.ts" line="27" assertions="1">
<failure type="AssertionError" />
</testcase>
<testcase name="agent returns direct text when no tool invocation needed" classname="" time="0.000545" file="tests/unit/support-agent.test.ts" line="62" assertions="5" />
<testcase name="agent remembers order #999 when context is added in second turn" classname="" time="0" file="tests/unit/support-agent.test.ts" line="91" assertions="0">
<skipped />
</testcase>
</testsuite>
</testsuites>
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 16 additions & 0 deletions tests/reporter.ts
Original file line number Diff line number Diff line change
@@ -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;
76 changes: 54 additions & 22 deletions tests/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,69 @@

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
# 1. Force clear old reports
rm -f "$TMP_FILE"

# 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" ]; then
echo "Error: Test report file was not generated."
if [ ! -f "$TMP_FILE" ] || [ ! -s "$TMP_FILE" ]; then
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"

# 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.
grep -E "<testcase" "$TMP_FILE" | while read -r line; do
# Extract the test name from the name="..." attribute
name=$(echo "$line" | sed -E 's/.*name="([^"]*)".*/\1/')
# Extract the file path
file=$(echo "$line" | sed -E 's/.*file="([^"]*)".*/\1/')
# 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 using native Bash [[ $str =~ regex ]]
if [[ "$line" == *"<testcase"* ]]; then

if [[ "$line" =~ $NAME_REGEX ]]; then
CURRENT_NAME="${BASH_REMATCH[1]}"
fi

if [[ "$line" =~ $FILE_REGEX ]]; then
FILE_PATH="${BASH_REMATCH[1]}"
CURRENT_FILE=$(basename "$FILE_PATH")
fi

IS_FAIL=0
IS_SKIP=0

# If the tag is self-closing (/>), 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

# Clean up the path format for readability
file_short=$(basename "$file")

# If the line ends with '/>', it passed. Otherwise, it has a child <failure> tag.
if [[ "$line" == *"/"\> ]]; 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"
# Check inner block states
elif [[ "$line" == *"<failure"* ]]; then
IS_FAIL=1
elif [[ "$line" == *"<skipped"* ]]; then
IS_SKIP=1

# When we hit the closing tag of an open block, print the collected metrics
elif [[ "$line" == *"</testcase>"* && -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 ""

# 3. Clean up the temp file silently and forcefully
# 4. Clean up
rm -f "$TMP_FILE"
23 changes: 23 additions & 0 deletions tests/run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/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 "^\((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
2 changes: 1 addition & 1 deletion tests/unit/support-agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading