From dc61158adc97fca4f5e85b3d2207ce94d1346be0 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 6 Jan 2024 06:35:19 -0500 Subject: [PATCH] debug: misc improvements to debugging --- Makefile | 5 ++++- coverage/config.py | 2 +- coverage/debug.py | 1 + lab/pick.py | 6 +++--- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index cca356b13..547c4e555 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,10 @@ clean_platform: @rm -f *.pyo */*.pyo */*/*.pyo */*/*/*.pyo */*/*/*/*.pyo */*/*/*/*/*.pyo @rm -f *$$py.class */*$$py.class */*/*$$py.class */*/*/*$$py.class */*/*/*/*$$py.class */*/*/*/*/*$$py.class -clean: clean_platform ## Remove artifacts of test execution, installation, etc. +clean_debug: + @rm -rf /tmp/dis $$COVERAGE_DEBUG_FILE + +clean: clean_debug clean_platform ## Remove artifacts of test execution, installation, etc. @echo "Cleaning..." @-pip uninstall -yq coverage @mkdir -p build # so the chmod won't fail if build doesn't exist diff --git a/coverage/config.py b/coverage/config.py index 2ea48b72c..d7d6e3e1b 100644 --- a/coverage/config.py +++ b/coverage/config.py @@ -600,7 +600,7 @@ def read_coverage_config( if specified_file: raise ConfigError(f"Couldn't read {fname!r} as a config file") - # $set_env.py: COVERAGE_DEBUG - Options for --debug. + # $set_env.py: COVERAGE_DEBUG - Debug options: https://coverage.readthedocs.io/en/latest/cmd.html#debug # 3) from environment variables: env_data_file = os.getenv("COVERAGE_FILE") if env_data_file: diff --git a/coverage/debug.py b/coverage/debug.py index 000a2cab9..8aaecb589 100644 --- a/coverage/debug.py +++ b/coverage/debug.py @@ -446,6 +446,7 @@ def get_one( if file_name is not None: fileobj = open(file_name, "a", encoding="utf-8") else: + # $set_env.py: COVERAGE_DEBUG_FILE - Where to write debug output file_name = os.getenv("COVERAGE_DEBUG_FILE", FORCED_DEBUG_FILE) if file_name in ("stdout", "stderr"): fileobj = getattr(sys, file_name) diff --git a/lab/pick.py b/lab/pick.py index 06274b4b4..ade24676c 100644 --- a/lab/pick.py +++ b/lab/pick.py @@ -17,15 +17,15 @@ as in:: - te py311 -- -vvv -n 0 --select-cmd="python lab/pick.py sample 10 < tests.txt" + te py311 -- -vvv -n 0 --cache-clear --select-cmd="python lab/pick.py sample 10 < tests.txt" or:: - for n in 1 1 2 2 3 3; do te py311 -- -vvv -n 0 --select-cmd="python lab/pick.py sample 3 $n < tests.txt"; done + for n in 1 1 2 2 3 3; do te py311 -- -vvv -n 0 --cache-clear --select-cmd="python lab/pick.py sample 3 $n < tests.txt"; done or:: - for n in $(seq 1 10); do echo seed=$n; COVERAGE_COVERAGE=yes te py311 -- -n 0 --select-cmd="python lab/pick.py sample 20 $n < tests.txt"; done + for n in $(seq 1 10); do echo seed=$n; COVERAGE_COVERAGE=yes te py311 -- -n 0 --cache-clear --select-cmd="python lab/pick.py sample 20 $n < tests.txt"; done """