88//
99
1010
11-
1211#if DEPLOYMENT_RUNTIME_OBJC || os(Linux)
1312 import Foundation
1413 import XCTest
1817#endif
1918
2019
20+ internal func testBundle( ) -> Bundle {
21+ return Bundle . main
22+ }
2123
2224class TestBundle : XCTestCase {
2325
@@ -36,29 +38,35 @@ class TestBundle : XCTestCase {
3638 }
3739
3840 func test_paths( ) {
39- let bundle = Bundle . main
40-
41+ let bundle = testBundle ( )
42+
4143 // bundlePath
4244 XCTAssert ( !bundle. bundlePath. isEmpty)
4345 XCTAssertEqual ( bundle. bundleURL. path, bundle. bundlePath)
4446 let path = bundle. bundlePath
45-
47+
4648 // etc
4749 #if os(OSX)
4850 XCTAssertEqual ( " \( path) /Contents/Resources " , bundle. resourcePath)
51+ #if DARWIN_COMPATIBILITY_TESTS
52+ XCTAssertEqual ( " \( path) /Contents/MacOS/DarwinCompatibilityTests " , bundle. executablePath)
53+ #else
4954 XCTAssertEqual ( " \( path) /Contents/MacOS/TestFoundation " , bundle. executablePath)
55+ #endif
5056 XCTAssertEqual ( " \( path) /Contents/Frameworks " , bundle. privateFrameworksPath)
5157 XCTAssertEqual ( " \( path) /Contents/SharedFrameworks " , bundle. sharedFrameworksPath)
5258 XCTAssertEqual ( " \( path) /Contents/SharedSupport " , bundle. sharedSupportPath)
5359 #endif
5460
5561 XCTAssertNil ( bundle. path ( forAuxiliaryExecutable: " no_such_file " ) )
62+ #if !DARWIN_COMPATIBILITY_TESTS
5663 XCTAssertNil ( bundle. appStoreReceiptURL)
64+ #endif
5765 }
5866
5967 func test_resources( ) {
60- let bundle = Bundle . main
61-
68+ let bundle = testBundle ( )
69+
6270 // bad resources
6371 XCTAssertNil ( bundle. url ( forResource: nil , withExtension: nil , subdirectory: nil ) )
6472 XCTAssertNil ( bundle. url ( forResource: " " , withExtension: " " , subdirectory: nil ) )
@@ -77,7 +85,7 @@ class TestBundle : XCTestCase {
7785 }
7886
7987 func test_infoPlist( ) {
80- let bundle = Bundle . main
88+ let bundle = testBundle ( )
8189
8290 // bundleIdentifier
8391 XCTAssertEqual ( " org.swift.TestFoundation " , bundle. bundleIdentifier)
@@ -93,8 +101,8 @@ class TestBundle : XCTestCase {
93101 }
94102
95103 func test_localizations( ) {
96- let bundle = Bundle . main
97-
104+ let bundle = testBundle ( )
105+
98106 XCTAssertEqual ( [ " en " ] , bundle. localizations)
99107 XCTAssertEqual ( [ " en " ] , bundle. preferredLocalizations)
100108 XCTAssertEqual ( [ " en " ] , Bundle . preferredLocalizations ( from: [ " en " , " pl " , " es " ] ) )
@@ -158,13 +166,13 @@ class TestBundle : XCTestCase {
158166 }
159167
160168 func test_bundleLoad( ) {
161- let bundle = Bundle . main
169+ let bundle = testBundle ( )
162170 let _ = bundle. load ( )
163171 XCTAssertTrue ( bundle. isLoaded)
164172 }
165173
166174 func test_bundleLoadWithError( ) {
167- let bundleValid = Bundle . main
175+ let bundleValid = testBundle ( )
168176 //test valid load using loadAndReturnError
169177 do {
170178 try bundleValid. loadAndReturnError ( )
@@ -184,7 +192,7 @@ class TestBundle : XCTestCase {
184192 }
185193
186194 func test_bundlePreflight( ) {
187- let bundleValid = Bundle . main
195+ let bundleValid = testBundle ( )
188196 do {
189197 try bundleValid. preflight ( )
190198 } catch {
0 commit comments