From dc4da72569677d0c5292cec165d2f9619f9c6f5e Mon Sep 17 00:00:00 2001 From: Lance Goyke Date: Sat, 18 Nov 2023 07:57:16 -0600 Subject: [PATCH 1/4] Add inline tabs on Increase Test Coverage page for commands on different systems --- testing/coverage.rst | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/testing/coverage.rst b/testing/coverage.rst index 0ebaf4b02..205903544 100644 --- a/testing/coverage.rst +++ b/testing/coverage.rst @@ -87,23 +87,31 @@ just built, and this built version of Python will not see packages installed into your default version of Python. One option is to use a virtual environment to install coverage. -On Unix run:: +.. tab:: Unix - ./python -m venv ../cpython-venv - source ../cpython-venv/bin/activate - pip install coverage + .. code-block:: shell -On :ref:`most ` macOS systems run:: + ./python -m venv ../cpython-venv + source ../cpython-venv/bin/activate + pip install coverage - ./python.exe -m venv ../cpython-venv - source ../cpython-venv/bin/activate - pip install coverage +.. tab:: macOS -On Windows run:: + On :ref:`most ` macOS systems run: - python.bat -m venv ..\\cpython-venv - ..\\cpython-venv\\Scripts\\activate.bat - pip install coverage + .. code-block:: shell + + ./python.exe -m venv ../cpython-venv + source ../cpython-venv/bin/activate + pip install coverage + +.. tab:: Windows + + .. code-block:: dosbatch + + python.bat -m venv ..\\cpython-venv + ..\\cpython-venv\\Scripts\\activate.bat + pip install coverage You can now use python without the ./ for the rest of these instructions, as long as your venv is activated. For more info on venv see `Virtual Environment From c7dee8206a7ab61db8ae1c96f92056de0c6c9dca Mon Sep 17 00:00:00 2001 From: Lance Goyke Date: Sat, 18 Nov 2023 11:12:28 -0600 Subject: [PATCH 2/4] simplify prompts --- testing/coverage.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/testing/coverage.rst b/testing/coverage.rst index 205903544..7ba5719a1 100644 --- a/testing/coverage.rst +++ b/testing/coverage.rst @@ -89,6 +89,8 @@ to install coverage. .. tab:: Unix + Run: + .. code-block:: shell ./python -m venv ../cpython-venv @@ -107,6 +109,8 @@ to install coverage. .. tab:: Windows + Run: + .. code-block:: dosbatch python.bat -m venv ..\\cpython-venv From f4e0aec9d44bda1c2edd0b5200a6fad26ec579bc Mon Sep 17 00:00:00 2001 From: Lance Goyke Date: Sat, 18 Nov 2023 11:12:37 -0600 Subject: [PATCH 3/4] add getOS() script --- testing/coverage.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/testing/coverage.rst b/testing/coverage.rst index 7ba5719a1..8b5caf83c 100644 --- a/testing/coverage.rst +++ b/testing/coverage.rst @@ -4,6 +4,14 @@ Increase test coverage ====================== +.. raw:: html + + + Python development follows a practice that all semantic changes and additions to the language and :abbr:`stdlib (standard library)` are accompanied by appropriate unit tests. Unfortunately Python was in existence for a long time From 11e66b51df71823ed3ca94578894d22735b7d4a4 Mon Sep 17 00:00:00 2001 From: Lance Goyke Date: Sun, 19 Nov 2023 06:50:40 -0600 Subject: [PATCH 4/4] add commands for make --- testing/coverage.rst | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/testing/coverage.rst b/testing/coverage.rst index 8b5caf83c..f0da94349 100644 --- a/testing/coverage.rst +++ b/testing/coverage.rst @@ -251,19 +251,49 @@ Measuring coverage of C code with gcov and lcov It's also possible to measure the function, line and branch coverage of Python's C code. Right now only GCC with `gcov`_ is supported. In order to -create an instrumented build of Python with gcov, run:: +create an instrumented build of Python with gcov, run: - make coverage +.. tab:: Unix/macOS + + .. code-block:: shell + + make coverage + +.. tab:: Windows + + .. code-block:: dosbatch + + .\make coverage Then run some code and gather coverage data with the ``gcov`` command. In -order to create a HTML report you can install `lcov`_. The command:: +order to create a HTML report you can install `lcov`_. The command: + +.. tab:: Unix/macOS + + .. code-block:: shell + + make coverage-lcov - make coverage-lcov +.. tab:: Windows + + .. code-block:: dosbatch + + .\make coverage-lcov assembles coverage data, removes 3rd party and system libraries and finally -creates a report. You can skip both steps and just run:: +creates a report. You can skip both steps and just run: + +.. tab:: Unix/macOS + + .. code-block:: shell + + make coverage-report + +.. tab:: Windows + + .. code-block:: dosbatch - make coverage-report + .\make coverage-report if you like to generate a coverage report for Python's stdlib tests. It takes about 20 to 30 minutes on a modern computer.