Skip to content

Commit 5577346

Browse files
authored
Merge pull request #2192 from compnerd/no-rest-for-the-wicked
TestFoundation: disable a couple of FileManager tests on Win32
2 parents 9971110 + e29486c commit 5577346

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

TestFoundation/TestFileManager.swift

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -366,15 +366,16 @@ class TestFileManager : XCTestCase {
366366
let systemSize = attrs[.systemSize] as? NSNumber
367367
XCTAssertNotNil(systemSize)
368368
XCTAssertGreaterThan(systemSize!.uint64Value, systemFreeSize!.uint64Value)
369-
370-
let systemFreeNodes = attrs[.systemFreeNodes] as? NSNumber
371-
XCTAssertNotNil(systemFreeNodes)
372-
XCTAssertNotEqual(systemFreeNodes!.uint64Value, 0)
373-
374-
let systemNodes = attrs[.systemNodes] as? NSNumber
375-
XCTAssertNotNil(systemNodes)
376-
XCTAssertGreaterThan(systemNodes!.uint64Value, systemFreeNodes!.uint64Value)
377-
369+
370+
if shouldAttemptWindowsXFailTests("FileAttributes[.systemFreeNodes], FileAttributes[.systemNodes] not implemented") {
371+
let systemFreeNodes = attrs[.systemFreeNodes] as? NSNumber
372+
XCTAssertNotNil(systemFreeNodes)
373+
XCTAssertNotEqual(systemFreeNodes!.uint64Value, 0)
374+
375+
let systemNodes = attrs[.systemNodes] as? NSNumber
376+
XCTAssertNotNil(systemNodes)
377+
XCTAssertGreaterThan(systemNodes!.uint64Value, systemFreeNodes!.uint64Value)
378+
}
378379
} catch {
379380
XCTFail("\(error)")
380381
}

TestFoundation/Utilities.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,17 @@ func shouldAttemptXFailTests(_ reason: String) -> Bool {
497497
}
498498
}
499499

500+
func shouldAttemptWindowsXFailTests(_ reason: String) -> Bool {
501+
var isOSWindows: Bool = false
502+
#if os(Windows)
503+
isOSWindows = true
504+
#endif
505+
506+
if !isOSWindows || shouldRunXFailTests { return true }
507+
try? FileHandle.standardError.write(contentsOf: Data("warning: Skipping test expected to fail with reason '\(reason)'\n".utf8))
508+
return false
509+
}
510+
500511
func appendTestCaseExpectedToFail<T: XCTestCase>(_ reason: String, _ allTests: [(String, (T) -> () throws -> Void)], into array: inout [XCTestCaseEntry]) {
501512
if shouldAttemptXFailTests(reason) {
502513
array.append(testCase(allTests))

0 commit comments

Comments
 (0)