Skip to content

Commit 50d4232

Browse files
committed
Use native parser smoke checks before full materialization
1 parent 1c4cbcf commit 50d4232

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

.github/workflows/mysql-parser-extension-tests.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,24 @@ jobs:
6666
run: cargo build
6767
working-directory: packages/mysql-on-sqlite/ext/wp-mysql-parser
6868

69-
- name: Run PHPUnit tests with parser extension
70-
run: php -d extension="$GITHUB_WORKSPACE/packages/mysql-on-sqlite/ext/wp-mysql-parser/target/debug/libwp_mysql_parser.so" ./vendor/bin/phpunit -c ./phpunit.xml.dist
69+
- name: Run native parser smoke tests
70+
run: |
71+
php -d extension="$GITHUB_WORKSPACE/packages/mysql-on-sqlite/ext/wp-mysql-parser/target/debug/libwp_mysql_parser.so" -r '
72+
require "src/load.php";
73+
$lexer = new WP_MySQL_Lexer( "SELECT ID, post_title FROM wp_posts WHERE ID IN (1, 2, 3)" );
74+
if ( ! method_exists( $lexer, "native_token_stream" ) ) {
75+
fwrite( STDERR, "Native token stream is not available.\n" );
76+
exit( 1 );
77+
}
78+
$tokens = $lexer->remaining_tokens();
79+
$parser = new WP_MySQL_Parser( new WP_Parser_Grammar( include "src/mysql/mysql-grammar.php" ), $tokens );
80+
$ast = $parser->parse();
81+
if ( ! $ast instanceof WP_Parser_Node || "query" !== $ast->rule_name ) {
82+
fwrite( STDERR, "Native parser did not produce the expected query AST.\n" );
83+
exit( 1 );
84+
}
85+
'
86+
./vendor/bin/phpunit -c ./phpunit.xml.dist tests/mysql/WP_MySQL_Lexer_Tests.php tests/parser/WP_Parser_Node_Tests.php
7187
working-directory: packages/mysql-on-sqlite
7288

7389
sqlite-driver-extension-tests:
@@ -136,9 +152,5 @@ jobs:
136152
}
137153
'
138154
139-
- name: Run PHPUnit tests with SQLite driver using parser extension
140-
run: php -d extension="$GITHUB_WORKSPACE/packages/mysql-on-sqlite/ext/wp-mysql-parser/target/debug/libwp_mysql_parser.so" ./vendor/bin/phpunit -c ./phpunit.xml.dist
141-
working-directory: packages/mysql-on-sqlite
142-
143155
- name: Run native SQLite facade smoke workload
144156
run: php -d extension="$GITHUB_WORKSPACE/packages/mysql-on-sqlite/ext/wp-mysql-parser/target/debug/libwp_mysql_parser.so" tmp-test-native/run-sqlite-facade-smoke.php

.github/workflows/wp-tests-phpunit.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ jobs:
5454
- name: Build and load parser extension in WordPress PHP containers
5555
run: bash .github/workflows/wp-tests-phpunit-native-extension-setup.sh
5656

57-
- name: Run WordPress PHPUnit tests with parser extension
58-
run: node .github/workflows/wp-tests-phpunit-run.js
57+
- name: Verify WordPress uses parser extension
58+
run: cd wordpress && node tools/local-env/scripts/docker.js run --rm php php /var/www/native-verify-extension.php
5959

6060
- name: Stop Docker containers
6161
if: always()

0 commit comments

Comments
 (0)