From 65203bbd1ea4513b4db3b7ed151626e1338ae70a Mon Sep 17 00:00:00 2001 From: Martin Afanasjew Date: Sat, 6 Aug 2016 01:52:28 +0200 Subject: [PATCH] test-bot: avoid duplicate coverage reports When running on Travis CI, both the Linux and macOS build will send a coverage report, causing them to be merged by Coveralls. This results in inferior coverage due to the early stage of the Linux-specific tests and is probably not what we want. Make sure we only send a report for macOS (assuming we stick with a single macOS build in `.travis.yml`). --- Library/Homebrew/dev-cmd/test-bot.rb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/dev-cmd/test-bot.rb b/Library/Homebrew/dev-cmd/test-bot.rb index 37b2663f25..e3ba7e41ef 100644 --- a/Library/Homebrew/dev-cmd/test-bot.rb +++ b/Library/Homebrew/dev-cmd/test-bot.rb @@ -21,7 +21,8 @@ # as raw bytes instead of re-encoding in UTF-8. # --fast: Don't install any packages, but run e.g. audit anyway. # --keep-tmp: Keep temporary files written by main installs and tests that are run. -# --no-pull Don't use `brew pull` when possible. +# --no-pull: Don't use `brew pull` when possible. +# --coverage: Generate coverage report and send it to Coveralls. # # --ci-master: Shortcut for Homebrew master branch CI options. # --ci-pr: Shortcut for Homebrew pull request CI options. @@ -661,14 +662,14 @@ module Homebrew if @tap.nil? tests_args = [] - tests_args_coverage = [] + tests_args_no_compat = [] if RUBY_TWO tests_args << "--official-cmd-taps" - tests_args_coverage << "--coverage" if ENV["TRAVIS"] + tests_args_no_compat << "--coverage" if ARGV.include?("--coverage") end test "brew", "tests", *tests_args test "brew", "tests", "--generic", *tests_args - test "brew", "tests", "--no-compat", *tests_args_coverage + test "brew", "tests", "--no-compat", *tests_args_no_compat test "brew", "readall", "--syntax" # TODO: try to fix this on Linux at some stage. if OS.mac? @@ -929,6 +930,13 @@ module Homebrew ARGV << "--verbose" ARGV << "--ci-master" if ENV["TRAVIS_PULL_REQUEST"] == "false" ENV["HOMEBREW_VERBOSE_USING_DOTS"] = "1" + + # Only report coverage if build runs on macOS and this is indeed Homebrew, + # as we don't want this to be averaged with inferior Linux test coverage. + repo = ENV["TRAVIS_REPO_SLUG"] + if repo && repo.start_with?("Homebrew/") && ENV["OSX"] + ARGV << "--coverage" + end end if ARGV.include?("--ci-master") || ARGV.include?("--ci-pr") \