Skip to content
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

improve and simplify validation of target based dependencies #3280

Merged
merged 1 commit into from
Feb 26, 2021

Conversation

tomerd
Copy link
Contributor

@tomerd tomerd commented Feb 16, 2021

motivation: SwiftPM 5.2 introduced target based dependencies which added complexity at code level and to users, this PR tries to both simplify the "rules" and the code

changes:

  • allow target dependency in the form of ".product(name:, package:)" where package parameter is the last segment of the dependency URL, which is the most intuitive choice (IMO)
  • change validation code to encourage the above form instead of encouraging adding a "name" attribute to the dependency deceleration. we want to get away from dependency::name in the long run.
  • add several tests that capture the numerous permutations we are coding for

rdar://65048461

@tomerd
Copy link
Contributor Author

tomerd commented Feb 16, 2021

@swift-ci please smoke test

@tomerd
Copy link
Contributor Author

tomerd commented Feb 16, 2021

macOS CI broken due to swift-driver cc @artemcm

@@ -1255,4 +1263,551 @@ class PackageGraphTests: XCTestCase {
let store = try PinsStore(pinsFile: AbsolutePath("/pins"), fileSystem: fs)
XCTAssertThrows(StringError("duplicated entry for package \"Yams\""), { try store.restore(from: json) })
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@neonichu @abertelrud would love to get your review on the different permutations captured in these new tests 😅 and hear your opinion on:

  1. the diagnostics make sense and are better than before, I think they are!
  2. the backward compatibility 5.2 < 5.4 looks reasonable - we allow users to use dependency::name but no longer encourage it
  3. do we need to capture more permutations?

@tomerd tomerd changed the title improve and simplify validation of target based dependencies improve and simplify validation of target based dependencies Feb 16, 2021
@tomerd tomerd self-assigned this Feb 16, 2021
@tomerd
Copy link
Contributor Author

tomerd commented Feb 16, 2021

@swift-ci please smoke test macOS

@tomerd tomerd added the ready Author believes the PR is ready to be merged & any feedback has been addressed label Feb 16, 2021
DiagnosticsEngineTester(diagnostics, ignoreNotes: true) { result in
result.check(
diagnostic: """
product 'Unknown' not found. it is required by package 'Foo' target 'Foo'.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not specific to this test, but does this kind of message now become ambiguous? It feels like conceptually we could now be referring to Package.name or to the last path component of the URL since we are treating them equally, even when they differ. I wonder if for remote packages, we should instead emit the URL here.

@neonichu
Copy link
Contributor

In terms of test coverage, I think we should also cover cases where there are multiple conflicting options:

  • URL and Package.name don't match and we have product dependencies referencing either name, explicitly and via short-hand (not sure if the short-hand is actually usable in tests)
  • two packages with distinct names but same last path component -- I think this works today (with explicit names) and might have potentially become more confusing now. In any case, would be good to have the behavior covered by a unit test
  • two packages with distinct URLs but same Package.name -- this is an error, but would be good to see if the behavior changed

I think none of these care covered, yet, but I may have missed something. There are a lot of tests which is great 👍

@tomerd
Copy link
Contributor Author

tomerd commented Feb 25, 2021

@neonichu added these test in #3308 so we can rebase this PR on top when merged and make sure they still pass

@neonichu neonichu self-requested a review February 25, 2021 21:26
motivation: SwiftPM 5.2 introduced target based dependencies which added complexity at code level and to users, this PR tries to both simplify the "rules" and the code

changes:
* allow target dependency in the form of ".product(name:, package:)" where package parameter is the last segment of the dependecy URL, which is the most intuitive choice
* change validation code to encourage the above from instead of encouraging adding "name" attibute to the dependency decleration, as we want to get away from adding this attribute in the long run
* add several tests that capture the numerous permutations we are coding for
@tomerd
Copy link
Contributor Author

tomerd commented Feb 25, 2021

@swift-ci please smoke test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready Author believes the PR is ready to be merged & any feedback has been addressed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants