Tests: Various harness improvements, especially on Windows#326
Tests: Various harness improvements, especially on Windows#326swissspidy wants to merge 19 commits intomainfrom
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This prevents cmd.exe from misinterpreting %...% as undefined environment variables and stripping them.
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Pull request overview
This PR improves the Behat test harness with a focus on Windows compatibility and adds extra resiliency around downloading WordPress core for tests.
Changes:
- Propagate additional Windows environment variables to subprocesses and add a Windows-specific PHAR invocation adjustment.
- Harden WP core download caching by checking a more reliable “cache present” marker and retrying downloads on failure.
- Normalize several path constructions using
DIRECTORY_SEPARATOR/rtrim(..., '/\\'), plus add a feature scenario to validate temp dir behavior in subprocesses.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Context/ThenStepDefinitions.php | Adjusts directory listing output to use \n for more consistent cross-platform comparisons. |
| src/Context/FeatureContext.php | Adds Windows env propagation, download retry logic, and multiple Windows path handling fixes. |
| features/testing.feature | Adds a scenario intended to validate temp dir handling in subprocess execution. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| $files = glob( rtrim( $path, '/' ) . '/*' ); | ||
| foreach ( $files as &$file ) { | ||
| $file = str_replace( $path . '/', '', $file ); | ||
| } | ||
| $contents = implode( PHP_EOL, $files ); | ||
| $contents = implode( "\n", $files ); |
There was a problem hiding this comment.
Directory listing normalization is still Unix-path specific: glob( rtrim( $path, '/' ) . '/*' ) and str_replace( $path . '/', '', $file ) won't reliably strip the prefix on Windows when $path (and/or glob() results) use backslashes. This can cause directory-contents assertions to compare against full absolute paths instead of basenames. Consider normalizing both $path and $file separators (or just use basename() here since the glob is non-recursive) and trimming '/\\' instead of only '/'.
Also adds some hardening when downloading WP core for tests fails due to timeouts or so.