First pass on compatibility tests

With some help from GPT, add a TCL script that has similar syntax as
some of the SQLite source tree tests.
This commit is contained in:
Pekka Enberg
2024-06-19 16:10:09 +03:00
parent 70b73e7535
commit 94c827d5ae
3 changed files with 38 additions and 1 deletions

View File

@@ -21,8 +21,10 @@ jobs:
- uses: actions/checkout@v3
- name: Build
run: cargo build --verbose
- name: Run tests
- name: Run Rust tests
run: cargo test --verbose
- name: Run compatibility tests
run: make test
build-wasm:
runs-on: ubuntu-latest

View File

@@ -2,3 +2,7 @@ all:
cargo build
cargo build --package limbo-wasm --target wasm32-wasi
.PHONY: all
test: all
SQLITE_EXEC=./target/debug/limbo ./testing/all.test
.PHONY: test

31
testing/all.test Executable file
View File

@@ -0,0 +1,31 @@
#!/usr/bin/env tclsh
set sqlite_exec [expr {[info exists env(SQLITE_EXEC)] ? $env(SQLITE_EXEC) : "sqlite3"}]
proc evaluate_sql {sqlite_exec sql} {
set command [list $sqlite_exec database.db $sql]
set output [exec {*}$command]
return $output
}
proc run_test {sqlite_exec sql expected_output} {
set actual_output [evaluate_sql $sqlite_exec $sql]
if {$actual_output ne $expected_output} {
puts "Test passed: '$sql' returned '$actual_output'"
}
}
proc do_execsql_test {test_name sql_statements expected_outputs} {
puts "Running test: $test_name"
set combined_sql [join $sql_statements " "]
set combined_expected_output [join $expected_outputs "\n"]
run_test $::sqlite_exec $combined_sql $combined_expected_output
}
do_execsql_test select-1 {
SELECT 1
} {1}
do_execsql_test select-2 {
SELECT 2
} {2}