Skip to content

Fix Windows test failures: shell quoting, cURL error 77 message, sys_get_temp_dir path mismatch, chmod file permissions#6257

Closed
Copilot wants to merge 4 commits intotry/osfrom
copilot/sub-pr-6245
Closed

Fix Windows test failures: shell quoting, cURL error 77 message, sys_get_temp_dir path mismatch, chmod file permissions#6257
Copilot wants to merge 4 commits intotry/osfrom
copilot/sub-pr-6245

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 3, 2026

Four Windows-specific failures block the CI matrix added to run tests on windows-2025. All 203 Behat scenarios fail due to shell quoting incompatibility with PowerShell/cmd.exe, and three PHPUnit tests fail due to platform differences in cURL error messages, temp directory path resolution, and file permission handling.

Changes

  • features/*.feature — Behat Windows shell quoting: PowerShell and cmd.exe do not treat single quotes as string delimiters, so wp eval 'code here' gets tokenized incorrectly. All eval '...' calls in 14 Behat feature files are converted to eval "..." (double outer quotes), with inner PHP string literals flipped from " to ' as needed. For PHP code containing $variable references (which would be shell-expanded under double quotes), the eval calls are converted to use eval-file with inline PHP files via Behat's Given a ... file: step. The $assoc_args case in config.feature uses compact('assoc_args')['assoc_args'] to avoid any bare $ in the shell string.

  • tests/UtilsTest.phptestHttpRequestBadCAcert: Windows cURL error 77 reports "error adding trust anchors from file: ...\wp-5EFE.tmp" instead of "error setting certificate". Assertion narrowed to 'cURL error 77:' which is common to both platforms.

  • tests/mock-requests-transport.phptest_http_request_verify@insecure: strpos($verify, sys_get_temp_dir()) fails on Windows when sys_get_temp_dir() returns an 8.3 short path (RUNNER~1) while tempnam() returns the long path (runneradmin). Use realpath() to normalize both sides before comparing.

  • tests/FileCacheTest.phptest_import_do_not_use_cache_file_cannot_be_read: chmod($file, 0000) does not restrict read access on Windows (unlike POSIX), causing FileCache::import() to succeed instead of returning false. The test is skipped on Windows with markTestSkipped(), consistent with the existing Windows guard already in place for the mkdir permission test in the same class.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…_temp_dir path

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

Copilot AI changed the title [WIP] Run tests against Windows and macOS Fix Windows test failures: shell quoting, cURL error 77 message, sys_get_temp_dir path mismatch Mar 3, 2026
@swissspidy

This comment was marked as resolved.

…stead of single quotes

- Revert proc_open_compat() bash-wrapping change (no longer needed)
- Convert all eval '...' to eval "..." in feature files, flipping inner PHP
  double-quoted strings to single-quoted to avoid escaping conflicts
- For PHP code containing $variables: convert to eval-file with inline PHP
  files to avoid shell variable expansion
- config.feature $assoc_args: use compact('assoc_args')['assoc_args'] to
  avoid bare $ in the shell command string
- aliases.feature echo "\n": replace with echo 'text' . PHP_EOL;

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

@swissspidy
Copy link
Copy Markdown
Member

@copilot any idea why the tests might be timing out on Windows? maybe an issue with wp-cli/wp-cli-tests#274?

…n Windows: skip when chmod() is ineffective

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 4, 2026

@copilot any idea why the tests might be timing out on Windows? maybe an issue with wp-cli/wp-cli-tests#274?

The actual CI failure in the latest run isn't a timeout — it's FileCacheTest::test_import_do_not_use_cache_file_cannot_be_read failing because chmod($file, 0000) doesn't restrict read access on Windows (unlike POSIX). I've added a markTestSkipped() guard there, matching the pattern already used for the mkdir permission test in the same class (commit 080e642).

The installed wp-cli-tests already includes the PR #274 changes (temp_files tracking, cleanup_temp_files(), Windows background_proc using file descriptors instead of pipes). So that PR shouldn't cause timeouts here.

Copilot AI changed the title Fix Windows test failures: shell quoting, cURL error 77 message, sys_get_temp_dir path mismatch Fix Windows test failures: shell quoting, cURL error 77 message, sys_get_temp_dir path mismatch, chmod file permissions Mar 4, 2026
@swissspidy swissspidy closed this Mar 10, 2026
swissspidy added a commit that referenced this pull request Mar 10, 2026
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.

2 participants