Skip to content

Commit 36f8e18

Browse files
committed
Replace isolation probe with SQL-capture probe
Now that we know the bugs reproduce in isolation (not from suite state buildup), capture the exact SQLite SQL the driver emits for each failing test. Install a query_logger on the connection and print every statement. Then we can pinpoint which specific SQL the driver issues that triggers Turso's failure mode.
1 parent 2295388 commit 36f8e18

1 file changed

Lines changed: 50 additions & 8 deletions

File tree

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

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,20 +2015,62 @@ jobs:
20152015
# form crashes testReconstructTable. Test stays failing.
20162016
PY
20172017
2018-
- name: Probe — run only the 3 failing tests via PHPUnit filter
2018+
- name: Probe — capture exact SQL the driver emits in failing tests
20192019
continue-on-error: true
20202020
env:
20212021
LD_PRELOAD: ${{ steps.preload.outputs.value }}
20222022
working-directory: packages/mysql-on-sqlite
20232023
run: |
20242024
set +e
2025-
# If only the 3 failing tests are run (no preceding suite), do
2026-
# they still fail? This isolates whether the bug is intrinsic
2027-
# to the tests or accumulated from prior tests.
2028-
timeout --kill-after=10 120 \
2029-
php ./vendor/bin/phpunit -c ./phpunit.xml.dist \
2030-
--filter '(testCreateTemporaryTable|testTemporaryTableHasPriorityOverStandardTable|testInformationSchemaTablesFilterByAutoIncrement)' \
2031-
--debug 2>&1 | tail -50
2025+
php <<'PHP'
2026+
<?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.
2031+
require __DIR__ . '/vendor/autoload.php';
2032+
require __DIR__ . '/tests/bootstrap.php';
2033+
2034+
function run_with_log(string $label, callable $f): void {
2035+
echo "=== $label ===\n";
2036+
try {
2037+
$pdo_class = PHP_VERSION_ID >= 80400 ? PDO\SQLite::class : PDO::class;
2038+
$sqlite = new $pdo_class('sqlite::memory:');
2039+
$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+
});
2046+
$engine = new WP_SQLite_Driver($conn, 'wp');
2047+
$f($engine, $sqlite);
2048+
echo "OK\n";
2049+
} catch (Throwable $e) {
2050+
echo 'FAIL: ' . $e->getMessage() . "\n";
2051+
}
2052+
echo "\n";
2053+
}
2054+
2055+
run_with_log('testCreateTemporaryTable', function ($engine) {
2056+
$engine->query('CREATE TEMPORARY TABLE _tmp_table (
2057+
ID INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL,
2058+
option_name TEXT NOT NULL default \'\',
2059+
option_value TEXT NOT NULL default \'\'
2060+
)');
2061+
$engine->query('DROP TEMPORARY TABLE _tmp_table');
2062+
});
2063+
2064+
run_with_log('testInformationSchemaTablesFilterByAutoIncrement', function ($engine) {
2065+
$engine->query('CREATE TABLE low (id INT AUTO_INCREMENT PRIMARY KEY, name TEXT)');
2066+
$engine->query('CREATE TABLE high (id INT AUTO_INCREMENT PRIMARY KEY, name TEXT)');
2067+
$engine->query('CREATE TABLE plain (id INT, name TEXT)');
2068+
$engine->query("INSERT INTO low (name) VALUES ('a')");
2069+
$engine->query("INSERT INTO high (name) VALUES ('a'), ('b'), ('c'), ('d'), ('e')");
2070+
$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";
2072+
});
2073+
PHP
20322074
echo "(probe step: continue-on-error)"
20332075
20342076
- name: Run PHPUnit tests against Turso DB

0 commit comments

Comments
 (0)