diff --git a/Gemfile b/Gemfile index b633a18a..b5ae7aa0 100644 --- a/Gemfile +++ b/Gemfile @@ -6,4 +6,5 @@ group :test do gem "activesupport" gem "rspec" gem "simplecov" + gem "sorbet-runtime" end diff --git a/Gemfile.lock b/Gemfile.lock index c3334cd3..96f43b51 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -41,6 +41,7 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) + sorbet-runtime (0.5.11357) tzinfo (2.0.6) concurrent-ruby (~> 1.0) @@ -51,3 +52,4 @@ DEPENDENCIES activesupport rspec simplecov + sorbet-runtime diff --git a/lib/test.rb b/lib/test.rb index 60dfdf1f..3fc1d427 100644 --- a/lib/test.rb +++ b/lib/test.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require "utils/analytics" + module Homebrew class Test def failed_steps @@ -52,6 +54,11 @@ def test(*arguments, named_args: nil, env: {}, verbose: @verbose, ignore_failure ) step.run(dry_run: @dry_run, fail_fast: @fail_fast) @steps << step + + if ENV["HOMEBREW_TEST_BOT_ANALYTICS"].present? + ::Utils::Analytics.report_test_bot_test(step.command_short, step.passed?) + end + step end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d7d90f9b..afeaccf5 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -6,6 +6,12 @@ minimum_coverage 10 end +# Setup Sorbet for usage in stubs. +require "sorbet-runtime" +class Module + include T::Sig +end + PROJECT_ROOT = Pathname(__dir__).parent.freeze STUB_PATH = (PROJECT_ROOT/"spec/stub").freeze $LOAD_PATH.unshift(STUB_PATH) diff --git a/spec/stub/utils/analytics.rb b/spec/stub/utils/analytics.rb new file mode 100644 index 00000000..df7c8428 --- /dev/null +++ b/spec/stub/utils/analytics.rb @@ -0,0 +1,9 @@ +# typed: true +# frozen_string_literal: true + +module Utils + module Analytics + sig { params(command: String, passed: T::Boolean).void } + def self.report_test_bot_test(command, passed); end + end +end