File tree Expand file tree Collapse file tree 3 files changed +12
-13
lines changed Expand file tree Collapse file tree 3 files changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,8 @@ import PackageDescription
4
4
let package = Package (
5
5
name: " swift-bson " ,
6
6
platforms: [
7
- . macOS( . v10_14)
7
+ . macOS( . v10_14) ,
8
+ . iOS( . v11)
8
9
] ,
9
10
products: [
10
11
. library( name: " SwiftBSON " , targets: [ " SwiftBSON " ] )
Original file line number Diff line number Diff line change @@ -6,19 +6,15 @@ import SwiftBSON
6
6
import XCTest
7
7
8
8
open class BSONTestCase : XCTestCase {
9
- /// Gets the path of the directory containing spec files, depending on whether
10
- /// we're running from XCode or the command line
9
+ /// Gets the path of the directory containing spec files.
11
10
static var specsPath : String {
12
- // if we can access the "/Tests" directory, assume we're running from command line
13
- if FileManager . default. fileExists ( atPath: " ./Tests " ) {
14
- return " ./Tests/Specs "
15
- }
16
- // otherwise we're in Xcode, get the bundle's resource path
17
- guard let path = Bundle ( for: self ) . resourcePath else {
18
- XCTFail ( " Missing resource path " )
19
- return " "
20
- }
21
- return path
11
+ // Approach taken from https://stackoverflow.com/a/58034307
12
+ // TODO: SWIFT-1442 Once we drop Swift < 5.3 we can switch to including the JSON files as Resources via our
13
+ // package manifest instead.
14
+ let thisFile = URL ( fileURLWithPath: #file)
15
+ // We are in Tests/SwiftBSONTests/BSONTests.swift; drop 2 components to get up to the Tests directory.
16
+ let baseDirectory = thisFile. deletingLastPathComponent ( ) . deletingLastPathComponent ( )
17
+ return baseDirectory. appendingPathComponent ( " Specs " ) . path
22
18
}
23
19
24
20
// indicates whether we are running on a 32-bit platform
Original file line number Diff line number Diff line change
1
+ #if os(macOS) // the Process APIs used do not exist on iOS, and `leaks` does not exist on Linux.
1
2
import Foundation
2
3
3
4
final class LeakCheckTests : BSONTestCase {
@@ -32,3 +33,4 @@ final class LeakCheckTests: BSONTestCase {
32
33
}
33
34
}
34
35
}
36
+ #endif
You can’t perform that action at this time.
0 commit comments