Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Sep 9, 2025

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.mjs containing 5 test cases that verify:

  1. 2 parallel sleep commands - Validates that 2 commands with sleep 0.5 execute in parallel (~500ms total, not ~1000ms sequential)

  2. 3 parallel sleep commands - Validates that 3 commands with sleep 0.3 execute in parallel (~300ms total, not ~900ms sequential)

  3. 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)

  4. Parallel commands with output verification - Ensures parallel sleep commands that also produce output work correctly and maintain their output integrity

  5. 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:

  • Commands execute with different PIDs simultaneously
  • Total execution time matches the longest sleep duration (not cumulative)
  • All commands complete successfully with exit code 0
  • Output from parallel commands is properly captured and maintained

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

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #22
@konard konard self-assigned this Sep 9, 2025
konard and others added 2 commits September 9, 2025 22:32
Implements test for issue #22 that validates the ability to execute 2-3 commands with sleep inside in parallel. The test suite includes:

- 2 parallel sleep commands with timing validation
- 3 parallel sleep commands with timing validation
- Mixed duration sleep commands executed in parallel
- Parallel commands with output verification
- Individual execution context verification for parallel commands

All tests verify that commands execute truly in parallel (not sequentially) by measuring execution time and ensuring it matches the longest sleep duration rather than the sum of all sleep durations.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] Add test, that we can start 2-3 commands with sleep inside in parallel and for all to execute Add test for parallel execution of 2-3 commands with sleep Sep 9, 2025
@konard konard marked this pull request as ready for review September 9, 2025 19:37
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.

Add test, that we can start 2-3 commands with sleep inside in parallel and for all to execute

2 participants