Skip to content

Tests: Further improve Windows compatibility#327

Merged
swissspidy merged 5 commits intomainfrom
fix/windows-pt2
Apr 2, 2026
Merged

Tests: Further improve Windows compatibility#327
swissspidy merged 5 commits intomainfrom
fix/windows-pt2

Conversation

@swissspidy
Copy link
Copy Markdown
Member

No description provided.

@github-actions
Copy link
Copy Markdown
Contributor

Hello! 👋

Thanks for opening this pull request! Please check out our contributing guidelines. We appreciate you taking the initiative to contribute to this project.

Contributing isn't limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation.

Here are some useful Composer commands to get you started:

  • composer install: Install dependencies.
  • composer test: Run the full test suite.
  • composer phpcs: Check for code style violations.
  • composer phpcbf: Automatically fix code style violations.
  • composer phpunit: Run unit tests.
  • composer behat: Run behavior-driven tests.

To run a single Behat test, you can use the following command:

# Run all tests in a single file
composer behat features/some-feature.feature

# Run only a specific scenario (where 123 is the line number of the "Scenario:" title)
composer behat features/some-feature.feature:123

You can find a list of all available Behat steps in our handbook.

@github-actions github-actions bot added the scope:testing Related to testing label Mar 29, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates a wp eval command in features/core.feature to use double quotes, which improves compatibility with Windows environments. The reviewer recommends extending this change to other similar commands within the same file to ensure consistency and prevent parsing issues across the entire test suite.

And the return code should be 0
When I run `wp eval 'echo $GLOBALS["current_site"]->domain;'`
When I run `wp eval "echo $GLOBALS['current_site']->domain;"`
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

While this change improves Windows compatibility for this command, other wp eval calls in this file still use single quotes (e.g., on line 249), which can cause parsing issues on Windows. For consistency and to fully address the compatibility issue, please consider updating all wp eval calls in this file to use double quotes for the command argument.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

swissspidy and others added 2 commits April 1, 2026 23:18
Co-authored-by: Wojciech Smoliński <wojsmol@wp.pl>
@swissspidy swissspidy marked this pull request as ready for review April 2, 2026 11:09
@swissspidy swissspidy requested a review from a team as a code owner April 2, 2026 11:09
Copilot AI review requested due to automatic review settings April 2, 2026 11:09
@swissspidy swissspidy added this to the 2.1.28 milestone Apr 2, 2026
@swissspidy swissspidy merged commit 6fede96 into main Apr 2, 2026
63 checks passed
@swissspidy swissspidy deleted the fix/windows-pt2 branch April 2, 2026 11:09
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

Updates Behat acceptance tests in core-command to behave more reliably across platforms (especially Windows), primarily by avoiding shell-quoting pitfalls and skipping scenarios that depend on Unix-specific paths/behavior.

Changes:

  • Replaced an inline wp eval '...' assertion with a wp eval-file run against a generated PHP file to avoid quoting issues.
  • Added @skip-windows to scenarios that are not portable to Windows (custom multisite base path scenario; root-level absolute path permission scenario).
  • Split out the root-level path failure checks into their own scenario in core-download.feature.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
features/core.feature Uses eval-file with a generated PHP file for a multisite-domain assertion; marks a multisite-base-path scenario as skipped on Windows.
features/core-download.feature Adds a Windows skip tag and isolates the absolute root-level path permission checks into a dedicated scenario.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


@skip-windows
Scenario: Fail if path can't be created (root-level-directory)
Given an empty directory
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

This new scenario is environment-dependent: creating /root-level-directory will succeed when tests run with elevated privileges (or in some container setups), and it can also behave differently if the directory already exists from a previous run. That makes the test potentially flaky on CI and locally. Consider making the failure deterministic by ensuring the directory is removed before the scenario (using the existing “non-existent … directory” step) and/or by targeting a consistently non-writable location or a non-writable directory created within the test workspace.

Suggested change
Given an empty directory
Given an empty directory
And a non-existent '/root-level-directory' directory

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

Labels

scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants