Skip to content

Commit c90daf8

Browse files
leogdionclaude
andcommitted
Fix test file path resolution for WASM/Android/Linux CI
Settings.projectRoot now uses a 3-strategy fallback matching the SyndiKit pattern: working directory first (reliable for WASM/Android/SPM), then #filePath-relative (macOS/Linux CI), then walking up parent directories. Add android-copy-files to copy Documentation.docc to the Android emulator's working directory so the path resolution finds the files via Strategy 1. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 9ef6549 commit c90daf8

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

.github/workflows/SyntaxKit.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ jobs:
264264
android-swift-version: ${{ matrix.swift.version }}
265265
android-api-level: ${{ matrix.android-api-level }}
266266
android-run-tests: true
267+
android-copy-files: Sources/SyntaxKit/Documentation.docc
267268
- name: Upload coverage to Codecov
268269
if: steps.build.outputs.contains-code-coverage == 'true'
269270
uses: codecov/codecov-action@v6

Tests/SyntaxDocTests/Settings.swift

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,36 @@
88
import Foundation
99

1010
internal enum Settings {
11-
/// Project root directory calculated from the current file location
11+
/// Project root directory calculated with a 3-strategy fallback for cross-platform support
1212
internal static let projectRoot: URL = {
13-
let currentFileURL = URL(fileURLWithPath: #filePath)
14-
return
15-
currentFileURL
13+
// Strategy 1: Working directory (most reliable for SPM/WASM/Android)
14+
let workingDir = URL(fileURLWithPath: FileManager.default.currentDirectoryPath)
15+
if FileManager.default.fileExists(atPath: workingDir.appendingPathComponent("Sources").path) {
16+
return workingDir
17+
}
18+
19+
// Strategy 2: Source-relative via #filePath (macOS/Linux CI)
20+
let sourceRelative = URL(fileURLWithPath: #filePath)
1621
.deletingLastPathComponent() // Tests/SyntaxDocTests
1722
.deletingLastPathComponent() // Tests
1823
.deletingLastPathComponent() // Project root
24+
if FileManager.default.fileExists(
25+
atPath: sourceRelative.appendingPathComponent("Sources").path)
26+
{
27+
return sourceRelative
28+
}
29+
30+
// Strategy 3: Walk up from working directory (nested execution contexts)
31+
var search = workingDir
32+
for _ in 0..<4 {
33+
if FileManager.default.fileExists(atPath: search.appendingPathComponent("Sources").path) {
34+
return search
35+
}
36+
search = search.deletingLastPathComponent()
37+
}
38+
39+
// Fallback — will produce a clear error if Sources/ is still not found
40+
return sourceRelative
1941
}()
2042

2143
/// Document paths to search for documentation files

0 commit comments

Comments
 (0)