Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add inline tabs on Increase Test Coverage page for commands on different systems #1228

Merged
merged 4 commits into from
Nov 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 68 additions & 18 deletions testing/coverage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
Increase test coverage
======================

.. raw:: html

<script>
document.addEventListener('DOMContentLoaded', function() {
activateTab(getOS());
});
</script>

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
Expand Down Expand Up @@ -87,23 +95,35 @@ 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

Run:

.. code-block:: shell
lancegoyke marked this conversation as resolved.
Show resolved Hide resolved

./python -m venv ../cpython-venv
source ../cpython-venv/bin/activate
pip install coverage

.. tab:: macOS

./python -m venv ../cpython-venv
source ../cpython-venv/bin/activate
pip install coverage
On :ref:`most <mac-python.exe>` macOS systems run:

On :ref:`most <mac-python.exe>` macOS systems run::
.. code-block:: shell

./python.exe -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

On Windows run::
.. tab:: Windows

python.bat -m venv ..\\cpython-venv
..\\cpython-venv\\Scripts\\activate.bat
pip install coverage
Run:

.. code-block:: dosbatch
lancegoyke marked this conversation as resolved.
Show resolved Hide resolved

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
Expand Down Expand Up @@ -231,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:

.. tab:: Unix/macOS

.. code-block:: shell

make coverage

.. tab:: Windows

make coverage
.. 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

.. tab:: Windows

.. code-block:: dosbatch

make coverage-lcov
.\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.
Expand Down
Loading