Add test for parallel execution of 2-3 commands with sleep #124
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements a comprehensive test suite to validate that command-stream can successfully execute 2-3 commands with sleep inside in parallel, as requested in issue #22.
Test Implementation
Added
tests/parallel-sleep.test.mjscontaining 5 test cases that verify:2 parallel sleep commands - Validates that 2 commands with
sleep 0.5execute in parallel (~500ms total, not ~1000ms sequential)3 parallel sleep commands - Validates that 3 commands with
sleep 0.3execute in parallel (~300ms total, not ~900ms sequential)Mixed duration parallel sleep commands - Tests commands with different sleep durations (0.2s, 0.4s, 0.3s) execute in parallel, completing in ~400ms (longest duration) rather than ~900ms (sum of durations)
Parallel commands with output verification - Ensures parallel sleep commands that also produce output work correctly and maintain their output integrity
Individual execution context verification - Confirms that each parallel command maintains its own execution environment and variable scope
Technical Validation
Each test includes timing validation with tolerance ranges to account for system overhead while ensuring true parallelism:
Test Results
All tests pass successfully:
✅ 5 tests passed, 28 expectations validated
✅ Full test suite continues to pass (all existing functionality preserved)
Fixes #22
🤖 Generated with Claude Code