Skip to content

Commit

Permalink
Merge pull request #66 from YellowBloomKnapsack/fix/Tester
Browse files Browse the repository at this point in the history
Fix tester to exit 1 if could not build or some tests failed
  • Loading branch information
Haximos authored Jul 29, 2024
2 parents e5bde4a + bbb1749 commit ef7cb22
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
1 change: 0 additions & 1 deletion panel/handlers/advertiserhandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ var sequentialTests = []func(t *testing.T){
testAddFunds,
testCreateAd,
testHandleEditAd,
testHandleImpressionAdInteraction,
testPublisherPanel,
testWithdrawPublisherBalanceSuccessfulWithdrawal,
}
Expand Down
Binary file removed panel/panel
Binary file not shown.
17 changes: 15 additions & 2 deletions tester.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,28 @@ run_tests_with_coverage() {
echo -e "${BLUE}- Running tests in $dir ${NC}"

# Run the tests and capture the output
result=$(go build $dir 2>&1)
exit_code=$?

result=$(go test -c $dir 2>&1)
exit_code=$?

if [[ $exit_code -ne 0 ]]; then
echo -e "${RED} Could not build ${dir}${NC}"
exit 1
fi

result=$(go test -coverprofile=coverage.out -v $dir 2>&1)

# Print each test function result with color
echo "$result" | while IFS= read -r line; do
while IFS= read -r line; do
if [[ "$line" == *"--- PASS"* ]]; then
echo -e "${GREEN}$line ${NC}" # Green for pass
elif [[ "$line" == *"--- FAIL"* ]]; then
echo -e "${RED}$line ${NC}" # Red for fail
exit 1
fi
done
done <<< "$result"

# Print the coverage
if [ -f coverage.out ]; then
Expand All @@ -69,6 +80,8 @@ run_tests_with_coverage() {
fi
fi
done

exit 0
}

# Execute the function
Expand Down

0 comments on commit ef7cb22

Please sign in to comment.