Debian Codegraph @

test/integration/targets/ansible-test-units-forked/runme.sh

raw
1 #!/usr/bin/env bash
2
3 source ../collection/setup.sh
4
5 set -x
6
7 options=$("${TEST_DIR}"/../ansible-test/venv-pythons.py --only-versions)
8 IFS=', ' read -r -a pythons <<< "${options}"
9
10 for python in "${pythons[@]}"; do
11 echo "*** Checking Python ${python} ***"
12
13 if ansible-test units --truncate 0 --target-python "venv/${python}" "${@}" > output.log 2>&1 ; then
14 cat output.log
15 echo "Unit tests on Python ${python} did not fail as expected. See output above."
16 exit 1
17 fi
18
19 cat output.log
20 echo "Unit tests on Python ${python} failed as expected. See output above. Checking for expected output ..."
21
22 # Verify that the appropriate tests passed, failed or xfailed.
23 grep 'PASSED tests/unit/plugins/modules/test_ansible_forked.py::test_passed' output.log
24 grep 'PASSED tests/unit/plugins/modules/test_ansible_forked.py::test_warning' output.log
25 grep 'XFAIL tests/unit/plugins/modules/test_ansible_forked.py::test_kill_xfail' output.log
26 grep 'FAILED tests/unit/plugins/modules/test_ansible_forked.py::test_kill' output.log
27 grep 'FAILED tests/unit/plugins/modules/test_ansible_forked.py::test_exception' output.log
28 grep 'XFAIL tests/unit/plugins/modules/test_ansible_forked.py::test_exception_xfail' output.log
29
30 # Verify that warnings are properly surfaced.
31 grep 'UserWarning: This verifies that warnings generated at test time are reported.' output.log
32 grep 'UserWarning: This verifies that warnings generated during test collection are reported.' output.log
33
34 # Verify there are no unexpected warnings.
35 grep 'Warning' output.log | grep -v 'UserWarning: This verifies that warnings generated ' && exit 1
36
37 # Verify that details from failed tests are properly surfaced.
38 grep "^Test CRASHED with exit code -9.$" output.log
39 grep "^This stdout message should be reported since we're throwing an exception.$" output.log
40 grep "^This stderr message should be reported since we're throwing an exception.$" output.log
41 grep '^> *raise Exception("This error is expected and should be visible.")$' output.log
42 grep "^E *Exception: This error is expected and should be visible.$" output.log
43
44 echo "*** Done Checking Python ${python} ***"
45 done