Fix Android doc test path resolution#130
Conversation
On Android, Documentation.docc is copied flat to the working directory without the Sources/SyntaxKit/ prefix. Centralize the prefix logic in resolveFilePath so test methods use short paths and Settings adds the prefix for non-Android platforms. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Code Review: Fix Android doc test path resolutionSummary: Focused, minimal fix for a real cross-platform CI issue. Changes are correct and well-scoped. Code Quality The conditional path prepending in Potential Issues 1. Logic duplication between Both independently encode Android-specific path layout knowledge. If the // NOTE: Mirrors the Android path layout assumed by docPaths.
// Both must stay in sync if the android-copy-files target changes.2. WASM fallthrough not documented
Test Coverage: Validated by the two failing Android CI tests described in the PR. No additional test infrastructure needed. Overall: Correct and appropriately minimal. Main suggestion: add a comment linking the platform path assumptions between |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 128-workflow-updates #130 +/- ##
========================================================
- Coverage 78.22% 78.15% -0.07%
========================================================
Files 126 126
Lines 4555 4555
========================================================
- Hits 3563 3560 -3
- Misses 992 995 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Code Review: Fix Android doc test path resolutionThe fix is correct and the root cause is well-explained. A few observations: Settings.swift - resolveFilePath platform coupling The non-Android branch of resolveFilePath now unconditionally prepends 'Sources/SyntaxKit/' to all relative paths. This means callers on all non-Android platforms (WASI, macOS, Linux) must pass short-form paths like 'Documentation.docc/Tutorials/...' without the prefix. The test changes do this correctly. One latent fragility: docPaths for WASI already contains the full 'Sources/SyntaxKit/...' prefix. If any code path ever called resolveFilePath with those docPaths strings on WASI, you would get double-prefixing. Right now docPaths and resolveFilePath are used independently so this is not an active bug, but a comment clarifying the expected input contract for resolveFilePath would help future callers. projectRoot fallback chain The 3-strategy fallback is reasonable for cross-platform support. Strategy 1a (Sources/ in working dir) takes priority over 1b (Documentation.docc in working dir) — the ordering seems intentional and handles the Android flat-copy case correctly. Test changes The DocumentationExampleTests.swift changes are correct — removing the 'Sources/SyntaxKit/' prefix aligns with the new resolveFilePath contract on all non-Android platforms. Minor: indentation in resolveFilePath The '#if os(Android)' block inside the else branch has 0-space indentation for the 'let resolvedPath' lines vs the surrounding code. Worth a format pass to keep SwiftFormat happy. Positives:
|
|
PR Review: Fix Android doc test path resolution Summary: This PR correctly identifies and fixes a real cross-platform path resolution issue for Android documentation tests. The core logic is sound and consistent with existing platform-conditional patterns already present in the codebase. What the fix does: On Android, the CI workflow copies Documentation.docc as a flat top-level directory without a Sources/SyntaxKit/ prefix. The fix updates resolveFilePath() to prepend Sources/SyntaxKit/ only on non-Android platforms, and updates the two specific test methods to use short-form paths. Code Quality - Strengths: Uses idiomatic compile-time #if os(Android) conditional (no runtime overhead). Consistent with the existing docPaths pattern in Settings.swift. Minimal, focused change with low regression risk. Code Quality - Minor issues:
Workflow File Changes: The three new workflow files (cleanup-caches.yml, cleanup-pr-caches.yml, codeql.yml) are good additions - cache cleanup prevents unbounded growth and CodeQL adds security scanning. These are unrelated to the core fix and could be separate PRs, but harmless here. Test Coverage: The two affected test methods will now execute correctly on Android. The generic validateAllDocumentationExamples() already worked across all platforms via docPaths. Coverage is adequate for the fix. Verdict: Approve with minor suggestions. The fix is correct and well-targeted. The issues above are non-blocking polish items. Note: the PR description has unchecked test plan boxes - worth confirming Android CI tests passed before merging. |
Summary
resolveFilePathinSettings.swiftnow prependsSources/SyntaxKit/on non-Android platformsDocumentationExampleTests.swiftuse the short-form path (Documentation.docc/Tutorials/...) without the prefixRoot cause
On Android,
Documentation.doccis copied flat to the test working directory — there's noSources/SyntaxKit/subdirectory. The two specific test methods hardcoded the full path, causing a "file doesn't exist" error.Settings.docPathsalready handled this correctly;resolveFilePathnow does too.Test plan
🤖 Generated with Claude Code
Perform an AI-assisted review on