feat(cli): accept globs in --swift-test-xunit-paths - #1201
Merged
Merged
Conversation
The argument took literal filenames, so a repository with more than one test target had to spell out every file `swift test --xunit-output` wrote, and a pattern reached `File::open` verbatim and failed. `--junit-paths` has always globbed, so the same spelling meant different things depending on which argument carried it. Expansion now goes through the junit path's own, which also brings its dedupe: matches are keyed by canonical path, so a file two patterns both match -- or one reached through a symlink as well as directly -- is parsed once instead of uploading every test it holds twice. `collect_files_per_glob` took junit wrappers to read one field off each, so it now takes the globs themselves and `expand_globs` exposes the flattened result. One implementation, rather than a second one that drifts. Two consequences worth knowing. A relative value now resolves against the repo root rather than the working directory, which is what `--junit-paths` has always done and only differs when the uploader runs outside the repo. And a value naming a file that is not there no longer fails on open -- it matches nothing, exactly as a junit glob does, leaving the existing empty-results check to decide whether that is an error. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
😎 Merged successfully - details. |
They only exercise `FileSetBuilder::expand_globs`, which is public, so nothing about them needs to sit inside the module. As an integration test they exercise the crate the way its callers do and cannot quietly come to depend on a private detail. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Say what the code does and drop the rest: which argument historically expanded differently, why a test needs no toolchain, what an uploaded duplicate would look like downstream. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1201 +/- ##
==========================================
+ Coverage 83.70% 83.93% +0.22%
==========================================
Files 74 74
Lines 17652 17667 +15
==========================================
+ Hits 14776 14828 +52
+ Misses 2876 2839 -37 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dfrankland
added a commit
to trunk-io/docs2
that referenced
this pull request
Sep 15, 2026
trunk-io/analytics-cli#1201 gives the argument the expansion `--junit-paths` has always had, so "files, not globs" stops being true in the release these pages already require. One pattern reaches both files a run writes, which is a better example than naming them, so the Swift Testing and GitHub Actions snippets now glob. Note what the dedupe does while here: overlapping patterns cannot upload a test twice, which is the question a glob raises and a file list does not. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
dfrankland
requested review from
TylerJang27,
acatxnamedvirtue and
max-trunk
September 15, 2026 04:37
max-trunk
approved these changes
Sep 16, 2026
dfrankland
added a commit
to trunk-io/docs2
that referenced
this pull request
Sep 16, 2026
trunk-io/analytics-cli#1201 gives the argument the expansion `--junit-paths` has always had, so "files, not globs" stops being true in the release these pages already require. One pattern reaches both files a run writes, which is a better example than naming them, so the Swift Testing and GitHub Actions snippets now glob. Note what the dedupe does while here: overlapping patterns cannot upload a test twice, which is the question a glob raises and a file list does not. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.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.
--swift-test-xunit-pathstook literal filenames.handle_swift_test_xunitpassed each comma-split value straight toFile::open, so a pattern failed withfailed to open ./junit*.xml: No such file or directory, and a repository with several test targets had to spell out every fileswift test --xunit-outputwrote.--junit-pathshas always globbed, so one spelling of a path meant different things depending on which argument carried it.What changed
Expansion now goes through the junit path's own, which brings its dedupe with it: matches are keyed by canonical path, so a file two patterns both match — or one reached through a symlink as well as directly — is parsed once rather than uploading every test it holds twice.
collect_files_per_globonly ever readjunit_pathoff each wrapper it was given, so it now takes&[String]directly andexpand_globsexposes the flattened result. That keeps one implementation rather than a second that drifts from it.Two consequences worth a look in review
scan_from_globdoes for junit globs. Only differs when the uploader runs outside the repo it is uploading for.Neither is a break for anyone on a release: the argument only exists in
0.15.5-beta.1/beta.2.Testing
cargo test -p bundlepasses (16 + 3).cargo test -p trunk-analytics-cli --test uploadis 58 passed, 3 failed — the threeswift_test_xunittests, which needsourcekit-lspfor the declaration lookup and have no toolchain on my machine. All three fail at the same assertion, andupload_bundle_using_swift_test_xunitfails identically on unmodifiedorigin/main, so it is the environment rather than this change. CI is the real check for those three, since it puts the Swift toolchain onPATHand setsREQUIRE_LANGUAGE_SERVER.What that does verify locally: the
cases.len() == 3assertion runs before the declaration one in each, and passes in all three — including the new overlapping-glob-plus-symlink case, which is the dedupe.New coverage:
bundle: four unit tests onexpand_globs— two globs matching one file, a symlink to an already-matched file, repo-root-relative resolution, and a glob matching nothing. These need no Swift toolchain, so the expansion half is provable anywhere.cli:swift_test_xunit_paths_are_globs, anda_swift_test_xunit_file_reached_twice_is_uploaded_once, which points a symlink at one fixture file and passesxunit*.xml,xunit.xmlso three routes reach two files.Fixture setup and bundle-reading in the existing test moved into helpers the new tests share.
Follow-ups, not in this PR
analytics-uploader's README andaction.yamldescribe the input as "Takes files, not glob paths" (#144).Both are accurate until this merges and should follow it.
🤖 Generated with Claude Code