A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/lackhove/coverage-sh below:

lackhove/coverage-sh: A Coverage.py plugin to measure code coverage of shell (sh or bash) scripts executed from python.

A Coverage.py plugin to measure code coverage of shell (sh or bash) scripts executed from python.

In your pyproject.toml, set

[tool.coverage.run]
plugins = ["coverage_sh"]

and run

coverage run main.py
coverage combine
coverage html

to measure coverage of all shell scripts executed via the subprocess module, e.g.:

subprocess.run(["bash", "test.sh"])

The resulting coverage is then displayed alongside the coverage of the python files:

The plugin works by patching the subprocess.Popen class to set the "ENV" and "BASH_ENV" environment variables before execution, to source a helper script which enables tracing. This approach comes with a few caveats:

When using the subprocess modue is not an option, coverage-sh can operate in "cover-always-mode", which is activated by setting

[tool.coverage.coverage_sh]
cover_always = true

in the pyproject.toml. In this mode, Coverage.sh will not respect the coverage.start() and coverage.stop() calls and instead cover every shell script executed after the plugin gets loaded until the main process is finished. This mode is also incompatible with the popular pytest-cov but works with starting pytest from coverage , e.g.:

coverage run -m pytest arg1 arg2 arg3

Licensed under the MIT License.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4