Repository navigation
Add live progress indicator to test runner - #256
Conversation
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.
📝 WalkthroughWalkthroughThe 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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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.
| // 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; | ||
|
|
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
fd test_runner.zig --type fRepository: lalinsky/zio
Length of output: 71
🏁 Script executed:
wc -l test_runner.zigRepository: lalinsky/zio
Length of output: 75
🏁 Script executed:
sed -n '150,190p' test_runner.zigRepository: 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 2Repository: 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 3Repository: 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 -20Repository: 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 -10Repository: 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 2Repository: 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' -iRepository: 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 -20Repository: 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.zigRepository: 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 -40Repository: lalinsky/zio
Length of output: 497
🏁 Script executed:
# Check the commit that added progress indicator for context
git show 8501a88 --statRepository: 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 2Repository: 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 10Repository: lalinsky/zio
Length of output: 1433
🏁 Script executed:
# Look for any usage patterns of setCompletedItems in similar code
rg 'setCompletedItems' . -t zigRepository: 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 -3Repository: 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 -20Repository: 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.zigRepository: 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 1Repository: 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.zigRepository: 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")
EOFRepository: 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 -10Repository: 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 10Repository: 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.
| // 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.
Summary
Example Output
In non-verbose mode, you'll see:
When a test fails, error details are shown and progress continues:
Benefits