-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Allow build & run to reference unreachable targets #1381
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
Allow build & run to reference unreachable targets #1381
Conversation
Sources/Commands/SwiftRunTool.swift
Outdated
|
|
||
| return executableProduct | ||
| } else { | ||
| // If the executably is implicit, search through root products. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/executably/executable/
|
|
||
| /// Returns list of all targets (reachable from root targets) in the graph. | ||
| public let targets: [ResolvedTarget] | ||
| public let targets: Set<ResolvedTarget> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we call this reachableTargets?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. Also renamed products to reachableProducts.
| "BTargetTests", | ||
| "ATargetTests", | ||
| "BTarget" | ||
| ]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should sort the keys for deterministic order
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't the conversion to a Set already handle that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right
| XCTAssertEqual(Set(graph.products.map({ $0.name })), ["aexec", "BLibrary"]) | ||
| XCTAssertEqual(Set(graph.targets.map({ $0.name })), ["ATarget", "BTarget1"]) | ||
| XCTAssertEqual(Set(graph.allProducts.map({ $0.name })), ["aexec", "BLibrary", "bexec", "cexec"]) | ||
| XCTAssertEqual(Set(graph.allTargets.map({ $0.name })), ["ATarget", "BTarget1", "BTarget2", "CTarget"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should sort these sets for deterministic order
| XCTAssert(!output.contains("bexec")) | ||
| XCTAssert(!output.contains("BTarget2")) | ||
| XCTAssert(!output.contains("cexec")) | ||
| XCTAssert(!output.contains("CTarget")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably better to check the build data than the output
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As in check that the expected files are present inside the .build directory
| XCTAssert(!output.contains("bexec")) | ||
| XCTAssert(!output.contains("BTarget1")) | ||
| XCTAssert(!output.contains("BTarget2")) | ||
| XCTAssert(!output.contains("cexec")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should test that we only build things required by CTarget
|
Thanks @hartbit! Looks good, I added some minor feedback. |
ab8c5f8 to
178e83a
Compare
| } | ||
|
|
||
| // Always build everything for the test target. | ||
| test.outputs += newTarget.outputs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean we will end up compiling tests from other packages for when building tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because the code only runs whenbuildByDefault is true, which is set to plan.graph.reachableTargets.contains(target) on line 91. See below the vapor build manifest output from a master build of swiftpm vs with this branch:
178e83a to
527a735
Compare
|
@swift-ci please smoke test |
This reintroduces PR #1284 that was reverted before the release of Swift 4 because of a bug referenced in SR-5595. The original code was modified to pass the new test that was added in 4b74cec to support external test targets on Linux.
This resolves SR-5597.