From bbc5c33dafc56a4a9c194a9336b62ff3d91e4d81 Mon Sep 17 00:00:00 2001 From: Mike Bland Date: Wed, 26 Jul 2017 17:56:26 -0400 Subject: [PATCH] test,lib/cov: Replace TRAVIS_TEST_RESULT Naturally this variable would be empty until after Travis finishes running `./go test`. --- scripts/lib/coverage | 6 ++++-- scripts/test | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/lib/coverage b/scripts/lib/coverage index a09e5c4..f86a22b 100644 --- a/scripts/lib/coverage +++ b/scripts/lib/coverage @@ -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" @@ -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 @@ -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)" @@ -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 diff --git a/scripts/test b/scripts/test index 7370c24..81cb1bc 100755 --- a/scripts/test +++ b/scripts/test @@ -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