◐ Shell
clean mode source ↗

gh-108834: Cleanup libregrtest by vstinner · Pull Request #108858 · python/cpython

@vstinner

Remove "global variables" from libregrtest: no longer pass 'ns' magic
namespace which was used to get and set 'random' attributes. Instead,
each class has its own attributes, and some classes are even
read-only (frozen dataclass), like RunTests.

Reorganize files:

* Rename runtest.py to single.py.
* Rename runtest_mp.py to mp_runner.py.
* Create findtests.py, result.py, results.py and worker.py.

Reorganize classes:

* Copy command line options ('ns' namespace) to Regrtest
  and RunTests attributes: add many attributes.
* Add Results class with methods: get_state(), display_result(),
  get_exitcode(), JUnit methods, etc.
* Add Logger class: log(), display_progress(), system load tracker.
* Remove WorkerJob class: the worker now gets a RunTests instance.

Move function and methods:

* Convert Regrtest.list_cases() to a function.
* Convert display_header(), display_sanitizers(), set_temp_dir() and
  create_temp_dir() methods of Regrtest to functions in utils.py.
  Rename set_temp_dir() to select_temp_dir(). Rename
  create_temp_dir() to make_temp_dir().
* Move abs_module_name() and normalize_test_name() to utils.py.
* Move capture_output() to utils.py.
* Rename dash_R() to runtest_refleak()
* Merge display_sanitizers() code into display_header().

cmdline.py changes:

* Rename internal --worker-args command line option to --worker-json.
* Rename ns.trace to ns.coverage.
* No longer gets the number of CPUs: it's now done by Regrtest class.
* Add missing attributes to Namespace: coverage, threshold, wait.

Misc:

* Add test_parse_memlimit() and test_set_memlimit() to test_support.
* Add some type annotations.