Skip to content

Add live progress indicator to test runner - #256

Merged
lalinsky merged 1 commit into
mainfrom
test-runner-progress
Jan 29, 2026
Merged

lalinsky merged 1 commit into
mainfrom
test-runner-progress

Conversation

@lalinsky

Copy link
Copy Markdown
Owner

Summary

  • Shows real-time progress with test name and completion count when running tests in non-verbose mode
  • Long test names (>40 chars) are truncated to show the most specific part (last 40 characters)
  • Failed tests display error details immediately while progress continues
  • Progress automatically ends before showing the final summary

Example Output

In non-verbose mode, you'll see:

Running tests [42/328] test.name.here

When a test fails, error details are shown and progress continues:

Running tests [42/328] failing.test
================================================================================
"failing.test" - TestExpectedEqual
(error details and stack trace)
================================================================================
Running tests [43/328] next.test

Benefits

  • Real-time feedback on which test is currently running
  • Easy to identify slow tests or hangs
  • Cleaner output - passing tests don't clutter the terminal
  • Overall progress visibility

Shows real-time progress with test name and completion count in non-verbose mode.
Long test names are truncated to show the last 40 characters (most specific part).
Failed tests display error details immediately while progress continues.
@coderabbitai

coderabbitai Bot commented Jan 29, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The test runner now counts runnable tests before execution, displays progress in non-verbose mode using a progress root node, updates per-test completion status and names dynamically, and manages error reporting flow consistently. Forty-eight lines added, five removed.

Changes

Cohort / File(s) Summary
Test Runner Progress Tracking
test_runner.zig
Added pre-pass to count runnable tests excluding setup/teardown; introduced std.Progress node when not verbose; added per-test progress updates (setCompletedItems, setName) with test_index incrementing; ensured progress termination before final summary; adjusted error reporting path with captured logs and stack traces for non-verbose mode.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

Tests march forward, one by one 🧪
Progress counts what must be done
No verbose noise, just steady pace—
Each test updates in its place ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly matches the main change—adding a live progress indicator to the test runner, which is the core objective of this PR.
Description check ✅ Passed The description clearly explains what the feature does, provides concrete examples with expected output, and articulates specific benefits. It's directly related to the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test-runner-progress

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@test_runner.zig`:
- Around line 164-176: The progress counter currently calls
root_node.setCompletedItems(test_index) before test_index is incremented,
causing test 1 to display as 0/total; update the call so the displayed completed
count is 1-based by passing test_index + 1 (or incrementing test_index before
calling setCompletedItems). Specifically adjust the use of
root_node.setCompletedItems(test_index) in the block that also computes
display_name/friendly_name so it uses test_index + 1 to reflect the currently
running test.

Comment thread test_runner.zig
Comment on lines +164 to +176
// Update progress
if (root_node.index != .none) {
root_node.setCompletedItems(test_index);
// Progress truncates at 40 chars, so show the end of long names
const display_name = if (friendly_name.len <= std.Progress.Node.max_name_len)
friendly_name
else
friendly_name[friendly_name.len - std.Progress.Node.max_name_len ..];
root_node.setName(display_name);
}

test_index += 1;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

fd test_runner.zig --type f

Repository: lalinsky/zio

Length of output: 71


🏁 Script executed:

wc -l test_runner.zig

Repository: lalinsky/zio

Length of output: 75


🏁 Script executed:

sed -n '150,190p' test_runner.zig

Repository: lalinsky/zio

Length of output: 1333


🏁 Script executed:

# Search for where test_index is declared and initialized
rg 'test_index' test_runner.zig -B 2 -A 2

Repository: lalinsky/zio

Length of output: 531


🏁 Script executed:

# Look for any examples or documentation about the progress display format
rg 'setCompletedItems|setName' test_runner.zig -B 3 -A 3

Repository: lalinsky/zio

Length of output: 557


🏁 Script executed:

# Search for any README or documentation that might explain the expected UX
fd 'README|CHANGELOG|\.md' --type f | head -20

Repository: lalinsky/zio

Length of output: 212


🏁 Script executed:

# Look for any git history or PR mentions about progress display
git log --oneline test_runner.zig | head -10

Repository: lalinsky/zio

Length of output: 106


🏁 Script executed:

# Search for progress-related output or display formatting
rg 'Progress|progress' test_runner.zig -B 2 -A 2

Repository: lalinsky/zio

Length of output: 1094


🏁 Script executed:

# Check if there's any documentation about the test runner's output
grep -r 'progress\|counter' docs/ README.md --include='*.md' -i

Repository: lalinsky/zio

Length of output: 138


🏁 Script executed:

# Look for any test output examples or expected behavior documentation
grep -r '0/\|1/\|/total' . --include='*.md' --include='*.zig' 2>/dev/null | head -20

Repository: lalinsky/zio

Length of output: 977


🏁 Script executed:

# Check the exact context around where root_node is created and configured
sed -n '90,180p' test_runner.zig

Repository: lalinsky/zio

Length of output: 2827


🏁 Script executed:

# Look for any Zig std.Progress documentation in the repo or examples
rg 'std.Progress' . --include='*.zig' -A 5 -B 1 | head -40

Repository: lalinsky/zio

Length of output: 497


🏁 Script executed:

# Check the commit that added progress indicator for context
git show 8501a88 --stat

Repository: lalinsky/zio

Length of output: 7080


🏁 Script executed:

# Search for any test output examples or expected format strings
rg 'fmt|print' test_runner.zig | grep -i 'progress\|counter\|test' -A 2 -B 2

Repository: lalinsky/zio

Length of output: 922


🏁 Script executed:

# Look at how the progress output is formatted and if there's display logic
sed -n '1,50p' test_runner.zig | grep -E 'import|use|Progress'

Repository: lalinsky/zio

Length of output: 119


🏁 Script executed:

# Look for any documentation about what the progress display should show
git show 8501a88 test_runner.zig | grep -A 30 -B 5 'setCompletedItems'

Repository: lalinsky/zio

Length of output: 1173


🏁 Script executed:

# Search for any output examples or screenshots in the repo
find . -type f \( -name '*.md' -o -name '*.txt' \) -exec grep -l 'Running tests\|[0-9]/[0-9]' {} \;

Repository: lalinsky/zio

Length of output: 38


🏁 Script executed:

# Check Zig's std.Progress API documentation through comments in code
rg 'Progress' test_runner.zig -B 10 -A 10

Repository: lalinsky/zio

Length of output: 1433


🏁 Script executed:

# Look for any usage patterns of setCompletedItems in similar code
rg 'setCompletedItems' . -t zig

Repository: lalinsky/zio

Length of output: 126


🏁 Script executed:

# Check if there are any test output logs or examples in CI/workflows
find .github -name '*.yml' -o -name '*.yaml' | xargs grep -l 'test' 2>/dev/null | head -3

Repository: lalinsky/zio

Length of output: 143


🏁 Script executed:

# Let's check if there's a way to understand std.Progress semantics from Zig stdlib
# Look for comments or documentation
rg 'setCompletedItems' /usr/lib/zig --type zig 2>/dev/null | head -20

Repository: lalinsky/zio

Length of output: 38


🏁 Script executed:

# Try to find Zig's std library or check online documentation patterns
# Let's at least verify the exact behavior by understanding test flow more
# Count how many tests would be in test_count
sed -n '90,150p' test_runner.zig

Repository: lalinsky/zio

Length of output: 1889


🏁 Script executed:

# Check if there's any example output or progress format visible in docs
cat README.md | grep -i 'progress\|test\|running' -A 3 -B 1

Repository: lalinsky/zio

Length of output: 512


🏁 Script executed:

# Let's trace through what a user would see - look at the complete loop
sed -n '155,200p' test_runner.zig

Repository: lalinsky/zio

Length of output: 1372


🏁 Script executed:

# Let's check how Zig's Progress displays work by looking at actual usage context
# Try to understand if setCompletedItems uses 0-based or reflects count of completed items
python3 << 'EOF'
# Analysis: Understanding std.Progress semantics
# The key question: does setCompletedItems(n) mean:
# a) n items have completed (so 0 = none done, first test shows "0/total")
# b) showing progress for item n (so 0 = first item, but display should be 1-based)

# Standard UX convention in progress bars:
# - Most tools show "Processing item 1/10", "Processing item 2/10"
# - When you see "0/10", it typically means "0 items completed"
# - For a running test, users expect "1/10" not "0/10"

# In this code:
# test_index = 0 initially
# Loop iteration 1: setCompletedItems(0) called, THEN test_index += 1
# Loop iteration 2: setCompletedItems(1) called, THEN test_index += 1

# Result: First test shows "0/total" (0 completed)
# This is technically correct if you're counting "completed" items
# But confusing for users expecting "1/total" for "test 1 running"

print("Current behavior: Displays 0/total while test `#1` is running")
print("Expected behavior (per reviewer): Display 1/total while test `#1` is running")
print("\nThe semantic issue:")
print("- setCompletedItems might mean 'items completed so far'")
print("- But contextually, showing test `#1` as '0/total' is counterintuitive")
print("- Adding +1 would show '1/total', matching user expectations")
EOF

