-
Notifications
You must be signed in to change notification settings - Fork 26
Add @skip-<dbtype> tags for database-specific test exclusion
#302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,3 +80,34 @@ Feature: Test that WP-CLI loads. | |
| """ | ||
| 6.3.1 | ||
| """ | ||
|
|
||
| @skip-mysql | ||
| Scenario: Skip on MySQL databases | ||
| Given a WP install | ||
|
|
||
| When I run `wp eval 'echo "This should only run on MariaDB or SQLite";'` | ||
| Then STDOUT should contain: | ||
| """ | ||
| This should only run on MariaDB or SQLite | ||
| """ | ||
|
|
||
| @skip-mariadb | ||
| Scenario: Skip on MariaDB databases | ||
| Given a WP install | ||
|
|
||
| When I run `wp eval 'echo "This should only run on MySQL or SQLite";'` | ||
| Then STDOUT should contain: | ||
| """ | ||
| This should only run on MySQL or SQLite | ||
| """ | ||
|
Comment on lines
+94
to
+102
|
||
|
|
||
| @skip-sqlite | ||
| Scenario: Skip on SQLite databases | ||
| Given a WP install | ||
|
|
||
| When I run `wp eval 'echo "This should only run on MySQL or MariaDB";'` | ||
| Then STDOUT should contain: | ||
| """ | ||
| This should only run on MySQL or MariaDB | ||
| """ | ||
|
Comment on lines
+104
to
+112
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -66,16 +66,19 @@ public function test_behat_tags_wp_version_github_token( $env, $expected ): void | |||
| case 'mariadb': | ||||
| $expected .= '&&~@require-mysql'; | ||||
| $expected .= '&&~@require-sqlite'; | ||||
| $expected .= '&&~@skip-mariadb'; | ||||
| break; | ||||
| case 'sqlite': | ||||
| $expected .= '&&~@require-mariadb'; | ||||
| $expected .= '&&~@require-mysql'; | ||||
| $expected .= '&&~@require-mysql-or-mariadb'; | ||||
| $expected .= '&&~@skip-sqlite'; | ||||
| break; | ||||
| case 'mysql': | ||||
| default: | ||||
| $expected .= '&&~@require-mariadb'; | ||||
| $expected .= '&&~@require-sqlite'; | ||||
| $expected .= '&&~@skip-mysql'; | ||||
| break; | ||||
| } | ||||
|
|
||||
|
|
@@ -150,16 +153,19 @@ public function test_behat_tags_php_version(): void { | |||
| case 'mariadb': | ||||
| $expected .= '&&~@require-mysql'; | ||||
| $expected .= '&&~@require-sqlite'; | ||||
| $expected .= '&&~@skip-mariadb'; | ||||
| break; | ||||
| case 'sqlite': | ||||
| $expected .= '&&~@require-mariadb'; | ||||
| $expected .= '&&~@require-mysql'; | ||||
| $expected .= '&&~@require-mysql-or-mariadb'; | ||||
| $expected .= '&&~@skip-sqlite'; | ||||
| break; | ||||
| case 'mysql': | ||||
| default: | ||||
| $expected .= '&&~@require-mariadb'; | ||||
| $expected .= '&&~@require-sqlite'; | ||||
| $expected .= '&&~@skip-mysql'; | ||||
| break; | ||||
| } | ||||
|
|
||||
|
|
@@ -187,16 +193,19 @@ public function test_behat_tags_extension(): void { | |||
| case 'mariadb': | ||||
| $expecteds[] = '~@require-mysql'; | ||||
| $expecteds[] = '~@require-sqlite'; | ||||
| $expecteds[] = '~@skip-mariadb'; | ||||
| break; | ||||
| case 'sqlite': | ||||
| $expecteds[] = '~@require-mariadb'; | ||||
| $expecteds[] = '~@require-mysql'; | ||||
| $expecteds[] = '~@require-mysql-or-mariadb'; | ||||
| $expecteds[] = '~@skip-sqlite'; | ||||
| break; | ||||
| case 'mysql': | ||||
| default: | ||||
| $expecteds[] = '~@require-mariadb'; | ||||
| $expecteds[] = '~@require-sqlite'; | ||||
| $expecteds[] = '~@skip-mysql'; | ||||
| break; | ||||
| } | ||||
|
|
||||
|
|
@@ -231,19 +240,22 @@ public function test_behat_tags_db_version(): void { | |||
| $contents = "@require-mariadb-$minimum_db_version @less-than-mariadb-$db_version"; | ||||
| $expecteds[] = '~@require-mysql'; | ||||
| $expecteds[] = '~@require-sqlite'; | ||||
| $expecteds[] = '~@skip-mariadb'; | ||||
| $expecteds[] = "~@require-mariadb-$minimum_db_version"; | ||||
| $expecteds[] = "~@less-than-mariadb-$db_version"; | ||||
| break; | ||||
| case 'sqlite': | ||||
| $expecteds[] = '~@require-mariadb'; | ||||
| $expecteds[] = '~@require-mysql'; | ||||
| $expecteds[] = '~@require-mysql-or-mariadb'; | ||||
| $expecteds[] = '~@skip-sqlite'; | ||||
| break; | ||||
| case 'mysql': | ||||
| default: | ||||
| $contents = "@require-mysql-$minimum_db_version @less-than-mysql-$db_version"; | ||||
| $expecteds[] = '~@require-mariadb'; | ||||
| $expecteds[] = '~@require-sqlite'; | ||||
| $expecteds[] = '~@skip-mysql'; | ||||
| $expecteds[] = "~@require-mysql-$minimum_db_version"; | ||||
| $expecteds[] = "~@less-than-mysql-$db_version"; | ||||
| break; | ||||
|
|
@@ -255,4 +267,43 @@ public function test_behat_tags_db_version(): void { | |||
| $output = exec( "cd {$this->temp_dir}; php $behat_tags" ); | ||||
| $this->assertSame( $expected, $output ); | ||||
| } | ||||
|
|
||||
| public function test_behat_tags_skip_db_type(): void { | ||||
| $env_github_token = getenv( 'GITHUB_TOKEN' ); | ||||
| $db_type = getenv( 'WP_CLI_TEST_DBTYPE' ); | ||||
|
|
||||
| putenv( 'GITHUB_TOKEN' ); | ||||
|
|
||||
| $behat_tags = dirname( dirname( __DIR__ ) ) . '/utils/behat-tags.php'; | ||||
|
|
||||
| file_put_contents( $this->temp_dir . '/features/skip_db.feature', '@skip-mysql @skip-mariadb @skip-sqlite' ); | ||||
|
|
||||
|
Comment on lines
+279
to
+280
|
||||
| file_put_contents( $this->temp_dir . '/features/skip_db.feature', '@skip-mysql @skip-mariadb @skip-sqlite' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These scenarios are intended to demonstrate/verify
@skip-*behavior, but the steps/assertions are database-agnostic (they just echo a static string). If the skip-tag implementation regresses and scenarios run on the “skipped” DB, they will still pass and won’t catch it. Consider making each scenario contain a DB-specific step that would fail on the skipped DB (e.g., combine@require-mysql-or-mariadbwith@skip-mysqland assertSELECT VERSION()containsMariaDB, and use@skip-sqlitewith aSHOW TABLESassertion).