-
Notifications
You must be signed in to change notification settings - Fork 4
/
coverage.sh
31 lines (24 loc) · 936 Bytes
/
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
#!/bin/bash
# Check if lcov is installed
if ! command -v lcov &> /dev/null
then
echo "lcov could not be found, please install it first."
exit
fi
# Run the tests with coverage
flutter test --coverage
# Generate the LCOV report
lcov --capture --directory coverage --output-file coverage/lcov.info
# Remove unnecessary files from the report
lcov --remove coverage/lcov.info 'lib/*/*.g.dart' 'lib/*/*.freezed.dart' -o coverage/lcov.info
# Generate the HTML report
genhtml coverage/lcov.info --output-directory coverage/html
# Open the coverage report in the default browser
if [ "$(uname)" == "Darwin" ]; then
open coverage/html/index.html
elif [ "$(uname)" == "Linux" ]; then
xdg-open coverage/html/index.html
elif [ "$(uname)" == "CYGWIN" ] || [ "$(uname)" == "MINGW32" ] || [ "$(uname)" == "MINGW64" ]; then
start coverage/html/index.html
fi
echo "Coverage report generated and opened in the default browser."