-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgcovr.chevre
80 lines (66 loc) · 1.88 KB
/
gcovr.chevre
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
options="$(echo "$@" | jq -r .options | not is_null)"
compiler="$(get_compiler)"
includes="-Isrc -Ibuild/include $(get_includes source_dependencies)"
test_includes="-Isrc -Ibuild/include $(get_includes identity)"
links="-Lbuild/lib $(get_module_links identity) $(get_links identity) $(get_static_links identity | non_empty | map link_statically)"
date="$(date +%s)"
coverage_file()
{
echo "build/$1.gcno"
}
get_coverage_file()
{
echo "$1" | tr '.' ' ' | map coverage_file
}
has_coverage_data()
{
test -f "$(get_coverage_file "$1")" || (echo "$1" | grep "^test/")
}
has_object_and_coverage_data()
{
has_object "$1" && has_coverage_data "$1"
}
coverage_flags()
{
echo -fprofile-arcs -ftest-coverage
}
get_includes()
{
echo "$includes"
}
get_test_includes()
{
echo "$test_includes"
}
compile()
{
verbose $compiler -c $($1) -o $(get_output "$4") $($2 $4) $($3) $4
if [[ $? -eq 0 ]]; then
generate_hash "$4" >> build/hashes
fi
}
link()
{
verbose $(echo "$compiler" | map first) --coverage -o $(get_executable "$1") $1 $(all_sources | map get_output | not is_executable_object) -lgcov $links
}
run_test()
{
echo "$1"
$1 &> /dev/null
}
mkdir -p build/gcovr/build/bin
copy_all src build/gcovr
copy_all test build/gcovr
copy_all build/lib build/gcovr/build
copy_all build/include build/gcovr/build
cd build/gcovr
filter_old_hashes has_object_and_coverage_data
get_missing_sources src | map remove_hash | map make_directory | parmap compile coverage_flags blank get_includes
get_missing_sources test | map remove_hash | map make_directory | parmap compile blank include_source get_test_includes
get_sources test | map get_output | filter is_executable_object | map link
get_sources test | map get_output | filter is_executable_object | map get_executable | map run_test
mkdir $date
rm -f latest
ln -s $date latest
verbose gcovr -s -r . --html --html-details $options -o "$date/coverage_report.html"