Repository navigation
Conversation
Adds a shared invariant checker for the files the SwiftPM tooling generates (machine paths, scheme script, Package.swift names and dependencies, deployment target, pbxproj integrity), and a lifecycle test that runs scaffold, add, sync, update and deinit on a fake app on disk and checks the invariants and byte/inode identity after each step. Test-only; runs offline in the Linux Jest job.
cipolleschi
approved these changes
Oct 20, 2026
cipolleschi
left a comment
Contributor
There was a problem hiding this comment.
Thanks. foradding some tests
|
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this in D126304581. |
This branch has not been deployed
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.
Summary:
Recent fixes to the iOS SwiftPM tooling (
scripts/spm) all fixed bugs that CI did not catch. Adopters found them first. Each fix added a test for its own bug only. The bugs fall into a few classes: output that changes when nothing changed, generated names that collide or do not resolve, values that are hard-coded instead of read from the app, machine-specific paths in files that users commit, and malformed files that Xcode tolerates.This PR adds two test-only tools that look for each class in general. They run in the existing Linux Jest job (
test_js). No production code changes.Invariant checker (
spm-invariants.js, not a test file itself). It reads the files that the tooling generates and returns a list of violations:$HOME, absolute build-setting values) inproject.pbxproj,.xcscheme, or.spm-injected.json;Package.swift, target and product names are unique (also case-insensitive) and valid C99 identifiers, and every dependency resolves, including products of local.package(path:)dependencies;.iOS(.v15), must not be above it;project.pbxprojis balanced, every referenced object ID is defined, and the frameworks in.spm-injected.jsonmatch the project.Each rule also fails when the file or field it checks is missing, so a check cannot pass by finding nothing.
Lifecycle test (
spm-lifecycle-test.js+spm-fixture-app.js). It builds a fake app on disk (deployment target 16.4), fake prebuilt artifacts for two React Native versions, and four fake libraries: one with its ownPackage.swift, one podspec-only library withmodule_namedifferent from its npm name, one scoped@acme/…package, and one autolinking plugin with a flavored framework. It then runsscaffold → add → sync → sync → update (same version) → update (next version) → deinitthroughsetup-apple-spm.js, and runs the checker after each step. It also asserts:libs/entry;updateto the same version anddeinitrestore the project and scheme byte for byte.Network access,
plutil,otool, codegen andpodare mocked, so the test runs offline on Linux.Changelog:
[INTERNAL] [ADDED] - Add regression tests for the iOS SwiftPM tooling
Test Plan:
Result: 24 suites, 1124 tests, all passed, about 23 s (on main at dd9b6c5). The two new suites take about 4 s.
Each earlier fix was undone one at a time with
git show <sha> -- ':!**/__tests__/**' | git apply -R, and the new tests failed each time:HERMES_CLI_PATHin pbxproj)libs/rewritten on every sync)yarn eslintandprettier --checkon the new files: clean.Not run: Linux locally. The
test_jsjob on this PR is the first Linux run.