-
-
Notifications
You must be signed in to change notification settings - Fork 652
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
Add support for source roots in V2 ./pants test
#7696
Changes from 23 commits
3cff08f
d6e8514
2c6fc06
1cf60b4
7225ad8
5c09f7f
dbeb559
2172cbc
300e7f1
f25c5b9
2b1816f
ce34286
6a5e9cd
c86e6ca
f22ea0f
6de654a
9459047
21c638b
a60cb54
cc92bac
dba4a57
f8a7d71
cebcb32
3c1462f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from __future__ import absolute_import | ||
|
||
from pants.dummies.example_source import add_two | ||
|
||
|
||
def test_external_method(): | ||
assert add_two(2) == 4 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,7 +72,7 @@ def test_passing_python_test(self): | |
plugins: SOME_TEXT | ||
collected 1 item | ||
|
||
testprojects/tests/python/pants/dummies/test_pass.py . [100%] | ||
pants/dummies/test_pass.py . [100%] | ||
|
||
=========================== 1 passed in SOME_TEXT =========================== | ||
|
||
|
@@ -95,7 +95,7 @@ def test_failing_python_test(self): | |
plugins: SOME_TEXT | ||
collected 1 item | ||
|
||
testprojects/tests/python/pants/dummies/test_fail.py F [100%] | ||
pants/dummies/test_fail.py F [100%] | ||
|
||
=================================== FAILURES =================================== | ||
__________________________________ test_fail ___________________________________ | ||
|
@@ -104,36 +104,59 @@ def test_fail(): | |
> assert False | ||
E assert False | ||
|
||
testprojects/tests/python/pants/dummies/test_fail.py:2: AssertionError | ||
pants/dummies/test_fail.py:2: AssertionError | ||
=========================== 1 failed in SOME_TEXT =========================== | ||
|
||
|
||
testprojects/tests/python/pants/dummies:failing_target ..... FAILURE | ||
"""), | ||
) | ||
|
||
def test_source_dep(self): | ||
def test_source_dep_absolute_import(self): | ||
pants_run = self.run_passing_pants_test([ | ||
'testprojects/tests/python/pants/dummies:target_with_source_dep', | ||
'testprojects/tests/python/pants/dummies:target_with_source_dep_absolute_import', | ||
]) | ||
self.assert_fuzzy_string_match( | ||
pants_run.stdout_data, | ||
dedent("""\ | ||
testprojects/tests/python/pants/dummies:target_with_source_dep stdout: | ||
testprojects/tests/python/pants/dummies:target_with_source_dep_absolute_import stdout: | ||
============================= test session starts ============================== | ||
platform SOME_TEXT | ||
rootdir: SOME_TEXT | ||
plugins: SOME_TEXT | ||
collected 1 item | ||
|
||
testprojects/tests/python/pants/dummies/test_with_source_dep.py . [100%] | ||
pants/dummies/test_with_source_dep_absolute_import.py . [100%] | ||
|
||
=========================== 1 passed in SOME_TEXT =========================== | ||
|
||
|
||
testprojects/tests/python/pants/dummies:target_with_source_dep ..... SUCCESS | ||
testprojects/tests/python/pants/dummies:target_with_source_dep_absolute_import ..... SUCCESS | ||
""") | ||
) | ||
) | ||
|
||
def test_source_dep_relative_import(self): | ||
pants_run = self.run_passing_pants_test([ | ||
'testprojects/tests/python/pants/dummies:target_with_source_dep_relative_import', | ||
]) | ||
self.assert_fuzzy_string_match( | ||
pants_run.stdout_data, | ||
dedent("""\ | ||
testprojects/tests/python/pants/dummies:target_with_source_dep_relative_import stdout: | ||
============================= test session starts ============================== | ||
platform SOME_TEXT | ||
rootdir: SOME_TEXT | ||
plugins: SOME_TEXT | ||
collected 1 item | ||
|
||
pants/dummies/test_with_source_dep_relative_import.py . [100%] | ||
|
||
=========================== 1 passed in SOME_TEXT =========================== | ||
|
||
|
||
testprojects/tests/python/pants/dummies:target_with_source_dep_relative_import ..... SUCCESS | ||
""") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I personally prefer keeping parentheses joined here instead of spreading them over a new line, but I think the style is inconsistent all over the repo. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair. For now, this is using the file convention which I'm going to stick with. This is precisely why I want to add Black to our codebase - either style works just fine, but the issue is that this statement is unfortunately true :/
|
||
) | ||
|
||
def test_thirdparty_dep(self): | ||
pants_run = self.run_passing_pants_test([ | ||
|
@@ -149,7 +172,7 @@ def test_thirdparty_dep(self): | |
plugins: SOME_TEXT | ||
collected 1 item | ||
|
||
testprojects/tests/python/pants/dummies/test_with_thirdparty_dep.py . [100%] | ||
pants/dummies/test_with_thirdparty_dep.py . [100%] | ||
|
||
=========================== 1 passed in SOME_TEXT =========================== | ||
|
||
|
@@ -173,7 +196,7 @@ def test_mixed_python_tests(self): | |
plugins: SOME_TEXT | ||
collected 1 item | ||
|
||
testprojects/tests/python/pants/dummies/test_fail.py F [100%] | ||
pants/dummies/test_fail.py F [100%] | ||
|
||
=================================== FAILURES =================================== | ||
__________________________________ test_fail ___________________________________ | ||
|
@@ -182,7 +205,7 @@ def test_fail(): | |
> assert False | ||
E assert False | ||
|
||
testprojects/tests/python/pants/dummies/test_fail.py:2: AssertionError | ||
pants/dummies/test_fail.py:2: AssertionError | ||
=========================== 1 failed in SOME_TEXT =========================== | ||
|
||
testprojects/tests/python/pants/dummies:passing_target stdout: | ||
|
@@ -192,7 +215,7 @@ def test_fail(): | |
plugins: SOME_TEXT | ||
collected 1 item | ||
|
||
testprojects/tests/python/pants/dummies/test_pass.py . [100%] | ||
pants/dummies/test_pass.py . [100%] | ||
|
||
=========================== 1 passed in SOME_TEXT =========================== | ||
|
||
|
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.
Ooh! I'm pretty sure we actually can do this now! (There were reasons we couldn't before, but I think they're all gone).
I'd be very happy to talk you through how to do this - it would look very similar to #7699 but instead of calling a new
fs::Snapshot::strip_prefix
function it would call the existingfs::Snapshot::from_digest
function.Definitely doesn't need to block this PR, but would be good to do soon :)
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.
Oh yay! I've always wanted to write Rust, so with a little guidance would be happy to do this.