39 lines
2.4 KiB
Markdown
39 lines
2.4 KiB
Markdown
# P0 Process Test Environment Isolation
|
|
Task ID: X-BASE-01
|
|
Phase: P0
|
|
Status: APPROVED
|
|
|
|
## 1. Context and baseline
|
|
`tests/standalone/System/Process.cpp` currently invokes `/bin/echo`, `/bin/cat`, and `shell("seq 1 10000")`. On NixOS and minimal container hosts without `/bin/echo`, `/bin/cat`, or `seq` in `PATH`, those tests fail with child exit code 127.
|
|
|
|
## 2. Deliverables
|
|
- Controlled standard-library helper executable `tests/helpers/ProcessHelper.cpp` (`VoidProcessHelper`).
|
|
- CMake wiring in `tests/CMakeLists.txt` defining `VOID_PROCESS_HELPER_PATH` when `VoidTests` and `Void::System` are built.
|
|
- Updated `tests/standalone/System/Process.cpp` using `VOID_PROCESS_HELPER_PATH` instead of host `/bin/echo`, `/bin/cat`, or `seq`.
|
|
|
|
## 3. Exact files and interfaces
|
|
- `tests/helpers/ProcessHelper.cpp`:
|
|
- `echo [args...]`: prints space-separated args + `\n`, exits `0`.
|
|
- `cat`: copies raw stdin to stdout in 4096-byte chunks until EOF, exits `0`.
|
|
- `seq <start> <end>`: prints signed 64-bit integers inclusive one per line, exits `0`.
|
|
- `streams`: writes `"to_stdout\n"` to `stdout` and `"to_stderr\n"` to `stderr`, exits `0`.
|
|
- `exit <code>`: exits with parsed integer status code.
|
|
- `lines [--no-newline] [--stderr] [items...]`: emits lines to stdout or stderr.
|
|
- Invalid usage: prints diagnostic to `stderr` and exits `2`.
|
|
- `tests/CMakeLists.txt`: build `VoidProcessHelper` with C++26 (`VOID_TESTING_NO_AUTO_SCAN TRUE`) and pass `VOID_PROCESS_HELPER_PATH="$<TARGET_FILE:VoidProcessHelper>"` to `VoidTests`.
|
|
- `tests/standalone/System/Process.cpp`: replace hardcoded host commands; keep shell builtin tests (`/bin/sh` `echo`/`exit`) and `run_missing_executable_returns_code_127`; add direct argv `exit 42` and `streams` tests via `VOID_PROCESS_HELPER_PATH`.
|
|
|
|
## 4. Edge cases
|
|
- Helper binary uses only the C++ standard library (no `Void::` module dependencies) so it cannot mask failures in `Void::System`.
|
|
- Numeric parsing in `seq` and `exit` uses `std::from_chars` and rejects malformed/partial inputs with exit `2`.
|
|
|
|
## 5. Acceptance criteria
|
|
- `Process` and `ProcessStream` suites pass with 0 failures on NixOS without `/bin/echo`, `/bin/cat`, or `seq`.
|
|
- Full `VoidTests` passes with 0 failures (only existing intentional skip demonstrations in `Testing/Math.cpp`).
|
|
|
|
## 6. Verification commands
|
|
```sh
|
|
cmake --build /tmp/void-p0-base --parallel 4
|
|
/tmp/void-p0-base/tests/VoidTests --filter "Process*"
|
|
```
|