Skip to content

Commit

Permalink
Fix Xcode unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nsc committed May 28, 2024
1 parent ca713b6 commit 55e05fd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Tests/SwiftTLSTests/XCTestHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ import XCTest

extension XCTestCase {
func path(forResource name: String) -> String {
if let value = ProcessInfo.processInfo.environment["XPC_SERVICE_NAME"],
if let value = ProcessInfo.processInfo.environment["XCTestBundlePath"] {
return Bundle(for: type(of: self)).path(forResource: name, ofType: nil)!
}
else if let value = ProcessInfo.processInfo.environment["XPC_SERVICE_NAME"],
// Xcode pre 11.4
value.contains("com.apple.dt") ||
// Xcode >= 11.4
(value.contains("com.apple.xpc.launchd") && value.hasSuffix("Xcode")) {

return Bundle(for: type(of: self)).path(forResource: name, ofType: nil)!
}

let resourcesPath = "Tests/SwiftTLSTests/Resources/"
return resourcesPath.appending(name)
}
Expand Down

0 comments on commit 55e05fd

Please sign in to comment.