8
8
//
9
9
10
10
11
-
12
11
#if DEPLOYMENT_RUNTIME_OBJC || os(Linux)
13
12
import Foundation
14
13
import XCTest
18
17
#endif
19
18
20
19
20
+ internal func testBundle( ) -> Bundle {
21
+ return Bundle . main
22
+ }
21
23
22
24
class TestBundle : XCTestCase {
23
25
@@ -36,29 +38,35 @@ class TestBundle : XCTestCase {
36
38
}
37
39
38
40
func test_paths( ) {
39
- let bundle = Bundle . main
40
-
41
+ let bundle = testBundle ( )
42
+
41
43
// bundlePath
42
44
XCTAssert ( !bundle. bundlePath. isEmpty)
43
45
XCTAssertEqual ( bundle. bundleURL. path, bundle. bundlePath)
44
46
let path = bundle. bundlePath
45
-
47
+
46
48
// etc
47
49
#if os(OSX)
48
50
XCTAssertEqual ( " \( path) /Contents/Resources " , bundle. resourcePath)
51
+ #if DARWIN_COMPATIBILITY_TESTS
52
+ XCTAssertEqual ( " \( path) /Contents/MacOS/DarwinCompatibilityTests " , bundle. executablePath)
53
+ #else
49
54
XCTAssertEqual ( " \( path) /Contents/MacOS/TestFoundation " , bundle. executablePath)
55
+ #endif
50
56
XCTAssertEqual ( " \( path) /Contents/Frameworks " , bundle. privateFrameworksPath)
51
57
XCTAssertEqual ( " \( path) /Contents/SharedFrameworks " , bundle. sharedFrameworksPath)
52
58
XCTAssertEqual ( " \( path) /Contents/SharedSupport " , bundle. sharedSupportPath)
53
59
#endif
54
60
55
61
XCTAssertNil ( bundle. path ( forAuxiliaryExecutable: " no_such_file " ) )
62
+ #if !DARWIN_COMPATIBILITY_TESTS
56
63
XCTAssertNil ( bundle. appStoreReceiptURL)
64
+ #endif
57
65
}
58
66
59
67
func test_resources( ) {
60
- let bundle = Bundle . main
61
-
68
+ let bundle = testBundle ( )
69
+
62
70
// bad resources
63
71
XCTAssertNil ( bundle. url ( forResource: nil , withExtension: nil , subdirectory: nil ) )
64
72
XCTAssertNil ( bundle. url ( forResource: " " , withExtension: " " , subdirectory: nil ) )
@@ -77,7 +85,7 @@ class TestBundle : XCTestCase {
77
85
}
78
86
79
87
func test_infoPlist( ) {
80
- let bundle = Bundle . main
88
+ let bundle = testBundle ( )
81
89
82
90
// bundleIdentifier
83
91
XCTAssertEqual ( " org.swift.TestFoundation " , bundle. bundleIdentifier)
@@ -93,8 +101,8 @@ class TestBundle : XCTestCase {
93
101
}
94
102
95
103
func test_localizations( ) {
96
- let bundle = Bundle . main
97
-
104
+ let bundle = testBundle ( )
105
+
98
106
XCTAssertEqual ( [ " en " ] , bundle. localizations)
99
107
XCTAssertEqual ( [ " en " ] , bundle. preferredLocalizations)
100
108
XCTAssertEqual ( [ " en " ] , Bundle . preferredLocalizations ( from: [ " en " , " pl " , " es " ] ) )
@@ -158,13 +166,13 @@ class TestBundle : XCTestCase {
158
166
}
159
167
160
168
func test_bundleLoad( ) {
161
- let bundle = Bundle . main
169
+ let bundle = testBundle ( )
162
170
let _ = bundle. load ( )
163
171
XCTAssertTrue ( bundle. isLoaded)
164
172
}
165
173
166
174
func test_bundleLoadWithError( ) {
167
- let bundleValid = Bundle . main
175
+ let bundleValid = testBundle ( )
168
176
//test valid load using loadAndReturnError
169
177
do {
170
178
try bundleValid. loadAndReturnError ( )
@@ -184,7 +192,7 @@ class TestBundle : XCTestCase {
184
192
}
185
193
186
194
func test_bundlePreflight( ) {
187
- let bundleValid = Bundle . main
195
+ let bundleValid = testBundle ( )
188
196
do {
189
197
try bundleValid. preflight ( )
190
198
} catch {
0 commit comments