scripts/unit-test: Only build coverage output if coverage run
If our project has no test cases run then no coverage data will be
produced. This results in a lack of .gcda files which causes the
coverage-html target to fail being built. Just avoid running the
coverage-html generation if we don't have coverage data.
Change-Id: If4342798c6bfaa4fd2eed77fe510fa6a70546fa4
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/scripts/unit-test.py b/scripts/unit-test.py
index 6468bf1..ba95405 100755
--- a/scripts/unit-test.py
+++ b/scripts/unit-test.py
@@ -724,7 +724,12 @@
check_call_cmd(top_dir, 'meson', 'configure', 'build',
'-Db_coverage=true')
check_call_cmd(top_dir, 'meson', 'test', '-C', 'build')
- check_call_cmd(top_dir, 'ninja', '-C', 'build', 'coverage-html')
+ # Only build coverage HTML if coverage files were produced
+ for root, dirs, files in os.walk('build'):
+ if any([f.endswith('.gcda') for f in files]):
+ check_call_cmd(top_dir, 'ninja', '-C', 'build',
+ 'coverage-html')
+ break
check_call_cmd(top_dir, 'meson', 'configure', 'build',
'-Db_coverage=false')
else: