unified: Always run corpus tests - #22248
Draft
tausbn wants to merge 2 commits into
Draft
Conversation
The corpus tests skipped themselves when the `swift-syntax-parse` binary could not be launched. That was meant to keep the suite usable without a Swift toolchain, but it hid far more than it helped: a skip still reports `test result: ok`, and the message explaining why only appears under `cargo test -- --nocapture`. `scripts/update-corpus.sh` never set the variable that locates the parser, so the documented way to regenerate the corpus silently exercised nothing at all. Drop the guard, so a missing parser fails loudly, and make the parser easy to find so that failing is rare: - Resolve the parser one directory above the running executable as well as beside it. Test binaries live in `target/<profile>/deps/`, so the existing sibling lookup could never find `target/<profile>/swift-syntax-parse` and `cargo test` always fell through to `PATH`. - Report a missing binary with the command that builds it, rather than a bare `No such file or directory`. - Build the parser in `scripts/update-corpus.sh`, so regenerating the corpus works from a clean checkout. `cargo test` in `extractor` still needs the parser built first, since the extractor deliberately does not depend on the crate that provides it -- that is what keeps the Swift toolchain off the build path for the other languages. `AGENTS.md` now says so. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Now that the corpus tests no longer skip themselves, running them
requires a `swift-syntax-parse` binary — and so far the only way to get
one was `cargo build`, which needs Swift installed locally. Bazel
already builds the same binary against a hermetic swift.org toolchain,
so offer that instead and make it the default.
The wrapper script locates its Swift runtime libraries beside itself, so
it only works in the flattened layout the extractor pack uses; under
`bazel-bin`, and in the runfiles tree, the libraries are in a different
directory and it fails to start. Add a `pkg_install` target that stages
that layout into a directory, and `scripts/build-parser.sh` to run it
and print the resulting path:
export
CODEQL_EXTRACTOR_UNIFIED_SWIFT_SYNTAX_PARSE=$(scripts/build-parser.sh)
`--cargo` selects the previous behaviour, which is quicker to iterate on
when a local toolchain is available. Both pin swift-syntax 603.0.2, so
either parser produces the same trees.
`scripts/update-corpus.sh` now goes through the script and forwards its
arguments, so regenerating the corpus needs only Bazel. The staging
directory sits under `unified/target`, which is already ignored.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Changes our test setup so that the corpus tests are always run. In addition to this, it (hopefully) fixes the build so that both locally built
swift-syntax-parserbinaries and ones built using Bazel (if there isn't a local Swift toolchain) can be used.