-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_coverage.sh
More file actions
executable file
·38 lines (31 loc) · 1.07 KB
/
generate_coverage.sh
File metadata and controls
executable file
·38 lines (31 loc) · 1.07 KB
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
# Colors for output
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m' # No color
# Build directory
BUILD_DIR="build"
# Check if gcovr is installed
if ! command -v gcovr &> /dev/null; then
echo -e "${RED}gcovr is not installed. Please install it.${NC}"
exit 1
fi
# Check if build directory exists
if [ ! -d "$BUILD_DIR" ]; then
echo -e "${RED}Build directory '$BUILD_DIR' not found. Please build the project first.${NC}"
exit 1
fi
# Generate the coverage report
echo -e "${GREEN}--- Generating coverage report with gcovr ---${NC}"
if ! gcovr --root . --filter src/ --html --html-details --output "$BUILD_DIR/coverage.html"; then
echo -e "${RED}Failed to generate coverage report.${NC}"
exit 1
fi
echo -e "${GREEN}Coverage report generated at $BUILD_DIR/coverage.html${NC}"
if command -v open &> /dev/null; then
open "$BUILD_DIR/coverage.html" # macOS
elif command -v xdg-open &> /dev/null; then
xdg-open "$BUILD_DIR/coverage.html" # Linux
else
echo -e "${RED}Cannot automatically open the coverage report. Please open it manually.${NC}"
fi