Skip to content

Conversation

@MelbourneDeveloper
Copy link
Owner

@MelbourneDeveloper MelbourneDeveloper commented Jan 27, 2026

TLDR

Fixed critical bugs in test runner AND achieved 100% coverage in dart_node_mcp by fixing the coverage tool to merge data across test files.

What Does This Do?

1. Coverage Merging Fix (dart_node_mcp: <70% → 100%)

Problem: dart_node_coverage was only capturing 42/42 lines from server.dart, completely missing mcp_server.dart (111 lines) and stdio_transport.dart (6 lines). Total coverage was <70%.

Root Cause: Every test file called writeCoverageFile('coverage/coverage.json') in tearDownAll, overwriting each other's coverage data. The last test to finish would wipe out all previous coverage.

Fix: Modified dart_node_coverage/lib/src/runtime.dart to merge coverage data instead of overwriting:

  • Added readFileSync to read existing coverage before writing
  • Implemented _mergeData() to combine line execution counts across test runs
  • Now accumulates coverage from all test files: 159/159 lines = 100% coverage

2. Test Runner Fixes

Fixed two critical bugs in tools/test.sh:

  • Test failures now properly fail the build (exit code 1)
  • Test output is now visible in real-time while also being logged to files

Bug 1: Silent Failures
Parallel test runner spawned subshells that always exited with code 0. Fixed by adding explicit exit codes.

Bug 2: Hidden Output
All output redirected to log files only. Fixed using tee -a to stream to both terminal and files.

How Do The Tests Prove The Change Works?

Coverage Verification

cd packages/dart_node_mcp
dart run dart_node_coverage:coverage -- \
  --project-root . \
  --packages dart_node_mcp \
  --node-test-runner \
  --format lcov --output coverage/lcov.info

Results:

  • server.dart: 42/42 lines (100%)
  • mcp_server.dart: 111/111 lines (100%)
  • stdio_transport.dart: 6/6 lines (100%)
  • TOTAL: 159/159 lines = 100.0% coverage

Test Runner Verification

  • ./tools/test.sh --tier 1 - All tests pass, exit code 0
  • ./tools/test.sh --tier 2 - Fails properly on dart_node_react (needs Chrome), exit code 1 ✅
  • MIN_COVERAGE=99 ./tools/test.sh packages/reflux - Coverage failure detected, exit code 1 ✅
  • All test output now visible in terminal while saved to logs/*.log

🤖 Generated with Claude Code

@MelbourneDeveloper MelbourneDeveloper merged commit 41bd751 into main Jan 29, 2026
4 checks passed
@MelbourneDeveloper MelbourneDeveloper deleted the fix_tests_on_container branch January 29, 2026 10:06
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.

2 participants