Skip to content

Commit

Permalink
test,lib/cov: Replace TRAVIS_TEST_RESULT
Browse files Browse the repository at this point in the history
Naturally this variable would be empty until after Travis finishes
running `./go test`.
  • Loading branch information
mbland committed Jul 26, 2017
1 parent b362cda commit bbc5c33
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions scripts/lib/coverage
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ urlp.init_code_climate() {
}

urlp.generate_coverage_report() {
local test_result="$1"
local report_dir="${_GO_ROOTDIR}/coverage/lcov-report"
local report_path="$report_dir/index.html"

Expand All @@ -28,7 +29,7 @@ urlp.generate_coverage_report() {
@go.printf 'Coverage report saved as: file://%s\n' "$report_path"

if [[ -n "$CI" ]]; then
urlp.send_coverage_report
urlp.send_coverage_report "$test_result"
elif [[ "$COVERAGE_REPORT_SERVER" == 'false' ]]; then
return
elif [[ "$COVERAGE_REPORT_SERVER" == 'true' ]]; then
Expand All @@ -44,6 +45,7 @@ urlp.generate_coverage_report() {
}

urlp.send_coverage_report() {
local test_result="$1"
local lcov_info_path="${_GO_ROOTDIR}/coverage/lcov.info"
local github_repo="$(git config remote.origin.url)"

Expand All @@ -58,7 +60,7 @@ urlp.send_coverage_report() {
"https://coveralls.io/github/${github_repo}"

if [[ -n "$CC_TEST_REPORTER_ID" && -x "$CC_TEST_REPORTER" ]]; then
if ! "$CC_TEST_REPORTER" after-build --exit-code "$TRAVIS_TEST_RESULT"; then
if ! "$CC_TEST_REPORTER" after-build --exit-code "$test_result"; then
echo 'Failed to send report to Code Climate.' >&2
return 1
fi
Expand Down
2 changes: 1 addition & 1 deletion scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ _test() {
if ! @go.log_command @go test end-to-end; then
result='1'
fi
if [[ -n "$coverage_run" ]] && ! urlp.generate_coverage_report; then
if [[ -n "$coverage_run" ]] && ! urlp.generate_coverage_report "$result"; then
result='1'
fi
if [[ "$result" -eq '0' ]]; then
Expand Down

0 comments on commit bbc5c33

Please sign in to comment.