Skip to content

Tests: improve Windows compatibility#484

Merged
swissspidy merged 2 commits intomainfrom
fix/windows-tests
Mar 28, 2026
Merged

Tests: improve Windows compatibility#484
swissspidy merged 2 commits intomainfrom
fix/windows-tests

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 27, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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 improves cross-platform compatibility for the test suite, specifically targeting Windows environments. Key changes include removing a PHP tag from a file content check, skipping Unix-specific scenarios on Windows, and introducing a dynamic {DIRECTORY_SEPARATOR} variable for path assertions. Feedback points out a syntax error in a PowerShell command where an en-dash was used instead of a hyphen and suggests refactoring repeated setup steps into a Background section to reduce duplication.

Comment thread features/makepot.feature Outdated
Comment thread features/makepot.feature
Comment thread features/makepot.feature Outdated
Comment thread features/makepot.feature Outdated
Co-authored-by: Pascal Birchler <pascal.birchler@gmail.com>
@swissspidy swissspidy added this to the 2.7.1 milestone Mar 28, 2026
@swissspidy swissspidy marked this pull request as ready for review March 28, 2026 11:53
@swissspidy swissspidy requested a review from a team as a code owner March 28, 2026 11:53
Copilot AI review requested due to automatic review settings March 28, 2026 11:53
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 the Behat feature tests to be more compatible with Windows environments by avoiding Unix-specific assumptions in a few scenarios.

Changes:

  • Split the “Adds copyright comments” scenario into Windows and non-Windows variants using OS-specific tags/commands.
  • Make debug-output path assertions OS-agnostic by using DIRECTORY_SEPARATOR.
  • Relax a make-php content assertion to avoid line-ending related failures.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
features/makepot.feature Adds Windows-specific scenario coverage and normalizes path assertions for Windows path separators.
features/makephp.feature Adjusts expected generated PHP output to reduce sensitivity to platform line-ending differences.

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

Comment thread features/makepot.feature
Comment on lines +116 to +118
@require-windows
Scenario: Adds copyright comments
When I run `wp scaffold plugin hello-world`
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

There are now two scenarios with the exact same name (one Windows-only, one non-Windows). Even if the runner allows it, it makes test reports and reruns ambiguous. Rename one/both scenarios to include the platform (or avoid duplication entirely) so failures can be identified unambiguously.

Copilot uses AI. Check for mistakes.
Comment thread features/makephp.feature
Comment on lines 154 to 156
And the foo-plugin/foo-plugin-de_DE.l10n.php file should contain:
"""
<?php
return ['domain'=>NULL,'plural-forms'=>'nplurals=2; plural=n != 1;','language'=>'de_DE','project-id-version'=>'Development (5.2.x)','pot-creation-date'=>'','po-revision-date'=>'2019-03-28 19:42+0300','x-generator'=>'Poedit 2.2.1','messages'=>['html_lang_attribute'=>'de-DE','text directionltr'=>'ltr','number_format_decimal_point'=>',','number_format_thousands_sep'=>'.','Update %s now'=>'Jetzt %s aktualisieren','[%1$s] Confirm Action: %2$s'=>'[%1$s] Aktion bestätigen: %2$s','[%s] Erasure Request Fulfilled'=>'[%s] Löschauftrag ausgeführt','[%s] Personal Data Export'=>'[%s] Export personenbezogener Daten']];
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

Dropping the <?php line from the expected content makes this assertion much less strict and could let a regression slip through (e.g., missing PHP open tag) just to work around line-ending differences. A more robust approach is to assert <?php and the return [...] payload separately (or use an assertion that’s tolerant of CRLF between lines) so Windows compatibility doesn’t reduce coverage.

Copilot uses AI. Check for mistakes.
Comment thread features/makepot.feature
Comment on lines 102 to +121
@@ -112,6 +113,20 @@ Feature: Generate a POT file of a WordPress project
# This file is distributed under the same license as the Hello World plugin.
"""

@require-windows
Scenario: Adds copyright comments
When I run `wp scaffold plugin hello-world`
And I run `get-date -f yyyy`
Then STDOUT should not be empty
And save STDOUT as {YEAR}
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

These tests still rely on platform-specific shell commands to determine the current year (date vs get-date), which duplicates the scenario and can be brittle depending on which shell is used to execute I run on Windows. Consider replacing both with a single cross-platform WP-CLI call (e.g., wp eval emitting date('Y')) so the scenario can run unconditionally without OS-specific tags/duplication.

Copilot uses AI. Check for mistakes.
@swissspidy swissspidy merged commit ddf8b84 into main Mar 28, 2026
73 checks passed
@swissspidy swissspidy deleted the fix/windows-tests branch March 28, 2026 12:02
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.

2 participants