From 592946827a2e53dd672421aed9b1a068d7943094 Mon Sep 17 00:00:00 2001 From: Louie Lu Date: Sun, 16 Jul 2017 21:08:47 +0800 Subject: [PATCH 1/2] bpo-30934: IDLE: Add Linux/MacOS coverage usage --- Lib/idlelib/idle_test/README.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Lib/idlelib/idle_test/README.txt b/Lib/idlelib/idle_test/README.txt index a54e74ddda21701..cd18054c337a9c1 100644 --- a/Lib/idlelib/idle_test/README.txt +++ b/Lib/idlelib/idle_test/README.txt @@ -215,3 +215,16 @@ rem Above opens new report; htmlcov\index.html displays report index --- The second parameter was added for tests of module x not named test_x. (There were several before modules were renamed, now only one is left.) + + +Coverage on Linux and MacOS +--- +using command line to manipulate like this: + +$ cd cpython # Goto cpython root directory +$ ./python -m coverage run --source Lib/idlelib Lib/idlelib/idle_test/test_config.py +$ ./python -m coverage report --show-missing +$ ./python -m coverage html + +You can replace `test_config.py` to the test you want to mesure, and the source +argument, you can set to specific file like `Lib/idlelib/config.py`. From 8dec3c06555493588073ab742c07cc5930b42593 Mon Sep 17 00:00:00 2001 From: Louie Lu Date: Tue, 18 Jul 2017 10:04:56 +0800 Subject: [PATCH 2/2] Add unix system how to prepare coverage --- Lib/idlelib/idle_test/README.txt | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/Lib/idlelib/idle_test/README.txt b/Lib/idlelib/idle_test/README.txt index cd18054c337a9c1..c4b21f26adf0ec4 100644 --- a/Lib/idlelib/idle_test/README.txt +++ b/Lib/idlelib/idle_test/README.txt @@ -164,7 +164,7 @@ python -m idlelib.idle_test.htest 5. Test Coverage Install the coverage package into your Python 3.6 site-packages -directory. (Its exact location depends on the OS). +directory. (Its exact location depends on the OS). > python3 -m pip install coverage (On Windows, replace 'python3 with 'py -3.6' or perhaps just 'python'.) @@ -218,13 +218,25 @@ The second parameter was added for tests of module x not named test_x. Coverage on Linux and MacOS ---- -using command line to manipulate like this: +--------------------------- + +First, install coverage in virtualenv: + +$ cd cpython # Goto cpython root directory +$ ./python -m venv venv # Create venv +$ source venv/bin/activate +$ (venv) python -m pip install coverage # Notice that is using `python`, not `./python` -$ cd cpython # Goto cpython root directory -$ ./python -m coverage run --source Lib/idlelib Lib/idlelib/idle_test/test_config.py -$ ./python -m coverage report --show-missing -$ ./python -m coverage html +then, using command line to manipulate like this: + +$ (venv) python -m coverage run --source Lib/idlelib Lib/idlelib/idle_test/test_config.py +$ (venv) python -m coverage report --show-missing +$ (venv) python -m coverage html You can replace `test_config.py` to the test you want to mesure, and the source argument, you can set to specific file like `Lib/idlelib/config.py`. + +If you don't want to do it in virtualenv, you can move coverage from venv to Lib: + +$ cp -r venv/lib/python3.7/site-packages/coverage Lib/coverage +$ ./python -m coverage run --source Lib/idlellib Lib/idlelib/idle_test/test_config.py