Skip to content

[5.2] [sourcekit] Add global -module-cache-path to test executables #29547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 3, 2020

Conversation

benlangmuir
Copy link
Contributor

@benlangmuir benlangmuir commented Jan 30, 2020

Cherry-pick #29357 to swift-5.2-branch


Add a global -module-cache-path option to sourcekitd-test and
complete-test and have lit provide the default module cache in its
substitutions. Previously many tests have explicitly provided the
%mcp_opt option, but this is easy to forget when writing new tests.

The module cache is inserted into the compiler arguments at the
beginning so that it's still possible for a test to override it with a
per-test cache if desired.

rdar://58959228

Add a global -module-cache-path option to `sourcekitd-test` and
`complete-test` and have lit provide the default module cache in its
substitutions. Previously many tests have explicitly provided the
`%mcp_opt` option, but this is easy to forget when writing new tests.

The module cache is inserted into the compiler arguments at the
beginning so that it's still possible for a test to override it with a
per-test cache if desired.

rdar://58752842
Remove `%mcp_opt` from commands that use `%sourcekitd-test` and
`%complete-test`, as they are now redundant with the lit substitution.

Conflicts:
	test/SourceKit/CursorInfo/cursor_info.swift
When doing header interface generation, we interpret clang command-line
arguments in `initInvocationByClangArguments` and attempt to setup a
matching Swift compiler invocation. One important argument is the module
cache, but clang will only interpret `-fmodules-cache-path` if modules
are enabled (typically with `-fmodules`). While the header itself might
not need modules, Swift will import its own shims module and during
testing this needs to honour lit's provided cache. So we add -fmodules
in sourcekitd-test anytime we add -fmodules-cache-path.

rdar://58836540
@benlangmuir benlangmuir changed the base branch from master to swift-5.2-branch January 30, 2020 16:53
@benlangmuir
Copy link
Contributor Author

benlangmuir commented Jan 30, 2020

  • Explanation: Fixes an issue where certain sourcekit tests were missing a -module-cache-path, which caused non-deterministic failures in CI.
  • Scope of Issue: SourceKit tests
  • Origination: We've had on-and-off module cache issues with sourcekit tests for years that we have spot-fixed. The current round of non-deterministic CI failures is likely triggered by a recent clang change, based on timing, but they were always susceptible.
  • Risk: Low. This change only impacts tests and test tools (sourcekitd-test and complete-test).
  • Reviewed by: @nathawes
  • Bug: rdar://58959228

@swift-ci please nominate

@benlangmuir
Copy link
Contributor Author

@swift-ci please test

@benlangmuir
Copy link
Contributor Author

Update: we believe we found the change that triggered this set of failures, and fixed it in #29556. That being said, I would still like to make this change, since it makes the tests more robust against module-cache-related problems in general, particularly during local development where we do not detect the format changes reliably. It also helps avoid merge conflicts between master and 5.2 because it touches a lot of test invocations.

@benlangmuir benlangmuir merged commit ff861b4 into swiftlang:swift-5.2-branch Feb 3, 2020
@benlangmuir benlangmuir deleted the cache-path-52 branch February 3, 2020 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants