Run all tcl tests on 2 separate dbs (1. with rowid aliases 2. without rowid aliases)

This commit is contained in:
jussisaurio 2024-12-14 17:13:45 +02:00
parent 949d6fecbd
commit 987a8bfb5d
3 changed files with 69 additions and 11 deletions

View file

@ -3,7 +3,7 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
do_execsql_test schema {
do_execsql_test_on_specific_db testing/testing.db schema {
.schema
} {"CREATE TABLE users (
id INTEGER PRIMARY KEY,
@ -24,7 +24,29 @@ CREATE TABLE products (
);
CREATE INDEX age_idx on users (age);"}
do_execsql_test schema-1 {
# FIXME sqlite does something different with .schema than what we are doing
#do_execsql_test_on_specific_db testing/testing_norowidalias.db schema {
# .schema
#} {"CREATE TABLE IF NOT EXISTS users (
# id INT PRIMARY KEY,
# first_name TEXT,
# last_name TEXT,
# email TEXT,
# phone_number TEXT,
# address TEXT,
# city TEXT,
# state TEXT,
# zipcode TEXT,
# age INTEGER
# );
#CREATE TABLE IF NOT EXISTS products (
# id INT PRIMARY KEY,
# name TEXT,
# price REAL
# );
#CREATE INDEX age_idx2 on users (age);"}
do_execsql_test_on_specific_db testing/testing.db schema-1 {
.schema users
} {"CREATE TABLE users (
id INTEGER PRIMARY KEY,
@ -40,10 +62,36 @@ do_execsql_test schema-1 {
);
CREATE INDEX age_idx on users (age);"}
do_execsql_test schema-2 {
# FIXME sqlite does something different with .schema than what we are doing
#do_execsql_test_on_specific_db testing/testing_norowidalias.db schema-1 {
# .schema users
#} {"CREATE TABLE IF NOT EXISTS users (
# id INT PRIMARY KEY,
# first_name TEXT,
# last_name TEXT,
# email TEXT,
# phone_number TEXT,
# address TEXT,
# city TEXT,
# state TEXT,
# zipcode TEXT,
# age INTEGER
# );
#CREATE INDEX age_idx2 on users (age);"}
do_execsql_test_on_specific_db testing/testing.db schema-2 {
.schema products
} {{CREATE TABLE products (
} {"CREATE TABLE products (
id INTEGER PRIMARY KEY,
name TEXT,
price REAL
);}}
);"}
# FIXME sqlite does something different with .schema than what we are doing
#do_execsql_test_on_specific_db testing/testing_norowidalias.db schema-2 {
# .schema products
#} {"CREATE TABLE IF NOT EXISTS products (
# id INT PRIMARY KEY,
# name TEXT,
# price REAL
# );"}

View file

@ -1,13 +1,14 @@
set sqlite_exec [expr {[info exists env(SQLITE_EXEC)] ? $env(SQLITE_EXEC) : "sqlite3"}]
set test_dbs [list "testing/testing.db" "testing/testing_norowidalias.db"]
proc evaluate_sql {sqlite_exec sql} {
set command [list $sqlite_exec testing/testing.db $sql]
proc evaluate_sql {sqlite_exec db_name sql} {
set command [list $sqlite_exec $db_name $sql]
set output [exec {*}$command]
return $output
}
proc run_test {sqlite_exec sql expected_output} {
set actual_output [evaluate_sql $sqlite_exec $sql]
proc run_test {sqlite_exec db_name sql expected_output} {
set actual_output [evaluate_sql $sqlite_exec $db_name $sql]
if {$actual_output ne $expected_output} {
puts "Test FAILED: '$sql'"
puts "returned '$actual_output'"
@ -17,8 +18,17 @@ proc run_test {sqlite_exec sql expected_output} {
}
proc do_execsql_test {test_name sql_statements expected_outputs} {
puts "Running test: $test_name"
foreach db $::test_dbs {
puts [format "(%s) %s Running test: %s" $db [string repeat " " [expr {40 - [string length $db]}]] $test_name]
set combined_sql [string trim $sql_statements]
set combined_expected_output [join $expected_outputs "\n"]
run_test $::sqlite_exec $db $combined_sql $combined_expected_output
}
}
proc do_execsql_test_on_specific_db {db_name test_name sql_statements expected_outputs} {
puts [format "(%s) %s Running test: %s" $db_name [string repeat " " [expr {40 - [string length $db_name]}]] $test_name]
set combined_sql [string trim $sql_statements]
set combined_expected_output [join $expected_outputs "\n"]
run_test $::sqlite_exec $combined_sql $combined_expected_output
run_test $::sqlite_exec $db_name $combined_sql $combined_expected_output
}

Binary file not shown.