forked from google/anvil-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-coverage.sh
executable file
·38 lines (29 loc) · 1023 Bytes
/
run-coverage.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# Copyright 2012 Google Inc. All Rights Reserved.
# This script runs the build unit tests with a coverage run and spits out
# the result HTML to scratch/coverage/
# TODO(benvanik): merge with run-tests.py?
# This must currently run from the root of the repo
# TODO(benvanik): make this runnable from anywhere (find git directory?)
if [ ! -d ".git" ]; then
echo "This script must be run from the root of the repository (the folder containing .git)"
exit 1
fi
# Get into a known-good initial state by removing everything
# (removes the possibility for confusing old output when runs fail)
if [ -e ".coverage" ]; then
rm .coverage
fi
if [ -d "scratch/coverage" ]; then
rm -rf scratch/coverage
fi
# Run all unit tests with coverage
coverage run --branch ./run-tests.py
# Dump to console (so you see *something*)
coverage report -m
# Output HTML report
coverage html -d scratch/coverage/
# Cleanup the coverage temp data, as it's unused and regenerated
if [ -e ".coverage" ]; then
rm .coverage
fi