@@ -2019,40 +2019,34 @@ jobs:
20192019 continue-on-error : true
20202020 env :
20212021 LD_PRELOAD : ${{ steps.preload.outputs.value }}
2022+ # Use Turso's tracing to log every prepared SQL statement.
2023+ RUST_LOG : ' turso_core::translate=trace,turso_core::vdbe::insn=info'
20222024 working-directory : packages/mysql-on-sqlite
20232025 run : |
20242026 set +e
2025- php <<'PHP'
2027+ php <<'PHP' 2>&1 | head -800
20262028 <?php
2027- // Boot the driver, install a query logger on the SQLite
2028- // connection, and run the failing test scenarios. Print
2029- // every SQL statement that hits Turso so we can see exactly
2030- // which one triggers the failure.
2029+ // Boot the driver, run failing test scenarios. With RUST_LOG
2030+ // including translate=trace, Turso prints each prepared SQL
2031+ // to stderr (which we route to stdout for `head -800`).
20312032 require __DIR__ . '/vendor/autoload.php';
20322033 require __DIR__ . '/tests/bootstrap.php';
20332034
2034- function run_with_log (string $label, callable $f): void {
2035- echo " === $label ===\n";
2035+ function run_test (string $label, callable $f): void {
2036+ fwrite(STDERR, "\n === START $label ===\n") ;
20362037 try {
20372038 $pdo_class = PHP_VERSION_ID >= 80400 ? PDO\SQLite::class : PDO::class;
20382039 $sqlite = new $pdo_class('sqlite::memory:');
20392040 $conn = new WP_SQLite_Connection(['pdo' => $sqlite]);
2040- $idx = 0;
2041- $conn->set_query_logger(function ($sql, $params) use (&$idx) {
2042- $idx++;
2043- $oneline = preg_replace('/\s+/', ' ', trim($sql));
2044- echo sprintf("[%03d] %s\n", $idx, substr($oneline, 0, 240));
2045- });
20462041 $engine = new WP_SQLite_Driver($conn, 'wp');
20472042 $f($engine, $sqlite);
2048- echo "OK \n";
2043+ fwrite(STDERR, "=== OK $label === \n") ;
20492044 } catch (Throwable $e) {
2050- echo ' FAIL: ' . $e->getMessage() . "\n";
2045+ fwrite(STDERR, "=== FAIL $label: " . $e->getMessage() . " === \n") ;
20512046 }
2052- echo "\n";
20532047 }
20542048
2055- run_with_log ('testCreateTemporaryTable', function ($engine) {
2049+ run_test ('testCreateTemporaryTable', function ($engine) {
20562050 $engine->query('CREATE TEMPORARY TABLE _tmp_table (
20572051 ID INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL,
20582052 option_name TEXT NOT NULL default \'\',
@@ -2061,14 +2055,14 @@ jobs:
20612055 $engine->query('DROP TEMPORARY TABLE _tmp_table');
20622056 });
20632057
2064- run_with_log ('testInformationSchemaTablesFilterByAutoIncrement', function ($engine) {
2058+ run_test ('testInformationSchemaTablesFilterByAutoIncrement', function ($engine) {
20652059 $engine->query('CREATE TABLE low (id INT AUTO_INCREMENT PRIMARY KEY, name TEXT)');
20662060 $engine->query('CREATE TABLE high (id INT AUTO_INCREMENT PRIMARY KEY, name TEXT)');
20672061 $engine->query('CREATE TABLE plain (id INT, name TEXT)');
20682062 $engine->query("INSERT INTO low (name) VALUES ('a')");
20692063 $engine->query("INSERT INTO high (name) VALUES ('a'), ('b'), ('c'), ('d'), ('e')");
20702064 $r = $engine->query('SELECT TABLE_NAME FROM information_schema.tables WHERE `AUTO_INCREMENT` > 3');
2071- echo " -> " . count($r) . " row(s): " . json_encode(array_map(fn($o) => $o->TABLE_NAME, $r)) . "\n";
2065+ fwrite(STDERR, " -> " . count($r) . " row(s): " . json_encode(array_map(fn($o) => $o->TABLE_NAME, $r)) . "\n") ;
20722066 });
20732067 PHP
20742068 echo "(probe step: continue-on-error)"
0 commit comments