mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 18:18:03 +00:00
Run all tcl tests on 2 separate dbs (1. with rowid aliases 2. without rowid aliases)
This commit is contained in:
parent
949d6fecbd
commit
987a8bfb5d
3 changed files with 69 additions and 11 deletions
|
@ -3,7 +3,7 @@
|
||||||
set testdir [file dirname $argv0]
|
set testdir [file dirname $argv0]
|
||||||
source $testdir/tester.tcl
|
source $testdir/tester.tcl
|
||||||
|
|
||||||
do_execsql_test schema {
|
do_execsql_test_on_specific_db testing/testing.db schema {
|
||||||
.schema
|
.schema
|
||||||
} {"CREATE TABLE users (
|
} {"CREATE TABLE users (
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
|
@ -24,7 +24,29 @@ CREATE TABLE products (
|
||||||
);
|
);
|
||||||
CREATE INDEX age_idx on users (age);"}
|
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
|
.schema users
|
||||||
} {"CREATE TABLE users (
|
} {"CREATE TABLE users (
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
|
@ -40,10 +62,36 @@ do_execsql_test schema-1 {
|
||||||
);
|
);
|
||||||
CREATE INDEX age_idx on users (age);"}
|
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
|
.schema products
|
||||||
} {{CREATE TABLE products (
|
} {"CREATE TABLE products (
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
name TEXT,
|
name TEXT,
|
||||||
price REAL
|
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
|
||||||
|
# );"}
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
set sqlite_exec [expr {[info exists env(SQLITE_EXEC)] ? $env(SQLITE_EXEC) : "sqlite3"}]
|
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} {
|
proc evaluate_sql {sqlite_exec db_name sql} {
|
||||||
set command [list $sqlite_exec testing/testing.db $sql]
|
set command [list $sqlite_exec $db_name $sql]
|
||||||
set output [exec {*}$command]
|
set output [exec {*}$command]
|
||||||
return $output
|
return $output
|
||||||
}
|
}
|
||||||
|
|
||||||
proc run_test {sqlite_exec sql expected_output} {
|
proc run_test {sqlite_exec db_name sql expected_output} {
|
||||||
set actual_output [evaluate_sql $sqlite_exec $sql]
|
set actual_output [evaluate_sql $sqlite_exec $db_name $sql]
|
||||||
if {$actual_output ne $expected_output} {
|
if {$actual_output ne $expected_output} {
|
||||||
puts "Test FAILED: '$sql'"
|
puts "Test FAILED: '$sql'"
|
||||||
puts "returned '$actual_output'"
|
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} {
|
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_sql [string trim $sql_statements]
|
||||||
set combined_expected_output [join $expected_outputs "\n"]
|
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
|
||||||
}
|
}
|
||||||
|
|
BIN
testing/testing_norowidalias.db
Normal file
BIN
testing/testing_norowidalias.db
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue