Skip to content

Commit

Permalink
Adopt resource bundles for the SPM test target.
Browse files Browse the repository at this point in the history
  • Loading branch information
GetToSet committed Oct 23, 2022
1 parent e99ced2 commit b2b5af0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 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
8 changes: 6 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.0
// swift-tools-version:5.3

import PackageDescription

Expand All @@ -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 b2b5af0

Please sign in to comment.