-
-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Error out if the user explicitly tries to test a non-test tgt.
Previously we would apply the union filter to all targets. So `./pants test path/to:non-test-target` would noop. Now we only apply the filter to targets that originated in a glob spec, such as path/to/targets::. If the user tries to run tests on a non-test target via a single address spec then we don't apply the filter, and instead fail on attempting to cast the non-test target to the TestTarget union (which yields a sensible error message). This gives us the best of both worlds: We can give a sensible error, instead of nooping, when the user specifies a single target, but treat globs in the expected way. This required introducing the concept of the "provenance" of a BuildFileAddress. That is, the Spec it originated from. The term "source" is overloaded in this context, so we use "provenance" instead.
- Loading branch information
Showing
8 changed files
with
228 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from pants.base.specs import ( | ||
AscendantAddresses, | ||
DescendantAddresses, | ||
SiblingAddresses, | ||
SingleAddress, | ||
more_specific, | ||
) | ||
|
||
|
||
def test_more_specific(): | ||
single_address = SingleAddress(directory='foo/bar', name='baz') | ||
sibling_addresses = SiblingAddresses(directory='foo/bar') | ||
ascendant_addresses = AscendantAddresses(directory='foo/bar') | ||
descendant_addresses = DescendantAddresses(directory='foo/bar') | ||
|
||
assert single_address == more_specific(single_address, None) | ||
assert single_address == more_specific(single_address, sibling_addresses) | ||
assert single_address == more_specific(single_address, ascendant_addresses) | ||
assert single_address == more_specific(single_address, descendant_addresses) | ||
assert single_address == more_specific(None, single_address) | ||
assert single_address == more_specific(sibling_addresses, single_address) | ||
assert single_address == more_specific(ascendant_addresses, single_address) | ||
assert single_address == more_specific(descendant_addresses, single_address) | ||
|
||
assert sibling_addresses == more_specific(sibling_addresses, None) | ||
assert sibling_addresses == more_specific(sibling_addresses, ascendant_addresses) | ||
assert sibling_addresses == more_specific(sibling_addresses, descendant_addresses) | ||
assert sibling_addresses == more_specific(None, sibling_addresses) | ||
assert sibling_addresses == more_specific(ascendant_addresses, sibling_addresses) | ||
assert sibling_addresses == more_specific(descendant_addresses, sibling_addresses) | ||
|
||
assert ascendant_addresses == more_specific(ascendant_addresses, None) | ||
assert ascendant_addresses == more_specific(ascendant_addresses, descendant_addresses) | ||
assert ascendant_addresses == more_specific(None, ascendant_addresses) | ||
assert ascendant_addresses == more_specific(descendant_addresses, ascendant_addresses) | ||
|
||
assert descendant_addresses == more_specific(descendant_addresses, None) | ||
assert descendant_addresses == more_specific(None, descendant_addresses) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters