Skip to content

Tests: Various harness improvements, especially on Windows#326

Open
swissspidy wants to merge 19 commits intomainfrom
try/windows-logging
Open

Tests: Various harness improvements, especially on Windows#326
swissspidy wants to merge 19 commits intomainfrom
try/windows-logging

Conversation

@swissspidy
Copy link
Copy Markdown
Member

@swissspidy swissspidy commented Mar 27, 2026

Also adds some hardening when downloading WP core for tests fails due to timeouts or so.

@github-actions

This comment was marked as resolved.

gemini-code-assist[bot]

This comment was marked as resolved.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 27, 2026

Codecov Report

❌ Patch coverage is 0% with 33 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Context/FeatureContext.php 0.00% 32 Missing ⚠️
src/Context/ThenStepDefinitions.php 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

This prevents cmd.exe from misinterpreting %...% as undefined environment variables and stripping them.
@swissspidy swissspidy added this to the 5.1.7 milestone Mar 28, 2026
@swissspidy

This comment was marked as resolved.

gemini-code-assist[bot]

This comment was marked as resolved.

@swissspidy swissspidy changed the title Misc Windows improvements Tests: Various harness improvements, especially on Windows Mar 30, 2026
@swissspidy swissspidy marked this pull request as ready for review March 30, 2026 20:50
@swissspidy swissspidy requested a review from a team as a code owner March 30, 2026 20:50
Copilot AI review requested due to automatic review settings March 30, 2026 20:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines 498 to +502
$files = glob( rtrim( $path, '/' ) . '/*' );
foreach ( $files as &$file ) {
$file = str_replace( $path . '/', '', $file );
}
$contents = implode( PHP_EOL, $files );
$contents = implode( "\n", $files );
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 '/'.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants