Skip to content

Share expected failures across REGEXP tests - #651

Merged
JanJakes merged 2 commits into
trunkfrom
share-regexp-test-failures
Dec 4, 2026
Merged

JanJakes merged 2 commits into
trunkfrom
share-regexp-test-failures

Conversation

@JanJakes

@JanJakes JanJakes commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Summary

The REGEXP tests now share one list of expected failures. Cases are grouped by cause, with comments explaining the differences from MySQL and which checks or PCRE versions they affect. This removes more than 3,500 lines of duplicated test code and case IDs.

Why

REGEXP_INSTR() can return either the start or the end of a match. Previously, a fixture counted as a known failure if either position was wrong. That could hide a regression in the other position.

The suite now checks start and end positions independently. For example, ICU case 1243 starts at position 1 in both engines, but MySQL returns 10 for the end and the driver returns 2. The suite now reports a change to either result. The expected failures were checked against the previous lists across seven PCRE versions.

Summary by CodeRabbit

  • Tests
    • Consolidated separate regular-expression compatibility checks into a unified test suite covering five operations.
    • The suite compares results with MySQL-recorded cases and accounts for known differences across regex engines and versions.
    • Updated test-data generation to use the consolidated suite’s case definitions and output.

Group fixture IDs by source and record common failures once. Check REGEXP_INSTR start and end positions independently so a failure in one result cannot hide a change in the other.
@coderabbitai

coderabbitai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The REGEXP PHPUnit checks now reside in one class, replacing the shared base class and separate per-function classes. The test-data generator now uses that consolidated class for query definitions, sources, replacement templates, and output paths.

Changes: REGEXP Test Suite

Layer / File(s) Summary
Unified test suite and known failures
packages/mysql-on-sqlite/tests/regexp/WP_MySQL_On_SQLite_Regexp_Tests.php, packages/mysql-on-sqlite/tests/regexp/WP_MySQL_On_SQLite_Regexp_Test_Case.php, packages/mysql-on-sqlite/tests/regexp/WP_MySQL_On_SQLite_Regexp_*_Tests.php
One PHPUnit class defines five REGEXP checks and their source-, check-, engine-, and version-specific known failures. The former shared base class and per-function classes are removed.
Query execution and result reporting
packages/mysql-on-sqlite/tests/regexp/WP_MySQL_On_SQLite_Regexp_Tests.php
The suite executes cases, captures PHP and SQL errors, compares actual results with expected values, and formats failures.
Test-data generator integration
packages/mysql-on-sqlite/tests/tools/generate-regexp-test-data.php
The generator gets its source list, query construction, replacement templates, and output directory from the consolidated test class.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Other

Possibly related PRs

Merge Risk: Minimal · up to 4fba4

This change reorganizes the REGEXP test suite and its data generator into a single class. It affects only test code, not production behavior, and no merge-blocking issues were found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "Share expected failures across REGEXP tests" matches the main change. The PR consolidates expected REGEXP test failures into shared lists grouped by cause, removes the per-function test cla…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "Share expected failures across REGEXP tests" matches the main change. The PR consolidates expected REGEXP test failures into shared lists grouped by cause, removes the per-function test classes and base class, and adds a single WP_MySQL_On_SQLite_Regexp_Tests suite. The title is specific and does not use vague terms.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 690184ff-bf80-46f0-a3f9-537ccc9b93ad
Commits

Reviewing files that changed from the base of the PR and between a3572d3 and 4fba434.

Files selected for processing: 7

  • packages/mysql-on-sqlite/tests/regexp/WP_MySQL_On_SQLite_Regexp_Instr_Tests.php
  • packages/mysql-on-sqlite/tests/regexp/WP_MySQL_On_SQLite_Regexp_Like_Tests.php
  • packages/mysql-on-sqlite/tests/regexp/WP_MySQL_On_SQLite_Regexp_Replace_Tests.php
  • packages/mysql-on-sqlite/tests/regexp/WP_MySQL_On_SQLite_Regexp_Substr_Tests.php
  • packages/mysql-on-sqlite/tests/regexp/WP_MySQL_On_SQLite_Regexp_Test_Case.php
  • packages/mysql-on-sqlite/tests/regexp/WP_MySQL_On_SQLite_Regexp_Tests.php
  • packages/mysql-on-sqlite/tests/tools/generate-regexp-test-data.php
Files with no reviewable changes: 5

  • packages/mysql-on-sqlite/tests/regexp/WP_MySQL_On_SQLite_Regexp_Instr_Tests.php
  • packages/mysql-on-sqlite/tests/regexp/WP_MySQL_On_SQLite_Regexp_Like_Tests.php
  • packages/mysql-on-sqlite/tests/regexp/WP_MySQL_On_SQLite_Regexp_Replace_Tests.php
  • packages/mysql-on-sqlite/tests/regexp/WP_MySQL_On_SQLite_Regexp_Substr_Tests.php
  • packages/mysql-on-sqlite/tests/regexp/WP_MySQL_On_SQLite_Regexp_Test_Case.php

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

Explain which MySQL behavior each group exercises, including errors, match positions, replacements, and PCRE version differences.
@JanJakes
JanJakes marked this pull request as ready for review December 4, 2026 12:14
@JanJakes
JanJakes force-pushed the share-regexp-test-failures branch from 61c229c to 4fba434 Compare December 4, 2026 12:14
@JanJakes
JanJakes merged commit 80a5d8d into trunk Dec 4, 2026
20 checks passed
@JanJakes
JanJakes deleted the share-regexp-test-failures branch December 4, 2026 12:21
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.

1 participant