cool-easter-32542
05/03/2023, 10:11 AMtest depend on all of the definitions of everything they run, and thus changes to one test will dirty and interrupt/restart all tests.
Reproducer:
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:
# 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 theof the inputs for the test), and because thatDigestis actually visible to theDigestGoal intest, therun_testsrun_testsitself ends up restarting. And when it restarts, any work that it had from its previous attempt is canceled.@goal_rule
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