fix(editor): resolve grammar queries through Bundle instead of a path built on resourceURL - #2887
Merged
Merged
Conversation
… built on resourceURL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mainhas been red since #2878. Every branch fails the same CI step:Note the doubled
Resourcesin the path.Cause
CodeLanguage.queryURL(for:)built its path by hand:That assumes
resourceURLis the bundle root. It is not, because the copied directory was itselfnamed
Resources: in the flat bundle layout SwiftPM writes on the CI toolchain,Bundlesees atop-level
Resourcesdirectory and adopts that as the bundle's resources root, soresourceURLalready ends in
/Resourcesand the appended path namesResources/Resources/....Measured with a two-bundle probe, one directory named
Resourcesand one namedQueries,identical in every other respect:
resourceURLends inresourceURL+ pathurl(forResource:withExtension:subdirectory:)Resources/tree-sitter-sql/ResourcesQueries/tree-sitter-sql/<name>.bundleXcode's own SwiftPM writes the structured layout (
Contents/Resources/Resources/...), where thehand-built path happens to land correctly. That is why it passes on a developer Mac and on the app
build, and fails only in
swift teston the runner. The shipping app was never affected.Fix
Two changes, each sufficient on its own, and the pair leaves nothing layout-dependent:
Queries, notResources, so it cannot be mistaken for a resources root.Bundle.module.url(forResource:withExtension:subdirectory:), which is theonly thing that knows where a given bundle keeps its resources.
Test
A new case asserts the invariant directly: the bundle's resource directory contains
Queriesandno directory named
Resources. The two suites that caught this keep their coverage; with thelookup returning
nilfor a file that is not there,#requirefails before thefileExistscheck.swift test --package-path Packages/TableProGrammars --force-resolved-versions: 10 tests, 0 failures.swiftlint lint --strict: 0 violations.No CHANGELOG entry: nothing here reaches a user.
What this uncovers
The job runs its package-test steps in order under
set -e, so the grammars failure was hidingwhatever came after it. With this fixed,
Run CodeEditSourceEditor package testsfails next, ona stale lockfile. That is #2889, and both have to land before Package Tests is green on
main.