Skip to content

Commit f96749a

Browse files
deftioclaude
andcommitted
Fix Swift CI: use #filePath for fixture resolution instead of Bundle.module
SPM resource bundles can't follow symlinks in CI. Use #filePath-based path resolution to navigate to tests/fixtures/ directly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 15f947b commit f96749a

2 files changed

Lines changed: 11 additions & 12 deletions

File tree

bindings/swift/Package.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ let package = Package(
1616
.testTarget(
1717
name: "TriepackTests",
1818
dependencies: ["Triepack"],
19-
path: "Tests/TriepackTests",
20-
resources: [
21-
.copy("fixtures"),
22-
]
19+
path: "Tests/TriepackTests"
2320
),
2421
]
2522
)

bindings/swift/Tests/TriepackTests/TriepackTests.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ final class TriepackTests: XCTestCase {
88
// MARK: - Fixture Helpers
99

1010
private func fixtureURL(_ name: String) -> URL {
11-
// Try Bundle.module first (SPM resource bundle)
12-
#if swift(>=5.3)
13-
if let url = Bundle.module.url(forResource: name, withExtension: nil, subdirectory: "fixtures") {
14-
return url
15-
}
16-
#endif
17-
// Fallback: navigate from test file location to fixtures
11+
// Navigate from this source file to the shared fixtures directory.
12+
// Works with both local symlink and direct path resolution.
1813
let testFile = URL(fileURLWithPath: #filePath)
19-
let fixturesDir = testFile.deletingLastPathComponent().appendingPathComponent("fixtures")
14+
let fixturesDir = testFile
15+
.deletingLastPathComponent() // TriepackTests/
16+
.deletingLastPathComponent() // Tests/
17+
.deletingLastPathComponent() // swift/
18+
.deletingLastPathComponent() // bindings/
19+
.deletingLastPathComponent() // repo root
20+
.appendingPathComponent("tests")
21+
.appendingPathComponent("fixtures")
2022
return fixturesDir.appendingPathComponent(name)
2123
}
2224

0 commit comments

Comments
 (0)