Skip to content

Commit 762a89e

Browse files
committed
Try to programmatically pick reserved names that aren't configured instead of hoping they aren't
1 parent 28a275d commit 762a89e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Tests/TestingTests/AttachmentTests.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,13 @@ struct AttachmentTests {
100100

101101
#if os(Windows)
102102
static let maximumNameCount = Int(_MAX_FNAME)
103-
static let reservedNames = ["COM9", "LPT9"]
103+
static let reservedNames: [String] = {
104+
// Return the list of COM ports that are NOT configured (and so will fail
105+
// to open for writing.)
106+
(0...9).lazy
107+
.flatMap { ["COM\($0)", "LPT\($0)"] }
108+
.filter { !PathFileExistsA($0) }
109+
}()
104110
#else
105111
static let maximumNameCount = Int(NAME_MAX)
106112
static let reservedNames: [String] = []

0 commit comments

Comments
 (0)