From e0a209908b86fc9cd54f8479219354f57aa11cbd Mon Sep 17 00:00:00 2001 From: Nuno Cruces Date: Thu, 2 May 2024 23:22:43 +0100 Subject: [PATCH] Enable more tests. --- driver/driver_test.go | 9 +++++++-- driver/example_test.go | 2 +- tests/backup_test.go | 6 ++++-- tests/bradfitz/sql_test.go | 2 +- tests/parallel/parallel_test.go | 13 +++++++++++-- tests/wal_test.go | 9 ++++++--- vfs/lock_test.go | 6 ++++-- vfs/tests/mptest/mptest_test.go | 18 ++++++++++++++++-- 8 files changed, 50 insertions(+), 15 deletions(-) diff --git a/driver/driver_test.go b/driver/driver_test.go index 1c8c2ed..353783c 100644 --- a/driver/driver_test.go +++ b/driver/driver_test.go @@ -1,5 +1,3 @@ -//go:build !sqlite3_nosys - package driver import ( @@ -17,6 +15,7 @@ import ( _ "github.com/ncruces/go-sqlite3/embed" "github.com/ncruces/go-sqlite3/internal/util" _ "github.com/ncruces/go-sqlite3/tests/testcfg" + "github.com/ncruces/go-sqlite3/vfs" ) func Test_Open_dir(t *testing.T) { @@ -82,6 +81,9 @@ func Test_Open_pragma_invalid(t *testing.T) { } func Test_Open_txLock(t *testing.T) { + if !vfs.SupportsFileLocking { + t.Skip("skipping without locks") + } t.Parallel() db, err := sql.Open("sqlite3", "file:"+ @@ -128,6 +130,9 @@ func Test_Open_txLock_invalid(t *testing.T) { } func Test_BeginTx(t *testing.T) { + if !vfs.SupportsFileLocking { + t.Skip("skipping without locks") + } t.Parallel() ctx, cancel := context.WithCancel(context.Background()) diff --git a/driver/example_test.go b/driver/example_test.go index 161c338..c1c8613 100644 --- a/driver/example_test.go +++ b/driver/example_test.go @@ -1,4 +1,4 @@ -//go:build !sqlite3_nosys +//go:build (linux || darwin || windows || freebsd) && !sqlite3_nosys package driver_test diff --git a/tests/backup_test.go b/tests/backup_test.go index 980ed4c..1cefe66 100644 --- a/tests/backup_test.go +++ b/tests/backup_test.go @@ -1,5 +1,3 @@ -//go:build !sqlite3_nosys - package tests import ( @@ -9,9 +7,13 @@ import ( "github.com/ncruces/go-sqlite3" _ "github.com/ncruces/go-sqlite3/embed" _ "github.com/ncruces/go-sqlite3/tests/testcfg" + "github.com/ncruces/go-sqlite3/vfs" ) func TestBackup(t *testing.T) { + if !vfs.SupportsFileLocking { + t.Skip("skipping without locks") + } t.Parallel() backupName := filepath.Join(t.TempDir(), "backup.db") diff --git a/tests/bradfitz/sql_test.go b/tests/bradfitz/sql_test.go index 2e0e8ae..f12e28e 100644 --- a/tests/bradfitz/sql_test.go +++ b/tests/bradfitz/sql_test.go @@ -1,4 +1,4 @@ -//go:build !sqlite3_nosys +//go:build (linux || darwin || windows || freebsd) && !sqlite3_nosys package bradfitz diff --git a/tests/parallel/parallel_test.go b/tests/parallel/parallel_test.go index 40675c5..094c812 100644 --- a/tests/parallel/parallel_test.go +++ b/tests/parallel/parallel_test.go @@ -1,5 +1,3 @@ -//go:build !sqlite3_nosys - package tests import ( @@ -21,6 +19,10 @@ import ( ) func Test_parallel(t *testing.T) { + if !vfs.SupportsFileLocking { + t.Skip("skipping without locks") + } + var iter int if testing.Short() { iter = 1000 @@ -65,6 +67,10 @@ func Test_memdb(t *testing.T) { } func Test_adiantum(t *testing.T) { + if !vfs.SupportsFileLocking { + t.Skip("skipping without locks") + } + var iter int if testing.Short() { iter = 1000 @@ -81,6 +87,9 @@ func Test_adiantum(t *testing.T) { } func TestMultiProcess(t *testing.T) { + if !vfs.SupportsFileLocking { + t.Skip("skipping without locks") + } if testing.Short() { t.Skip("skipping in short mode") } diff --git a/tests/wal_test.go b/tests/wal_test.go index 711fc88..017ed57 100644 --- a/tests/wal_test.go +++ b/tests/wal_test.go @@ -1,5 +1,3 @@ -//go:build !sqlite3_nosys - package tests import ( @@ -14,6 +12,9 @@ import ( ) func TestWAL_enter_exit(t *testing.T) { + if !vfs.SupportsFileLocking { + t.Skip("skipping without locks") + } t.Parallel() file := filepath.Join(t.TempDir(), "test.db") @@ -49,7 +50,6 @@ func TestWAL_readonly(t *testing.T) { if !vfs.SupportsSharedMemory { t.Skip("skipping without shared memory") } - t.Parallel() tmp := filepath.Join(t.TempDir(), "test.db") @@ -76,6 +76,9 @@ func TestWAL_readonly(t *testing.T) { } func TestConn_WalCheckpoint(t *testing.T) { + if !vfs.SupportsFileLocking { + t.Skip("skipping without locks") + } t.Parallel() file := filepath.Join(t.TempDir(), "test.db") diff --git a/vfs/lock_test.go b/vfs/lock_test.go index 7b482f5..72ce24a 100644 --- a/vfs/lock_test.go +++ b/vfs/lock_test.go @@ -1,5 +1,3 @@ -//go:build !sqlite3_nosys - package vfs import ( @@ -13,6 +11,10 @@ import ( ) func Test_vfsLock(t *testing.T) { + if !SupportsFileLocking { + t.Skip("skipping without locks") + } + name := filepath.Join(t.TempDir(), "test.db") // Create a temporary file. diff --git a/vfs/tests/mptest/mptest_test.go b/vfs/tests/mptest/mptest_test.go index 78e2515..82ed918 100644 --- a/vfs/tests/mptest/mptest_test.go +++ b/vfs/tests/mptest/mptest_test.go @@ -1,5 +1,3 @@ -//go:build !sqlite3_nosys - package mptest import ( @@ -104,6 +102,10 @@ func system(ctx context.Context, mod api.Module, ptr uint32) uint32 { } func Test_config01(t *testing.T) { + if !vfs.SupportsFileLocking { + t.Skip("skipping without locks") + } + ctx := util.NewContext(newContext(t)) name := filepath.Join(t.TempDir(), "test.db") cfg := config(ctx).WithArgs("mptest", name, "config01.test") @@ -121,6 +123,9 @@ func Test_config02(t *testing.T) { if os.Getenv("CI") != "" { t.Skip("skipping in CI") } + if !vfs.SupportsFileLocking { + t.Skip("skipping without locks") + } ctx := util.NewContext(newContext(t)) name := filepath.Join(t.TempDir(), "test.db") @@ -139,6 +144,9 @@ func Test_crash01(t *testing.T) { if os.Getenv("CI") != "" { t.Skip("skipping in CI") } + if !vfs.SupportsFileLocking { + t.Skip("skipping without locks") + } ctx := util.NewContext(newContext(t)) name := filepath.Join(t.TempDir(), "test.db") @@ -154,6 +162,9 @@ func Test_multiwrite01(t *testing.T) { if testing.Short() { t.Skip("skipping in short mode") } + if !vfs.SupportsFileLocking { + t.Skip("skipping without locks") + } ctx := util.NewContext(newContext(t)) name := filepath.Join(t.TempDir(), "test.db") @@ -241,6 +252,9 @@ func Test_crash01_adiantum(t *testing.T) { if os.Getenv("CI") != "" { t.Skip("skipping in CI") } + if !vfs.SupportsFileLocking { + t.Skip("skipping without locks") + } ctx := util.NewContext(newContext(t)) name := "file:" + filepath.Join(t.TempDir(), "test.db") +