Debian Codegraph @

test/integration/targets/ansible-test-coverage/runme.sh

raw
1 #!/usr/bin/env bash
2
3 source ../collection/setup.sh
4
5 set -x
6
7 # common args for all tests
8 common=(--venv --color --truncate 0 "${@}")
9
10 # run a lightweight test that generates code coverage output
11 ansible-test sanity --test import "${common[@]}" --coverage --python "${ANSIBLE_TEST_PYTHON_VERSION}"
12
13 # run an integration test that generates code coverage for a Python file within the integration test
14 ansible-test integration "${common[@]}" --coverage
15
16 # run a unit test that generates code coverage using a venv
17 ansible-test units "${common[@]}" --coverage --python "${ANSIBLE_TEST_PYTHON_VERSION}" --venv
18
19 # report on code coverage in all supported formats
20 ansible-test coverage report "${common[@]}" | tee coverage.report
21 ansible-test coverage html "${common[@]}"
22 ansible-test coverage xml "${common[@]}"
23
24 # ensure import test coverage was collected
25 grep '^plugins/module_utils/test_util.py .* 100%$' coverage.report
26
27 # ensure integration test coverage was collected
28 grep '^tests/integration/targets/hello/world.py .* 100%$' coverage.report
29
30 # ensure unit test coverage was collected
31 grep '^tests/unit/test_something.py .* 100%$' coverage.report
32
33 # ensure tests/output/ (from --venv) does not appear in the coverage report (except in the report filename)
34 if grep "^tests/output/" coverage.report; then
35 echo "unexpected coverage output: tests/output/"
36 exit 1
37 fi