From 2ce7ef53ca1da8ec969432ef547fe86a0846d470 Mon Sep 17 00:00:00 2001 From: Junker der Provinz Date: Sat, 14 Nov 2026 04:58:10 +0100 Subject: [PATCH] test(scanner): run multi-library and selective scan specs on Windows (#5381) (#6307) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * test(scanner): run multi-library and selective scan specs on Windows Both suites put their DB in Ginkgo's TempDir, but the shared db.Db() pool stays open until TestScanner returns, so on Windows the TempDir cleanup failed with a sharing violation. Use the same os.MkdirTemp plus best-effort RemoveAll setup as scanner_test.go and drop the skips. Signed-off-by: junkerderprovinz * test(scanner): say why the DB may stay open in the temp dir Signed-off-by: junkerderprovinz --------- Signed-off-by: junkerderprovinz Co-authored-by: junkerderprovinz Co-authored-by: Deluan Quintão --- scanner/scanner_multilibrary_test.go | 8 ++++++-- scanner/scanner_selective_test.go | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/scanner/scanner_multilibrary_test.go b/scanner/scanner_multilibrary_test.go index 488608b98..87782b4a0 100644 --- a/scanner/scanner_multilibrary_test.go +++ b/scanner/scanner_multilibrary_test.go @@ -3,6 +3,7 @@ package scanner_test import ( "context" "errors" + "os" "path/filepath" "testing/fstest" "time" @@ -41,9 +42,12 @@ var _ = Describe("Scanner - Multi-Library", Ordered, func() { } BeforeAll(func() { - tests.SkipOnWindows("SQLite file lock blocks TempDir cleanup (#TBD-path-sep-scanner)") ctx = request.WithUser(GinkgoT().Context(), model.User{ID: "123", IsAdmin: true}) - tmpDir := GinkgoT().TempDir() + // db.Db() is a process-wide singleton, so this dir may hold the open DB until + // the suite ends, and Windows can't delete an open file + tmpDir, err := os.MkdirTemp("", "scanner-test") + Expect(err).ToNot(HaveOccurred()) + DeferCleanup(func() { _ = os.RemoveAll(tmpDir) }) DeferCleanup(conf.SnapshotConfig()) conf.Update(func(c *conf.Options) { c.DbPath = filepath.Join(tmpDir, "test-scanner-multilibrary.db?_journal_mode=WAL") diff --git a/scanner/scanner_selective_test.go b/scanner/scanner_selective_test.go index f462037ca..a9c30260e 100644 --- a/scanner/scanner_selective_test.go +++ b/scanner/scanner_selective_test.go @@ -2,6 +2,7 @@ package scanner_test import ( "context" + "os" "path/filepath" "testing/fstest" "time" @@ -34,9 +35,12 @@ var _ = Describe("ScanFolders", Ordered, func() { var fsys storagetest.FakeFS BeforeAll(func() { - tests.SkipOnWindows("SQLite file lock blocks TempDir cleanup (#TBD-path-sep-scanner)") ctx = request.WithUser(GinkgoT().Context(), model.User{ID: "123", IsAdmin: true}) - tmpDir := GinkgoT().TempDir() + // db.Db() is a process-wide singleton, so this dir may hold the open DB until + // the suite ends, and Windows can't delete an open file + tmpDir, err := os.MkdirTemp("", "scanner-test") + Expect(err).ToNot(HaveOccurred()) + DeferCleanup(func() { _ = os.RemoveAll(tmpDir) }) DeferCleanup(conf.SnapshotConfig()) conf.Update(func(c *conf.Options) { c.DbPath = filepath.Join(tmpDir, "test-selective-scan.db?_journal_mode=WAL") }) log.Warn("Using DB at " + conf.Server().DbPath)