Skip to content

Commit af48ab6

Browse files
committed
update
1 parent 20f86d1 commit af48ab6

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

go-test-runner

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ main () {
3636
# Change our working directory to the file path provided.
3737
cd "$FILE_PATH";
3838

39+
# Make sure we initiate clean up before exiting.
40+
trap clean_up EXIT;
41+
3942
# Create a new coverage-all.out file, that will contain the contents of every individual
4043
# pkg's `coverage.out`.
4144
echo "mode: count" > coverage-all.out;
@@ -53,18 +56,17 @@ main () {
5356
# Check if the current test coverage number is above the threshold.
5457
check_for_minimum_test_coverage_percentage "$current_test_coverage_number";
5558

56-
# Initiate clean up.
57-
clean_up;
58-
59-
# TODO add color here.
60-
echo -e "\e[32mExiting with status code $EXIT_STATUS\e[0m";
59+
exit_status_color="\e[32m";
60+
if [[ $EXIT_STATUS -eq 1 ]]; then
61+
exit_status_color="\e[31m";
62+
fi
63+
echo -e $exit_status_color"Exiting with status code $EXIT_STATUS\e[0m\n";
6164
exit $EXIT_STATUS;
6265
}
6366

6467
check_for_minimum_test_coverage_percentage () {
6568
local current_test_coverage_number;
66-
current_test_coverage_number="$1";
67-
current_test_coverage_number=$(echo ${current_test_coverage_number%%.*});
69+
current_test_coverage_number=$(echo ${1%%.*});
6870
MIN_COVERAGE_PERCENTAGE_NUM=$(echo ${MIN_COVERAGE_PERCENTAGE_NUM%%.*});
6971

7072
if ! [[ "$current_test_coverage_number" -ge "$MIN_COVERAGE_PERCENTAGE_NUM" ]]; then

0 commit comments

Comments
 (0)