~kyrofa/unity-scope-snappy/integration-tests_previews

« back to all changes in this revision

Viewing changes to test_coverage.sh

  • Committer: Tarmac
  • Author(s): Kyle Fazzari
  • Date: 2015-06-17 15:09:55 UTC
  • mfrom: (8.4.5 unity-scope-snappy)
  • Revision ID: tarmac-20150617150955-merikzwopj9gtd7c
Add progress placeholder previews for manually refreshing.

Approved by PS Jenkins bot, Xavi Garcia.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/bash
2
2
 
3
 
tmp_directory="$(mktemp -d)"
4
 
coverage_final=$tmp_directory/coverage.out
5
 
coverage_scope=$tmp_directory/coverage_scope.out
6
 
coverage_webdm=$tmp_directory/coverage_webdm.out
 
3
coverage_final="$(mktemp)"
 
4
 
 
5
# get_coverage runs the given tests and adds the results to the final coverage
 
6
# file.
 
7
#
 
8
# Parameters:
 
9
# $1: Go path under test.
 
10
# $2: Final coverage report.
 
11
function get_coverage
 
12
{
 
13
        local go_path=$1
 
14
        local coverage_final=$2
 
15
        local coverage_tmp="$(mktemp)"
 
16
 
 
17
        go test $go_path -coverprofile=$coverage_tmp
 
18
        local returnValue=$?
 
19
        if [ $returnValue -eq 0 ]; then
 
20
                # Tests passed, so add this to the final coverage file
 
21
                cat $coverage_tmp | grep -v "mode: set" >> $coverage_final
 
22
        else
 
23
                exit $returnValue # Tests failed, so this script should also fail
 
24
        fi
 
25
}
7
26
 
8
27
# Setup final coverage file
9
28
echo "mode: set" > $coverage_final
10
29
 
11
 
# Add the scope's coverage to the overarching coverage file
12
 
go test launchpad.net/unity-scope-snappy/scope -coverprofile=$coverage_scope
13
 
cat $coverage_scope | grep -v "mode: set" >> $coverage_final
 
30
# Add the scope's coverage to the final coverage file
 
31
get_coverage "launchpad.net/unity-scope-snappy/scope" $coverage_final
14
32
 
15
 
# Add webdm's coverage to the overarching coverage file
16
 
go test launchpad.net/unity-scope-snappy/webdm -coverprofile=$coverage_webdm
17
 
cat $coverage_webdm | grep -v "mode: set" >> $coverage_final
 
33
# Add webdm's coverage to the final coverage file
 
34
get_coverage "launchpad.net/unity-scope-snappy/webdm" $coverage_final
18
35
 
19
36
if [ "$1" == "xml" ]; then
20
37
        gocov convert $coverage_final | gocov-xml > coverage.xml