Skip to content

Commit 3a9fb7f

Browse files
authored
Simplify building and testing in Xcode (#723)
1 parent 7b2187b commit 3a9fb7f

File tree

3 files changed

+8
-76
lines changed

3 files changed

+8
-76
lines changed

Makefile

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ else
55
FILTERARG =
66
endif
77

8-
ifdef DOCSVERSION
9-
DOCSARG = --module-version $(DOCSVERSION)
10-
else
11-
DOCSARG =
12-
endif
13-
148
# if no value provided assume sourcery is in the user's PATH
159
SOURCERY ?= sourcery
1610

@@ -21,13 +15,6 @@ endef
2115
all:
2216
swift build -v
2317

24-
# project generates the .xcodeproj, and then modifies it to add
25-
# spec .JSON files to the project
26-
project:
27-
swift package generate-xcodeproj
28-
@$(call check_for_gem,xcodeproj)
29-
ruby etc/add_json_files.rb
30-
3118
exports:
3219
$(SOURCERY) --sources Sources/MongoSwift/ --templates Sources/MongoSwiftSync/Exports.stencil --output Sources/MongoSwiftSync/Exports.swift
3320

@@ -48,8 +35,6 @@ coverage:
4835
xcrun llvm-cov export -format="lcov" .build/debug/mongo-swift-driverPackageTests.xctest/Contents/MacOS/mongo-swift-driverPackageTests -instr-profile .build/debug/codecov/default.profdata > info.lcov
4936

5037
clean:
51-
rm -rf Packages
5238
rm -rf .build
53-
rm -rf MongoSwift.xcodeproj
5439
rm Package.resolved
5540

Sources/TestsCommon/SpecTestUtils.swift

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,15 @@ import NIO
44
import XCTest
55

66
extension MongoSwiftTestCase {
7-
/// Gets the path of the directory containing spec files, depending on whether
8-
/// we're running from XCode or the command line
7+
/// Gets the path of the directory containing spec files.
98
static var specsPath: String {
10-
// if we can access the "/Tests" directory, assume we're running from command line
11-
if FileManager.default.fileExists(atPath: "./Tests") {
12-
return "./Tests/Specs"
13-
}
14-
// otherwise we're in Xcode, get the bundle's resource path
15-
guard let path = Bundle(for: self).resourcePath else {
16-
XCTFail("Missing resource path")
17-
return ""
18-
}
19-
return path
9+
// Approach taken from https://stackoverflow.com/a/58034307
10+
// TODO: SWIFT-1442 Once we drop Swift < 5.3 we can switch to including the JSON files as Resources via our
11+
// package manifest instead.
12+
let thisFile = URL(fileURLWithPath: #file)
13+
// We are in Sources/TestsCommon/SpecTestUtils.swift; drop 3 components to get up to the root directory.
14+
let baseDirectory = thisFile.deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent()
15+
return baseDirectory.appendingPathComponent("Tests").appendingPathComponent("Specs").path
2016
}
2117
}
2218

etc/add_json_files.rb

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)