https://pantsbuild.org/ logo
#general
Title
# general
w

wide-zoo-86070

05/03/2022, 4:35 PM
Hi team, a (hopefully) quick question on
--changed-dependees
, suppose I have two tests in
unit/A_test.py
and
unit/B_test.py
and I only modified the
A_test.py
. It seem, if I run .
/pants --changed-since=origin/master --changed-dependees=transitive test
, the test in B_test.py also got triggered even
B_test.py
does not depend on
A_test.py
. I am wondering why? it is because they shared the same BUILD file
unit/BUILD
?
h

hundreds-father-404

05/03/2022, 4:35 PM
Did you modify the build file directly?
w

wide-zoo-86070

05/03/2022, 4:35 PM
no, I only modified A_test.py
h

hundreds-father-404

05/03/2022, 4:36 PM
w

wide-zoo-86070

05/03/2022, 4:45 PM
the path command does not seems working on test modules?
h

hundreds-father-404

05/03/2022, 4:46 PM
how so? you should be able to do
./pants paths --from=helloworld/tests_a.py --to=helloworld/tests_b.py
w

wide-zoo-86070

05/03/2022, 4:46 PM
Copy code
./pants paths --from=project_a/test_helloworld/unit/greeting_test.py --to=project_a/test_helloworld/unit/translator_test.py
12:45:13.69 [ERROR] 1 Exception encountered:

  ResolveError: 'unit' was not found in namespace 'project_a/test_helloworld/unit'. Did you mean one of:
  :tests
Copy code
python_tests(name="tests", tags=["unit_test"])
This is the BUILD file under project_a/test_helloworld/unit
h

hundreds-father-404

05/03/2022, 4:50 PM
which Pants version is this? You might need to do this:
Copy code
./pants paths --from=project_a/test_helloworld/unit/greeting_test.py:tests --to=project_a/test_helloworld/unit/translator_test.py:tests
I think it used to require target addresses, and Benjy improved it to work with just file paths too in a newer Pants version
w

wide-zoo-86070

05/03/2022, 4:51 PM
Copy code
./pants paths --from=project_a/test_helloworld/unit/greeting_test.py:tests --to=project_a/test_helloworld/unit/translator_test.py:tests
12:51:33.24 [ERROR] 1 Exception encountered:

  ValueError: The destination is not a dependency of the source
it shows that translator_tests.py has no relationship with greeting_test.py.
but if I modified greeting_test.py only, with the
--changed-dependees
(e.g.
./pants --changed-since=origin/master --changed-dependees=transitive test
), the translator_test.py will run.
h

hundreds-father-404

05/03/2022, 4:56 PM
hm fishy. What if you do
./pants --changed-since=origin/master list
? That will show you what Pants thinks has changed. (To confirm it thinks only
greeting_test.py
has changed)
w

wide-zoo-86070

05/03/2022, 4:56 PM
Copy code
./pants --changed-since=origin/master list
project_a/test_helloworld/unit/greeting_test.py:tests
h

hundreds-father-404

05/03/2022, 4:57 PM
K, then
./pants dependees --transitive project_a/test_helloworld/unit/greeting_test.py:tests
?
w

wide-zoo-86070

05/03/2022, 4:58 PM
Copy code
./pants dependees --transitive project_a/test_helloworld/unit/greeting_test.py:tests

project_a/test_helloworld/unit:tests
👍 1
h

hundreds-father-404

05/03/2022, 4:59 PM
that's what I would expect. and how about
./pants dependencies --transitive project_a/test_helloworld/unit/translator_test.py:tests
?
w

wide-zoo-86070

05/03/2022, 4:59 PM
so isn’t it because they shared the same BUILD files, in particular,
python_tests(name="tests", tags=["unit_test"])
includes both of them.
h

hundreds-father-404

05/03/2022, 4:59 PM
No, that should not matter unless you directly changed the BUILD file
w

wide-zoo-86070

05/03/2022, 5:09 PM
Copy code
./pants dependencies --transitive project_a/test_helloworld/unit/translator_test.py:tests
//:dev#pytest
//dev-requirements.txt:dev
project_a/helloworld/translator/translator.py
h

hundreds-father-404

05/03/2022, 5:11 PM
okay you are right, I'm experiencing the same thing that
./pants list
is what I expect but
./pants test
is not. Thanks for pointing that out!! I will file a bug report
w

wide-zoo-86070

05/03/2022, 5:12 PM
no problem. Let me know if the issue so I can track it. Thank you!
h

hundreds-father-404

05/03/2022, 5:15 PM
I want to write good tests for this before landing to make sure we really really understand what's going on. But: https://github.com/pantsbuild/pants/issues/15313
2 Views