Skip to content

Commit c1b79b0

Browse files
committed
Tests: adjust LMDB test harness for Windows
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`).
1 parent 4ee57a6 commit c1b79b0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Tests/SwiftDocCTests/Utility/LMDBTests.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ final class SwiftLMDBTests: XCTestCase {
2020
let tempURL = try createTemporaryDirectory()
2121

2222
environment = try! LMDB.Environment(path: tempURL.path, maxDBs: 4, mapSize: 1024 * 1024 * 1024) // 1GB of mapSize
23+
24+
// `addTeardownBlock` execute in LIFO order, which is important as we
25+
// need this to execute before the implicit closure for the cleaning of
26+
// the temporary directory.
27+
addTeardownBlock {
28+
// Explicitly close the environment to release the handles to the
29+
// database files. This is required on Windows where the files
30+
// cannot be deleted while they are open.
31+
self.environment.close()
32+
}
2333
}
2434

2535
override func tearDown() {

0 commit comments

Comments
 (0)