Merge pull request #14525 from SMillerDev/master

analytics: stop sending analytics in tests
This commit is contained in:
Mike McQuaid 2023-02-06 21:28:29 +01:00 committed by GitHub
commit 6c27021211
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -117,9 +117,8 @@ describe Utils::Analytics do
ENV.delete("HOMEBREW_NO_ANALYTICS")
ENV["HOMEBREW_ANALYTICS_DEBUG"] = "true"
ENV["HOMEBREW_ANALYTICS_ENABLE_INFLUX"] = "true"
expect do
described_class.report_influx(:install, action, true, developer: true, CI: true)
end.to output(/--data-raw install,[a-zA-Z=,]*,action=formula_name\\ --head/).to_stdout
expect(described_class).to receive(:deferred_curl).once
described_class.report_influx(:install, action, true, developer: true, CI: true)
end
end

View File

@ -99,8 +99,13 @@ module Utils
"--data-raw", "#{category},#{tags} count=1i #{Time.now.to_i}"
]
curl = Utils::Curl.curl_executable
url = "https://#{INFLUX_HOST}/api/v2/write?bucket=#{INFLUX_BUCKET}&precision=s"
deferred_curl(url, args)
end
sig { params(url: String, args: T::Array[String]).void }
def deferred_curl(url, args)
curl = Utils::Curl.curl_executable
if ENV["HOMEBREW_ANALYTICS_DEBUG"]
puts "#{curl} #{args.join(" ")} \"#{url}\""
puts Utils.popen_read(curl, *args, url)