test: add SPM + Xcode-app integration harnesses for the a11y-scan plugin#31
test: add SPM + Xcode-app integration harnesses for the a11y-scan plugin#31Crash0v3rrid3 wants to merge 1 commit into
Conversation
Adds a tests/ folder with two consumer harnesses that integrate this repo's a11y-scan command plugin (path dependency on the repo root) and run accessibility scans over sample sources with intentional issues: - tests/spm/: a SwiftPM package that declares the AccessibilityDevTools dependency and invokes the command plugin via 'swift package plugin … scan' (scripts/run-a11y-scan.sh). Includes an XCTest unit test plus a credential-gated end-to-end scan test. Verified: swift build + swift test pass and the plugin is discoverable. The plugin is intentionally NOT placed in a target's plugins: array — it is a command (not build-tool) plugin, and attaching it breaks swift build. - tests/xcode-app/: an iOS app described by an XcodeGen project.yml that runs the scan from a pre-compile build phase (the official Xcode integration), backed by a minimal Package.swift scan driver. Includes a unit-test target. project.yml validates as YAML and the scan driver resolves + exposes the plugin; the generated .xcodeproj was not built in this headless environment. Both harnesses no-op/skip without BrowserStack credentials so builds and tests stay green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Crash0v3rrid3
left a comment
There was a problem hiding this comment.
Claude Code Review (automated) — 4 inline finding(s). Full report in the PR comment below. Verdict: Passed.
| swift package plugin \ | ||
| --allow-writing-to-directory "$HOME/.cache" \ | ||
| --allow-writing-to-package-directory \ | ||
| --allow-network-connections 'all(ports: [])' \ |
There was a problem hiding this comment.
[Medium] Network-permission scope is broader than the plugin declares
all(ports: []) grants all ports, but the plugin declares .all(ports: [80, 443]). It works (and matches the repo's canonical scripts/.../spm.sh), but as a reference harness it over-grants and would break confusingly if the declared scope is tightened.
Suggestion: Use 'all(ports: [80,443])' to match the plugin's declared scope.
Reviewer: stack:code-reviewer
| try process.run() | ||
| process.waitUntilExit() | ||
|
|
||
| // --non-strict makes the scan exit 0 even when issues are found, so a |
There was a problem hiding this comment.
[Medium] Docstring overstates what this test verifies
The assertion only checks terminationStatus == 0 under --non-strict, so it confirms the plugin downloaded/authenticated/ran — not that the seeded issues in SampleViews.swift were detected. The docstring's "reports the intentional issues" overstates this.
Suggestion: Reword to make clear issue detection is not asserted (exit 0 = plugin ran). Optionally set process.environment explicitly for CI robustness.
Reviewer: stack:code-reviewer
| /// it. The accessibility scan itself runs as the app target's pre-compile | ||
| /// build phase (see project.yml), so a successful `xcodebuild test` means the | ||
| /// scan ran during the build. | ||
| func testContentViewExists() { |
There was a problem hiding this comment.
[Low] @MainActor isolation under Swift 6 strict concurrency
testContentViewExists() instantiates a @MainActor-isolated SwiftUI View from a nonisolated test context — a warning on Xcode 15+, an error in Swift 6 mode.
Suggestion: Mark the test @MainActor (or wrap in MainActor.run).
Reviewer: stack:code-reviewer
| settings: | ||
| base: | ||
| SWIFT_VERSION: "5.9" | ||
| # Required so the scan build phase can write the CLI cache to ~/.cache. |
There was a problem hiding this comment.
[Low] Sandboxing disabled globally, not just for the app target
ENABLE_USER_SCRIPT_SANDBOXING: NO in settings.base applies to the test target too, not only the app target that runs the scan build phase.
Suggestion: Move it under targets.A11yScanDemoApp.settings.base to scope it to the app target.
Reviewer: stack:code-reviewer
Claude Code PR ReviewPR: #31 • Head: 9311d3f • Reviewers: stack:code-reviewer (+ orchestrator verification) SummaryAdds a Review Table
Findings
Verification performed
Verdict: PASS — solid, well-documented test harness; all findings are Medium/Low polish on scaffolding, none blocking. Recommend addressing the docstring overstatement (F2), the |
sunny-se
left a comment
There was a problem hiding this comment.
LGTM — reviewed via harness stack:pr-review. Good integration test harnesses.
Minor nit (non-blocking): Both tests/spm/Package.swift and tests/xcode-app/Package.swift use the deprecated name: parameter for path dependencies (.package(name: "AccessibilityDevTools", path: "../..")). SwiftPM 5.9+ infers the name — should be .package(path: "../.."). Works today but may emit warnings in future toolchains.
What
Adds a
tests/folder with two consumer harnesses that integrate this repo'sa11y-scancommand plugin (via a path dependency on the repo root,../..) and run accessibility scans over sample sources containing intentional issues.tests/spm/— SwiftPM consumerAccessibilityDevToolsdependency and invokes the command plugin viaswift package plugin … scan(scripts/run-a11y-scan.sh).RUN_A11Y_SCAN=1).plugins:array —a11y-scanis a command plugin (not build-tool), and attaching it makesswift buildfail with "Plugin is declared with thebuildToolcapability…".tests/xcode-app/— Xcode appproject.yml, so the generated.xcodeprojis gitignored.Package.swiftscan driver. Unit-test target included.ENABLE_USER_SCRIPT_SANDBOXINGdisabled so the scan can write~/.cache.Both harnesses skip/no-op without
BROWSERSTACK_USERNAME/BROWSERSTACK_ACCESS_KEY, so builds and tests stay green.Verification
tests/spm:swift build✅,swift test✅ (unit test passes, scan test skips by default);swift package plugin --listshows'scan' (plugin 'a11y-scan' in package 'AccessibilityDevTools').tests/xcode-app:project.ymlvalidates as YAML; scan driver resolves and exposes the plugin; both shell scripts passbash -n.xcodegen generate+xcodebuild test(xcodegen/Xcode simulator unavailable) and a live scan (needs BrowserStack creds). Generate and run locally to validate on your toolchain.🤖 Generated with Claude Code