Skip to content

Commit

Permalink
Merge pull request #54 from GetToSet/ethanwong/spm-resource-bundle
Browse files Browse the repository at this point in the history
Adopt resource bundles for the SPM test target.
  • Loading branch information
1024jp authored Apr 29, 2023
2 parents 2166f9c + d404d99 commit 4a3fd19
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Gzip.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@
isa = PBXGroup;
children = (
2A7DC79E1FB6AFC900539D90 /* GzipTests */,
2A8219C61D65AFB300D65063 /* test.txt.gz */,
);
path = Tests;
sourceTree = "<group>";
Expand All @@ -234,6 +233,7 @@
isa = PBXGroup;
children = (
2A58A75C1B00F414005FBBC2 /* GzipTests.swift */,
2A8219C61D65AFB300D65063 /* test.txt.gz */,
);
path = GzipTests;
sourceTree = "<group>";
Expand Down
6 changes: 5 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ let package = Package(
targets: [
.target(name: "Gzip", dependencies: ["system-zlib"]),
.target(name: "system-zlib"),
.testTarget(name: "GzipTests", dependencies: ["Gzip"]),
.testTarget(
name: "GzipTests",
dependencies: ["Gzip"],
resources: [.copy("./test.txt.gz")]
),
],
swiftLanguageVersions: [
.v5,
Expand Down
5 changes: 1 addition & 4 deletions Tests/GzipTests/GzipTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,7 @@ private extension XCTestCase {
func bundleFile(name: String) -> URL {

#if SWIFT_PACKAGE
return URL(fileURLWithPath: #file)
.deletingLastPathComponent()
.deletingLastPathComponent()
.appendingPathComponent(name)
return Bundle.module.url(forResource: name, withExtension: nil)!
#else
return Bundle(for: type(of: self)).url(forResource: name, withExtension: nil)!
#endif
Expand Down
File renamed without changes.

0 comments on commit 4a3fd19

Please sign in to comment.