tests: Switch to unit2 test runner, with coverage
This means test files are imported as modules, not run as scripts. THey can still be run individually if so desired. Test coverage is measured, and an html report generated in htmlcov/. Test cases are automativally discovered, so they need not be listed twice. An overall passed/failed/skipped summary is printed, rather than for each file. Arguments passed to ./test are passed on to unit2. For instance ./test -v will print each test name as it is run.pull/180/head
parent
7b8fef5284
commit
dc60f05a40
@ -1,7 +1,9 @@
|
|||||||
|
.coverage
|
||||||
.venv
|
.venv
|
||||||
**/.DS_Store
|
**/.DS_Store
|
||||||
MANIFEST
|
MANIFEST
|
||||||
build/
|
build/
|
||||||
dist/
|
dist/
|
||||||
docs/_build
|
docs/_build
|
||||||
|
htmlcov/
|
||||||
*.egg-info
|
*.egg-info
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
[coverage:run]
|
||||||
|
branch = true
|
||||||
|
source =
|
||||||
|
mitogen
|
||||||
|
omit =
|
||||||
|
mitogen/compat/*
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
ignore = E402,E128,W503
|
ignore = E402,E128,W503
|
||||||
exclude = mitogen/compat
|
exclude = mitogen/compat
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
#/bin/sh
|
||||||
|
|
||||||
|
UNIT2="$(which unit2)"
|
||||||
|
|
||||||
|
coverage erase
|
||||||
|
coverage run "${UNIT2}" discover \
|
||||||
|
--start-directory "tests" \
|
||||||
|
--pattern '*_test.py' \
|
||||||
|
"$@"
|
||||||
|
coverage html
|
||||||
|
echo coverage report is at "file://$(pwd)/htmlcov/index.html"
|
@ -1,63 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
timeout()
|
|
||||||
{
|
|
||||||
python -c '
|
|
||||||
import subprocess
|
|
||||||
import sys
|
|
||||||
import time
|
|
||||||
|
|
||||||
deadline = time.time() + float(sys.argv[1])
|
|
||||||
proc = subprocess.Popen(sys.argv[2:])
|
|
||||||
while time.time() < deadline and proc.poll() is None:
|
|
||||||
time.sleep(1.0)
|
|
||||||
|
|
||||||
if proc.poll() is not None:
|
|
||||||
sys.exit(proc.returncode)
|
|
||||||
proc.terminate()
|
|
||||||
print
|
|
||||||
print >> sys.stderr, "Timeout! Command was:", sys.argv[2:]
|
|
||||||
print
|
|
||||||
sys.exit(1)
|
|
||||||
' "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
trap 'sigint' INT
|
|
||||||
sigint()
|
|
||||||
{
|
|
||||||
echo "SIGINT received, stopping.."
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
run_test()
|
|
||||||
{
|
|
||||||
echo "Running $1.."
|
|
||||||
timeout 10 python $1 || fail=$?
|
|
||||||
}
|
|
||||||
|
|
||||||
run_test tests/ansible_helpers_test.py
|
|
||||||
run_test tests/call_error_test.py
|
|
||||||
run_test tests/call_function_test.py
|
|
||||||
run_test tests/channel_test.py
|
|
||||||
run_test tests/fakessh_test.py
|
|
||||||
run_test tests/first_stage_test.py
|
|
||||||
run_test tests/fork_test.py
|
|
||||||
run_test tests/id_allocation_test.py
|
|
||||||
run_test tests/importer_test.py
|
|
||||||
run_test tests/latch_test.py
|
|
||||||
run_test tests/local_test.py
|
|
||||||
run_test tests/master_test.py
|
|
||||||
run_test tests/module_finder_test.py
|
|
||||||
run_test tests/nested_test.py
|
|
||||||
run_test tests/parent_test.py
|
|
||||||
run_test tests/receiver_test.py
|
|
||||||
run_test tests/responder_test.py
|
|
||||||
run_test tests/router_test.py
|
|
||||||
run_test tests/select_test.py
|
|
||||||
run_test tests/ssh_test.py
|
|
||||||
run_test tests/utils_test.py
|
|
||||||
|
|
||||||
if [ "$fail" ]; then
|
|
||||||
echo "AT LEAST ONE TEST FAILED" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
Loading…
Reference in New Issue