Skip to content

Tests: improve Windows compatibility#82

Merged
swissspidy merged 1 commit intomainfrom
fix/windows-tests
Mar 28, 2026
Merged

Tests: improve Windows compatibility#82
swissspidy merged 1 commit intomainfrom
fix/windows-tests

Conversation

@swissspidy
Copy link
Copy Markdown
Member

No description provided.

@swissspidy swissspidy added this to the 2.2.3 milestone Mar 28, 2026
@swissspidy swissspidy requested a review from a team as a code owner March 28, 2026 11:59
Copilot AI review requested due to automatic review settings March 28, 2026 11:59
@github-actions github-actions bot added scope:distribution Related to distribution scope:testing Related to testing labels Mar 28, 2026
@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.

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 refactors several Behat feature tests by replacing inline wp eval commands with wp eval-file for better maintainability. It also introduces @skip-windows tags and TODO notes for scenarios that exhibit inconsistent behavior on Windows. A review comment suggests improving the robustness of the PHP snippet in features/widget-reset.feature by explicitly verifying the existence of the 'sidebar-1' key before use to prevent silent failures.

Comment on lines +175 to +178
$w = wp_get_sidebars_widgets();
$w['orphaned-sidebar-1'] = $w['sidebar-1'];
$w['sidebar-1'] = [];
update_option( 'sidebars_widgets', $w );
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

This code assumes that $w['sidebar-1'] is always set. While the current test setup ensures this, it makes the test fragile. If a preceding step changes, this could lead to a PHP notice and potentially confusing test failures. To make the test more robust and easier to debug, consider adding an explicit check and failing loudly if the prerequisite is not met.

      $w = wp_get_sidebars_widgets();
      if ( ! array_key_exists( 'sidebar-1', $w ) ) {
          throw new \Exception( "Test prerequisite not met: 'sidebar-1' not found in sidebars_widgets." );
      }
      $w['orphaned-sidebar-1'] = $w['sidebar-1'];
      $w['sidebar-1'] = [];
      update_option( 'sidebars_widgets', $w );

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

Improves cross-platform (Windows) reliability of the Behat feature suite for the widget/sidebar WP-CLI commands by avoiding shell-quoting-sensitive wp eval usage and skipping scenarios that are currently Windows-flaky.

Changes:

  • Mark known-flaky widget scenarios as @skip-windows and add TODO notes documenting the Windows-only discrepancies.
  • Replace inline wp eval '...' usages with wp eval-file by generating small PHP helper files within scenarios.

Reviewed changes

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

File Description
features/widget.feature Skips the “Widget CRUD” scenario on Windows; adds a TODO note about Windows-only widget positioning.
features/widget-reset.feature Skips a Windows-flaky scenario; replaces inline wp eval with an eval-file helper for orphaned sidebar setup.
features/sidebar.feature Replaces inline wp eval with an eval-file helper to set up an orphaned sidebar entry.

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

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@swissspidy swissspidy merged commit 07cd4f3 into main Mar 28, 2026
68 checks passed
@swissspidy swissspidy deleted the fix/windows-tests branch March 28, 2026 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope:distribution Related to distribution scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants