Skip to content

Commit

Permalink
Tests: adjust LMDB test harness for Windows (#631)
Browse files Browse the repository at this point in the history
Ensure that we release the open handles before attempting to clean up
the temporary directory.  This repairs the execution of 11 tests on
Windows, bringing us to a 95% pass rate (excluding `LogHandleTests`).
  • Loading branch information
compnerd committed Jun 17, 2023
1 parent 792b9e8 commit f089d45
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Tests/SwiftDocCTests/Utility/LMDBTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ final class SwiftLMDBTests: XCTestCase {
let tempURL = try createTemporaryDirectory()

environment = try! LMDB.Environment(path: tempURL.path, maxDBs: 4, mapSize: 1024 * 1024 * 1024) // 1GB of mapSize

// `addTeardownBlock` execute in LIFO order, which is important as we
// need this to execute before the implicit closure for the cleaning of
// the temporary directory.
addTeardownBlock {
// Explicitly close the environment to release the handles to the
// database files. This is required on Windows where the files
// cannot be deleted while they are open.
self.environment.close()
}
}

override func tearDown() {
Expand Down

0 comments on commit f089d45

Please sign in to comment.