Skip to content

Commit 966ab2d

Browse files
committed
Foundation: add ProcessInfo SPI for tests
Add the `_processPath` computed property on `ProcessInfo` to allow the tests to access `_CFProcessPath`. This removes the last CoreFoundation API usage in the test suite, allowing it to build on Windows which does not provide the CoreFoundation APIs to users.
1 parent b1f31ab commit 966ab2d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Foundation/ProcessInfo.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,10 @@ open class ProcessInfo: NSObject {
192192
return NSFullUserName()
193193
}
194194
}
195+
196+
// SPI for TestFoundation
197+
public extension ProcessInfo {
198+
var _processPath: String {
199+
return String(cString: _CFProcessPath())
200+
}
201+
}

TestFoundation/TestBundle.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ class TestBundle : XCTestCase {
566566
XCTAssertNotNil(maybeURL)
567567
guard let url = maybeURL else { return }
568568

569-
XCTAssertEqual(url.path, String(cString: _CFProcessPath()))
569+
XCTAssertEqual(url.path, ProcessInfo.processInfo._processPath)
570570
#endif
571571
}
572572
}

0 commit comments

Comments
 (0)