Skip to content

Make Behat scenarios SQLite-compatible#138

Merged
swissspidy merged 4 commits intowp-cli:mainfrom
abhi3315:fix/112-sqlite-compatibility
Apr 17, 2026
Merged

Make Behat scenarios SQLite-compatible#138
swissspidy merged 4 commits intowp-cli:mainfrom
abhi3315:fix/112-sqlite-compatibility

Conversation

@abhi3315
Copy link
Copy Markdown
Contributor

@abhi3315 abhi3315 commented Apr 13, 2026

Fixes #112

A bunch of scenarios in features/export.feature are tagged @require-mysql, but the command source uses portable SQL and $wpdb everywhere. The SQLite integration plugin has matured since that tag was added, and most of those scenarios work fine on SQLite today. This PR removes the tag where it isn't needed.

Changes

  • 19 scenarios drop the @require-mysql tag. Verified by running the whole file with WP_CLI_TEST_DBTYPE=sqlite composer behat: 32 scenarios pass, 560 steps.

  • Scenario: Export posts from a given starting post ID switched from --start_id=6 to wp post list --offset=5 --posts_per_page=1 --format=ids. SQLite doesn't reset auto-increment on wp site empty, so the IDs aren't always 1..10 and the hardcoded value was matching 8 posts instead of 5.

  • Scenario: Export without splitting the dump keeps @require-mysql. The scenario literally tests MySQL's redo log size limit ("stay below 10% of default redo log size of 48MB"), so making it work on SQLite doesn't make sense. I tried swapping REPEAT() for str_repeat() earlier in this PR and it hung MySQL 5.6/5.7 CI for 47 minutes. Reverted.

Related: wp-cli/.github#94

@abhi3315 abhi3315 requested a review from a team as a code owner April 13, 2026 06:02
@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 scope:distribution Related to distribution scope:testing Related to testing labels Apr 13, 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 enhances SQLite compatibility for export feature tests by removing MySQL-specific tags and replacing SQL-specific functions with PHP equivalents via wp eval. It also implements dynamic post ID lookups to handle non-sequential auto-increment behavior. Feedback was provided to consolidate multiple wp eval calls into a single command to optimize performance by reducing WordPress bootstrap overhead.

Comment thread features/export.feature Outdated
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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 acceptance tests for the export command to run successfully under WP_CLI_TEST_DBTYPE=sqlite by removing MySQL-specific assumptions in two scenarios.

Changes:

  • Makes the “starting post ID” export scenario deterministic by deriving the start ID from the generated posts instead of hardcoding it.
  • Replaces a MySQL-only REPEAT() usage in a fixture with a SQLite-compatible wp eval + str_repeat() approach.
  • Removes @require-mysql from the two affected scenarios so they execute under SQLite.

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

@swissspidy
Copy link
Copy Markdown
Member

With this PR, all the MySQL 5.6/5.7 are timing out. This needs investigating.

The split-dump scenario remains MySQL-only because it tests MySQL's
redo log size limit behavior, which doesn't apply to SQLite.
@abhi3315
Copy link
Copy Markdown
Contributor Author

abhi3315 commented Apr 17, 2026

Fixed. The REPEAT() to str_repeat() swap was sending 4MB+ inserts from PHP, which hits MySQL 5.6 and 5.7's default 4MB max_allowed_packet. 8.0 passed because its default is 64MB. I haven't fully pinned down why it hung rather than errored, but the scope was wrong regardless: that scenario specifically tests MySQL's redo log limit, so making it work on SQLite doesn't fit. Reverted to the original SQL with @require-mysql restored.

While I was in there I also went through the rest of the @require-mysql scoped scenarios in this file. 19 of them pass on SQLite once the tag is stripped, so I un-tagged those too. I have updated the PR descriptions accordingly.

All CI jobs pass! ✅

Copy link
Copy Markdown
Member

@swissspidy swissspidy left a comment

Choose a reason for hiding this comment

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

Thanks a lot!

@swissspidy swissspidy merged commit 224b59b into wp-cli:main Apr 17, 2026
62 checks passed
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.

SQLite Compatibility

3 participants