Skip to content

[Plugins] Include Plugins in Manifest.targetsRequired #3623

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 2 commits into from
Sep 13, 2021

Conversation

fourplusone
Copy link
Contributor

Include Plugins in Manifest.targetsRequired

Motivation:

Fixes SR-14343. As Plugins are modeled as a dependency they also must be included the list of required targets for a product.

Modifications:

Changed the implementation of Manifest.targetsRequired to include plugins

Result:

SR-14343 is fixed

Fixes SR-14343. As Plugins are modeled as a dependency they also must be included the list of required targets for a product.
@neonichu
Copy link
Contributor

@swift-ci please smoke test


let plugins: [String] = target.pluginUsages?.compactMap { pluginUsage in
switch pluginUsage {
case .plugin(name: let name, package: nil):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be .plugin(name: let name, _):?

Copy link
Contributor Author

@fourplusone fourplusone Jul 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is, that if package is not nil .plugin(...) declares a dependency to a target in another package. Therefore it's not relevant in this context

@neonichu
Copy link
Contributor

10:23:08 Test Suite 'PackageCollectionsTests' started at 2021-07-20 10:21:53.935
10:23:08 Test Case '-[PackageCollectionsTests.PackageCollectionsTests testCollectionPendingTrustConfirmIsKeptOnAdd]' started.
10:23:08 Test Case '-[PackageCollectionsTests.PackageCollectionsTests testCollectionPendingTrustConfirmIsKeptOnAdd]' passed (0.105 seconds).
10:23:08 Exited with signal code 4

Maybe interesting for @yim-lee

@neonichu
Copy link
Contributor

@swift-ci please smoke test macOS

@yim-lee
Copy link
Contributor

yim-lee commented Jul 21, 2021

https://ci.swift.org/job/swift-package-manager-with-xcode-self-hosted-PR-osx/2239/console

Hard to tell what happened with PackageCollectionsTests. Will keep an eye on it in case it happens again.

This should help prevent it: #3629

yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Jul 21, 2021
Motivation:
Some of the package collection tests don't require search and finish quickly, so when background thread tries to `populateTargetTrie` it results in signal 4.

For [example](swiftlang#3623 (comment)):

```
10:23:08 Test Suite 'PackageCollectionsTests' started at 2021-07-20 10:21:53.935
10:23:08 Test Case '-[PackageCollectionsTests.PackageCollectionsTests testCollectionPendingTrustConfirmIsKeptOnAdd]' started.
10:23:08 Test Case '-[PackageCollectionsTests.PackageCollectionsTests testCollectionPendingTrustConfirmIsKeptOnAdd]' passed (0.105 seconds).
10:23:08 Exited with signal code 4
```

Modifications:
Set `initializeTargetTrie` to `false` for these tests such that `populateTargetTrie` is not called.
yim-lee added a commit that referenced this pull request Jul 21, 2021
Motivation:
Some of the package collection tests don't require search and finish quickly, so when background thread tries to `populateTargetTrie` it results in signal 4.

For [example](#3623 (comment)):

```
10:23:08 Test Suite 'PackageCollectionsTests' started at 2021-07-20 10:21:53.935
10:23:08 Test Case '-[PackageCollectionsTests.PackageCollectionsTests testCollectionPendingTrustConfirmIsKeptOnAdd]' started.
10:23:08 Test Case '-[PackageCollectionsTests.PackageCollectionsTests testCollectionPendingTrustConfirmIsKeptOnAdd]' passed (0.105 seconds).
10:23:08 Exited with signal code 4
```

Modifications:
Set `initializeTargetTrie` to `false` for these tests such that `populateTargetTrie` is not called.
yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Jul 26, 2021
Motivation:
Some of the package collection tests don't require search and finish quickly, so when background thread tries to `populateTargetTrie` it results in signal 4.

For [example](swiftlang#3623 (comment)):

```
10:23:08 Test Suite 'PackageCollectionsTests' started at 2021-07-20 10:21:53.935
10:23:08 Test Case '-[PackageCollectionsTests.PackageCollectionsTests testCollectionPendingTrustConfirmIsKeptOnAdd]' started.
10:23:08 Test Case '-[PackageCollectionsTests.PackageCollectionsTests testCollectionPendingTrustConfirmIsKeptOnAdd]' passed (0.105 seconds).
10:23:08 Exited with signal code 4
```

Modifications:
Set `initializeTargetTrie` to `false` for these tests such that `populateTargetTrie` is not called.
yim-lee added a commit that referenced this pull request Jul 26, 2021
* [Collections] Disable target trie in some of the tests

Motivation:
Some of the package collection tests don't require search and finish quickly, so when background thread tries to `populateTargetTrie` it results in signal 4.

For [example](#3623 (comment)):

```
10:23:08 Test Suite 'PackageCollectionsTests' started at 2021-07-20 10:21:53.935
10:23:08 Test Case '-[PackageCollectionsTests.PackageCollectionsTests testCollectionPendingTrustConfirmIsKeptOnAdd]' started.
10:23:08 Test Case '-[PackageCollectionsTests.PackageCollectionsTests testCollectionPendingTrustConfirmIsKeptOnAdd]' passed (0.105 seconds).
10:23:08 Exited with signal code 4
```

Modifications:
Set `initializeTargetTrie` to `false` for these tests such that `populateTargetTrie` is not called.

* [Collections] Don't queue populateTargetTrie if there is no data

Motivation:
`populateTargetTrie`, potentially because it's done in a background queue, causes a lot of random crashes in tests (not just in SwiftPM but other projects as well). The exception happens inside SQLite C library and it's not yet clear what the real cause is. However, since most tests do not use the package collections feature at all, `populateTargetTrie` is basically a no-op and therefore doesn't need to be queued.

Modification:
Queue `populateTargetTrie` only if there is package collection data.

This code change doesn't actually fix anything but may perhaps reduce the chance of crashing.

rdar://80840989
@abertelrud
Copy link
Contributor

Thanks for the fix, @fourplusone! The fix looks good... it would be great to also have a unit test for it. There are some test fixtures for plugins in the Fixtures/Miscellaneous/Plugins subdirectory that could be useful for this purpose.

@elsh
Copy link
Contributor

elsh commented Aug 16, 2021

Thanks for the fix, @fourplusone! The fix looks good... it would be great to also have a unit test for it. There are some test fixtures for plugins in the Fixtures/Miscellaneous/Plugins subdirectory that could be useful for this purpose.

@fourplusone do you need any additional info on adding unit tests?

@abertelrud
Copy link
Contributor

Extended a unit test to cover this. It's at abertelrud@c7fd9ec. @fourplusone, do you mind if I add that to this branch?

@fourplusone
Copy link
Contributor Author

@abertelrud Feel free to add it 🙂

…lved

# Conflicts:
#	Tests/PackageModelTests/ManifestTests.swift
@abertelrud
Copy link
Contributor

@abertelrud Feel free to add it 🙂

Great, thanks! I pushed a commit extending an existing test to cover this case. Thank you for the fix!

@abertelrud
Copy link
Contributor

@swift-ci please smoke test

@abertelrud
Copy link
Contributor

@swift-ci please smoke test linux

@abertelrud
Copy link
Contributor

Looks like all the tests pass and the reviews are in place, so merging this. Thank you for the fix!

@abertelrud abertelrud merged commit d5d3b92 into swiftlang:main Sep 13, 2021
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.

6 participants