Repository: lalinsky/zio

Length of output: 397


🏁 Script executed:

# Try searching for any git comments or PR discussion about the counter
git log --all --grep='progress\|counter' --oneline 2>/dev/null | head -10

Repository: lalinsky/zio

Length of output: 686


🏁 Script executed:

# Look for any test output format or display examples
rg 'estimated_total_items|Running tests' test_runner.zig -B 5 -A 10

Repository: lalinsky/zio

Length of output: 462


Show 1-based test index in progress counter.

The progress display shows 0/total for the first running test because setCompletedItems is called with test_index before the increment. Most progress UIs display 1/total when test #1 is running, not 0/total. Bump the count by one:

Proposed fix
-            root_node.setCompletedItems(test_index);
+            root_node.setCompletedItems(test_index + 1);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Update progress
if (root_node.index != .none) {
root_node.setCompletedItems(test_index);
// Progress truncates at 40 chars, so show the end of long names
const display_name = if (friendly_name.len <= std.Progress.Node.max_name_len)
friendly_name
else
friendly_name[friendly_name.len - std.Progress.Node.max_name_len ..];
root_node.setName(display_name);
}
test_index += 1;
// Update progress
if (root_node.index != .none) {
root_node.setCompletedItems(test_index + 1);
// Progress truncates at 40 chars, so show the end of long names
const display_name = if (friendly_name.len <= std.Progress.Node.max_name_len)
friendly_name
else
friendly_name[friendly_name.len - std.Progress.Node.max_name_len ..];
root_node.setName(display_name);
}
test_index += 1;
🤖 Prompt for AI Agents
In `@test_runner.zig` around lines 164 - 176, The progress counter currently calls
root_node.setCompletedItems(test_index) before test_index is incremented,
causing test 1 to display as 0/total; update the call so the displayed completed
count is 1-based by passing test_index + 1 (or incrementing test_index before
calling setCompletedItems). Specifically adjust the use of
root_node.setCompletedItems(test_index) in the block that also computes
display_name/friendly_name so it uses test_index + 1 to reflect the currently
running test.

@lalinsky
lalinsky merged commit 2c758fc into main Jan 29, 2026
@lalinsky
lalinsky deleted the test-runner-progress branch January 29, 2026 10:13
@coderabbitai coderabbitai Bot mentioned this pull request Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant