fancy-motherboard-46804
03/22/2021, 4:49 PMpants. However, I’m tearing my hair out (or would be, if I had any) over a mystery problem in which pants just refuses to find a file during tests that tox has no trouble finding.
I have a structure that looks like:
services/svcA/X.py
services/svcA/Y.py
services/svcA/Z.py
services/svcA/tests/test_X.py
services/svcA/tests/test_Y.py
services/svcA/tests/test_Z.py
Inside all three test files, they import the corresponding file, i.e. inside test_X.py there is a statement import X, inside test_Y.py we have import Y, and the same for Z.
However, when I run the tests:
./pants test services/svc::
2 out of the 3 sets of tests (X and Y) pass, while the third fails with an import error, `No module named Z. However, tox passes all three tests and find Z just fine.fancy-motherboard-46804
03/22/2021, 4:52 PM./pants dependencies services/svcA shows what I might expect:
./pants dependencies services/svcA
services/svcA/X.py
services/svcA/Y.py
services/svcA/Z.py
I honestly don’t even know where to start to solve this.witty-crayon-22786
03/22/2021, 4:54 PMwitty-crayon-22786
03/22/2021, 4:54 PM./pants dependencies services/svcA/tests/test_Z.py and the other files?fancy-motherboard-46804
03/22/2021, 4:55 PMwitty-crayon-22786
03/22/2021, 4:56 PMwitty-crayon-22786
03/22/2021, 4:56 PMfancy-motherboard-46804
03/22/2021, 4:56 PMZ and not test_Z. One sec.fancy-motherboard-46804
03/22/2021, 4:57 PMtest_X and test_Y look correct (test_X has X as a dependency and same with Y), but test_Z throws an error.hundreds-father-404
03/22/2021, 4:58 PMfancy-motherboard-46804
03/22/2021, 4:58 PM./pants dependencies services/svcA/tests/test_Z.py ST 2 chore/ch1953
16:56:59.97 [ERROR] Exception caught: (pants.engine.internals.scheduler.ExecutionError)
File "/Users/winawer/.cache/pants/setup/bootstrap-Darwin-x86_64/2.3.0rc2_py38/lib/python3.8/site-packages/pants/bin/local_pants_runner.py", line 246, in run
engine_result = self._perform_run(goals)
File "/Users/winawer/.cache/pants/setup/bootstrap-Darwin-x86_64/2.3.0rc2_py38/lib/python3.8/site-packages/pants/bin/local_pants_runner.py", line 167, in _perform_run
return self._perform_run_body(goals, poll=False)
File "/Users/winawer/.cache/pants/setup/bootstrap-Darwin-x86_64/2.3.0rc2_py38/lib/python3.8/site-packages/pants/bin/local_pants_runner.py", line 184, in _perform_run_body
return self.graph_session.run_goal_rules(
File "/Users/winawer/.cache/pants/setup/bootstrap-Darwin-x86_64/2.3.0rc2_py38/lib/python3.8/site-packages/pants/init/engine_initializer.py", line 130, in run_goal_rules
exit_code = self.scheduler_session.run_goal_rule(
File "/Users/winawer/.cache/pants/setup/bootstrap-Darwin-x86_64/2.3.0rc2_py38/lib/python3.8/site-packages/pants/engine/internals/scheduler.py", line 568, in run_goal_rule
self._raise_on_error([t for _, t in throws])
File "/Users/winawer/.cache/pants/setup/bootstrap-Darwin-x86_64/2.3.0rc2_py38/lib/python3.8/site-packages/pants/engine/internals/scheduler.py", line 536, in _raise_on_error
raise ExecutionError(
Exception message: 1 Exception encountered:
Exception: Unmatched glob from file arguments: "services/svcA/tests/test_Z.py"hundreds-father-404
03/22/2021, 4:59 PMfancy-motherboard-46804
03/22/2021, 5:01 PMwitty-crayon-22786
03/22/2021, 5:01 PMwitty-crayon-22786
03/22/2021, 5:04 PMfancy-motherboard-46804
03/22/2021, 5:11 PM[GLOBAL]
pants_ignore_use_gitignore = false
pants_ignore.add = ["!services/","!services/svcA/"]
and I’m still getting the glob error.
The BUILD file is just the one that was created by `./pants tailor`:
python_tests(
name="tests",
)fancy-motherboard-46804
03/22/2021, 5:18 PMwitty-crayon-22786
03/22/2021, 5:18 PMfancy-motherboard-46804
03/22/2021, 5:18 PMwitty-crayon-22786
03/22/2021, 5:18 PMdependencies report for that file?fancy-motherboard-46804
03/22/2021, 5:18 PMpants doesn’t register Z as a dependency for test_Z.hundreds-father-404
03/22/2021, 5:18 PMdependencies --transitivewitty-crayon-22786
03/22/2021, 5:19 PMfancy-motherboard-46804
03/22/2021, 5:20 PMsvcA/BUILD or svcA/tests/BUILD? And in python_library ?witty-crayon-22786
03/22/2021, 5:23 PMpython_tests target) in svcA/tests/BUILDfancy-motherboard-46804
03/22/2021, 5:25 PMwitty-crayon-22786
03/22/2021, 5:25 PMwitty-crayon-22786
03/22/2021, 5:25 PMwitty-crayon-22786
03/22/2021, 5:26 PMX ?hundreds-father-404
03/22/2021, 5:26 PMfancy-motherboard-46804
03/22/2021, 5:30 PM/libs/libFOO
/libs/libFOO/BAR/Z.py
/services/svcA/Z.py
/services/svcA/test_Z.py
with a bunch of stuff omitted here.
And in the BUILD for the svcA/BUILD , I had to pull in the dependency:
python_library(
dependencies=["//libs/libFOO:..."],)
(in tox, I have to bring it in using an editable:)
deps =
--editable=file:///{toxinidir}../../libs/libFOO
Could that be the issue?fancy-motherboard-46804
03/22/2021, 5:32 PMX and Y (i.e. there exists /libs/libFOO/BAR/X.py) and they’re not causing an issue.fancy-motherboard-46804
03/22/2021, 5:33 PMwitty-crayon-22786
03/22/2021, 5:58 PMhundreds-father-404
03/23/2021, 7:23 AM