15
15
#endif
16
16
#endif
17
17
18
- internal func testBundle( ) -> Bundle {
18
+ internal func testBundle( executable : Bool = false ) -> Bundle {
19
19
#if DARWIN_COMPATIBILITY_TESTS
20
20
for bundle in Bundle . allBundles {
21
21
if let bundleId = bundle. bundleIdentifier, bundleId == " org.swift.DarwinCompatibilityTests " , bundle. resourcePath != nil {
@@ -24,7 +24,7 @@ internal func testBundle() -> Bundle {
24
24
}
25
25
fatalError ( " Cant find test bundle " )
26
26
#else
27
- return Bundle . module
27
+ return executable ? Bundle . main : Bundle . module
28
28
#endif
29
29
}
30
30
@@ -474,13 +474,13 @@ class TestBundle : XCTestCase {
474
474
}
475
475
476
476
func test_bundleLoad( ) {
477
- let bundle = testBundle ( )
477
+ let bundle = testBundle ( executable : true )
478
478
let _ = bundle. load ( )
479
479
XCTAssertTrue ( bundle. isLoaded)
480
480
}
481
481
482
482
func test_bundleLoadWithError( ) {
483
- let bundleValid = testBundle ( )
483
+ let bundleValid = testBundle ( executable : true )
484
484
485
485
// Test valid load using loadAndReturnError
486
486
do {
@@ -503,7 +503,7 @@ class TestBundle : XCTestCase {
503
503
}
504
504
505
505
func test_bundlePreflight( ) {
506
- XCTAssertNoThrow ( try testBundle ( ) . preflight ( ) )
506
+ XCTAssertNoThrow ( try testBundle ( executable : true ) . preflight ( ) )
507
507
508
508
try ! _withEachPlaygroundLayout { ( playground) in
509
509
let bundle = Bundle ( path: playground. bundlePath) !
@@ -514,7 +514,7 @@ class TestBundle : XCTestCase {
514
514
}
515
515
516
516
func test_bundleFindExecutable( ) {
517
- XCTAssertNotNil ( testBundle ( ) . executableURL)
517
+ XCTAssertNotNil ( testBundle ( executable : true ) . executableURL)
518
518
519
519
_withEachPlaygroundLayout { ( playground) in
520
520
let bundle = Bundle ( path: playground. bundlePath) !
@@ -564,32 +564,6 @@ class TestBundle : XCTestCase {
564
564
#endif
565
565
566
566
func test_bundleForClass( ) {
567
- XCTAssertEqual ( testBundle ( ) , Bundle ( for: type ( of: self ) ) )
568
- }
569
-
570
- static var allTests : [ ( String , ( TestBundle ) -> ( ) throws -> Void ) ] {
571
- var tests : [ ( String , ( TestBundle ) -> ( ) throws -> Void ) ] = [
572
- ( " test_paths " , test_paths) ,
573
- ( " test_resources " , test_resources) ,
574
- ( " test_infoPlist " , test_infoPlist) ,
575
- ( " test_localizations " , test_localizations) ,
576
- ( " test_URLsForResourcesWithExtension " , test_URLsForResourcesWithExtension) ,
577
- ( " test_bundleLoad " , test_bundleLoad) ,
578
- ( " test_bundleLoadWithError " , test_bundleLoadWithError) ,
579
- ( " test_bundleWithInvalidPath " , test_bundleWithInvalidPath) ,
580
- ( " test_bundlePreflight " , testExpectedToFailOnWindows ( test_bundlePreflight, " Preflight checks aren't supported for DLLs " ) ) ,
581
- ( " test_bundleFindExecutable " , test_bundleFindExecutable) ,
582
- ( " test_bundleFindAuxiliaryExecutables " , test_bundleFindAuxiliaryExecutables) ,
583
- ( " test_bundleForClass " , testExpectedToFailOnWindows ( test_bundleForClass, " Functionality not yet implemented on Windows. SR-XXXX " ) ) ,
584
- ]
585
-
586
- #if NS_FOUNDATION_ALLOWS_TESTABLE_IMPORT
587
- tests. append ( contentsOf: [
588
- ( " test_mainBundleExecutableURL " , test_mainBundleExecutableURL) ,
589
- ( " test_bundleReverseBundleLookup " , test_bundleReverseBundleLookup) ,
590
- ] )
591
- #endif
592
-
593
- return tests
567
+ XCTAssertEqual ( testBundle ( executable: true ) , Bundle ( for: type ( of: self ) ) )
594
568
}
595
569
}
0 commit comments