Skip to content

Conversation

@hartbit
Copy link
Contributor

@hartbit hartbit commented Oct 26, 2017

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.

@hartbit hartbit requested a review from aciidgh October 26, 2017 19:28

return executableProduct
} else {
// If the executably is implicit, search through root products.
Copy link
Contributor

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>
Copy link
Contributor

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?

Copy link
Contributor Author

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"
])
Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

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"])
Copy link
Contributor

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"))
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you elaborate?

Copy link
Contributor

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"))
Copy link
Contributor

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

@aciidgh
Copy link
Contributor

aciidgh commented Oct 26, 2017

Thanks @hartbit! Looks good, I added some minor feedback.

}

// Always build everything for the test target.
test.outputs += newTarget.outputs
Copy link
Contributor

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?

Copy link
Contributor Author

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:

llbuild_manifests.zip

@hartbit hartbit force-pushed the build-unreachable-products-and-targets branch from 178e83a to 527a735 Compare November 28, 2017 23:33
@aciidgh aciidgh removed their assignment Nov 30, 2017
@hartbit
Copy link
Contributor Author

hartbit commented Nov 30, 2017

@swift-ci please smoke test

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