aboutsummaryrefslogtreecommitdiff
path: root/run_tests.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2017-05-22 20:22:12 +0300
committerGitHub <noreply@github.com>2017-05-22 20:22:12 +0300
commit07f117e38504df2525b4b09eb16ccc208031db9c (patch)
treecf65a7b66799c19a41e1d537f555541f119c0366 /run_tests.py
parent19faebe09f649bab21ca40a76fd517b6e245a453 (diff)
parent083b2756d1f1c41a06e9b1d2c60b2b2751d1070f (diff)
downloadmeson-07f117e38504df2525b4b09eb16ccc208031db9c.zip
meson-07f117e38504df2525b4b09eb16ccc208031db9c.tar.gz
meson-07f117e38504df2525b4b09eb16ccc208031db9c.tar.bz2
Merge pull request #1664 from QuLogic/codecov
Enable code coverage
Diffstat (limited to 'run_tests.py')
-rwxr-xr-xrun_tests.py29
1 files changed, 23 insertions, 6 deletions
diff --git a/run_tests.py b/run_tests.py
index 7ef9cf4..00c2595 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -19,6 +19,7 @@ import sys
import time
import shutil
import subprocess
+import tempfile
import platform
from mesonbuild import mesonlib
from mesonbuild.environment import detect_ninja
@@ -125,6 +126,13 @@ class FakeEnvironment(object):
return False
if __name__ == '__main__':
+ # Enable coverage early...
+ enable_coverage = '--cov' in sys.argv
+ if enable_coverage:
+ os.makedirs('.coverage', exist_ok=True)
+ sys.argv.remove('--cov')
+ import coverage
+ coverage.process_startup()
returncode = 0
# Iterate over list in reverse order to find the last --backend arg
backend = Backend.ninja
@@ -164,10 +172,19 @@ if __name__ == '__main__':
# Can't pass arguments to unit tests, so set the backend to use in the environment
env = os.environ.copy()
env['MESON_UNIT_TEST_BACKEND'] = backend.name
- returncode += subprocess.call([sys.executable, 'run_unittests.py', '-v'] + units, env=env)
- # Ubuntu packages do not have a binary without -6 suffix.
- if should_run_linux_cross_tests():
- print('Running cross compilation tests.\n')
- returncode += subprocess.call([sys.executable, 'run_cross_test.py', 'cross/ubuntu-armhf.txt'])
- returncode += subprocess.call([sys.executable, 'run_project_tests.py'] + sys.argv[1:])
+ with tempfile.TemporaryDirectory() as td:
+ # Enable coverage on all subsequent processes.
+ if enable_coverage:
+ with open(os.path.join(td, 'usercustomize.py'), 'w') as f:
+ f.write('import coverage\n'
+ 'coverage.process_startup()\n')
+ env['COVERAGE_PROCESS_START'] = '.coveragerc'
+ env['PYTHONPATH'] = os.pathsep.join([td] + env.get('PYTHONPATH', []))
+
+ returncode += subprocess.call([sys.executable, 'run_unittests.py', '-v'] + units, env=env)
+ # Ubuntu packages do not have a binary without -6 suffix.
+ if should_run_linux_cross_tests():
+ print('Running cross compilation tests.\n')
+ returncode += subprocess.call([sys.executable, 'run_cross_test.py', 'cross/ubuntu-armhf.txt'], env=env)
+ returncode += subprocess.call([sys.executable, 'run_project_tests.py'] + sys.argv[1:], env=env)
sys.exit(returncode)