@@ -13,13 +13,15 @@ main () {
13
13
MIN_COVERAGE_PERCENTAGE_NUM=0.0;
14
14
VERBOSE_FLAG=' false' ;
15
15
FILE_PATH=' .' ;
16
+ BUILD_FLAGS=' ' ;
16
17
17
18
# Parse flags and assign to global variables.
18
- while getopts ' :n:f:v' flag; do
19
+ while getopts ' :n:f:t: v' flag; do
19
20
case " ${flag} " in
20
21
n) MIN_COVERAGE_PERCENTAGE_NUM=" ${OPTARG} " ;;
21
- v) VERBOSE_FLAG=" true" ;;
22
22
f) FILE_PATH=" ${OPTARG} " ;;
23
+ t) BUILD_FLAGS=" ${OPTARG} " ;;
24
+ v) VERBOSE_FLAG=" true" ;;
23
25
* ) error " Unexpected option ${flag} " ;;
24
26
esac
25
27
done
@@ -84,15 +86,15 @@ generate_test_coverage () {
84
86
# If the pkg filepath contains 'vendor' we do not want to test it.
85
87
if [[ ${pkg} != * " vendor" * && ${pkg} != * " mock" * ]]; then
86
88
# Run the go cover and output results to 'coverage.out'.
87
- OUTPUT=$( go test -v -cover -coverprofile=coverage.out -covermode=count $pkg ) ;
89
+ OUTPUT=$( go test -v --tags " $BUILD_FLAGS " - cover -coverprofile=coverage.out -covermode=count $pkg ) ;
88
90
if [[ $OUTPUT == * " [no test files]" * ]]; then
89
91
print_handler " no tests founds for " $pkg
90
92
BASE_FOLDER_NAME=$( basename $pkg ) ;
91
93
MOCK_FILE_PATH=" ${PWD} /${pkg} /${BASE_FOLDER_NAME} _test.go" ;
92
94
TEMP_TEST_FILE_PATHS_ARR+=($MOCK_FILE_PATH )
93
95
touch $MOCK_FILE_PATH ;
94
96
echo " package ${BASE_FOLDER_NAME} " > $MOCK_FILE_PATH ;
95
- k=$( go test -v -cover -coverprofile=coverage.out -covermode=count $pkg ) ;
97
+ k=$( go test -v --tags " $BUILD_FLAGS " - cover -coverprofile=coverage.out -covermode=count $pkg ) ;
96
98
fi
97
99
98
100
# Take the results of coverage.out and append them to coverage-all.txt.
0 commit comments