<#18888 Editing one test restarts unrelated tests:...
# github-notifications
c
#18888 Editing one test restarts unrelated tests: goals depend on their work too strongly Issue created by huonw Describe the bug Per #18855 (comment), some goals like
test
depend on all of the definitions of everything they run, and thus changes to one test will dirty and interrupt/restart all tests. Reproducer:
Copy code
cd $(mktemp -d)

cat > pants.toml <<EOF
[GLOBAL]
pants_version = "2.16.0rc1"
backend_packages = ["pants.backend.python"]

[python]
interpreter_constraints = [">=3.7.*"]

[anonymous-telemetry]
enabled = false
EOF

cat > test_fast.py <<EOF
def test_fast():
    pass

# $(date)
EOF

cat > test_slow.py <<EOF
import time
def test_slow():
    time.sleep(10)

# $(date)
EOF

cat > BUILD <<EOF
python_test(name="slow", source="test_slow.py")
python_test(name="fast", source="test_fast.py")
EOF

# get everything initialised
pants test test_fast.py 2> /dev/null

( sleep 9; echo -e "\n\n# change\n\n" | tee -a test_fast.py ) &

pants test ::
Running with
PANTS_SHA=0c673b95c986b57d9a0113780af087a0997c1bbb bash ./script.sh
(0c673b9) shows that: 1.
test_fast
finishes fast and
test_slow
runs for a while 2. the change happens to
test_fast
3.
test_slow
is interrupted and restarted, despite the change Running with debug logging:
PANTS_LEVEL=debug PANTS_SHA=0c673b95c986b57d9a0113780af087a0997c1bbb bash ./script.sh
. The logging after the change includes:
Copy code
# change


20:02:08.95 [DEBUG] Starting: Run Pytest - //:fast
...
20:02:09.19 [INFO] Completed: Run Pytest - //:fast - succeeded.
...
20:02:09.19 [DEBUG] Dependency @rule(pants.backend.python.goals.pytest_runner.run_python_tests(//:fast)) of Some("@rule(pants.core.goals.test.run_tests())") changed.
...
20:02:09.19 [INFO] Filesystem changed during run: retrying `@rule(pants.core.goals.test.run_tests())` in 500ms...
...
20:02:09.70 [DEBUG] Starting: Run Pytest - //:slow
...
20:02:19.95 [INFO] Completed: Run Pytest - //:slow - succeeded.
Per #18855 (comment):
i.e. that because one of the test definitions have changed (most likely the
Digest
of the inputs for the test), and because that
Digest
is actually visible to the
test
Goal in
run_tests
, the
run_tests
@goal_rule
itself ends up restarting. And when it restarts, any work that it had from its previous attempt is canceled.
So: that behavior is currently expected unfortunately, but it would probably be worth opening an issue to think about how to refactor goals to make the actual work that they are spawning more opaque.
Pants version 0c673b9 / #18855 (unreleased, but will be included in 2.17) OS macOS Additional info N/A pantsbuild/pants