Hi team, a (hopefully) quick question on `--change...
# general
w
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
Did you modify the build file directly?
w
no, I only modified A_test.py
h
w
the path command does not seems working on test modules?
h
how so? you should be able to do
./pants paths --from=helloworld/tests_a.py --to=helloworld/tests_b.py
w
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
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
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
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
Copy code
./pants --changed-since=origin/master list
project_a/test_helloworld/unit/greeting_test.py:tests
h
K, then
./pants dependees --transitive project_a/test_helloworld/unit/greeting_test.py:tests
?
w
Copy code
./pants dependees --transitive project_a/test_helloworld/unit/greeting_test.py:tests

project_a/test_helloworld/unit:tests
👍 1
h
that's what I would expect. and how about
./pants dependencies --transitive project_a/test_helloworld/unit/translator_test.py:tests
?
w
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
No, that should not matter unless you directly changed the BUILD file
w
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
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
no problem. Let me know if the issue so I can track it. Thank you!
h
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