From e2fc14b0b7d67c1f19ab85c4942253d056f7cd4d Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Fri, 3 Dec 2021 20:14:17 -0500 Subject: [PATCH 1/4] Fix analytics_spec.rb test to pass when run from M1 --- Library/Homebrew/test/utils/analytics_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/test/utils/analytics_spec.rb b/Library/Homebrew/test/utils/analytics_spec.rb index 431d8a2448..c218052268 100644 --- a/Library/Homebrew/test/utils/analytics_spec.rb +++ b/Library/Homebrew/test/utils/analytics_spec.rb @@ -14,7 +14,9 @@ describe Utils::Analytics do it "returns OS_VERSION and prefix when HOMEBREW_PREFIX is a custom prefix" do allow(Hardware::CPU).to receive(:type).and_return(:intel) allow(Homebrew).to receive(:default_prefix?).and_return(false) - expect(described_class.os_arch_prefix_ci).to include("#{OS_VERSION}, #{described_class.custom_prefix_label}") + arch = ", #{described_class.arch_label}" if described_class.arch_label.present? + expected = "#{OS_VERSION}#{arch}, #{described_class.custom_prefix_label}" + expect(described_class.os_arch_prefix_ci).to include(expected) end it "does not include prefix when HOMEBREW_PREFIX is the default prefix" do From b58551cd677eed32028adba09dd1baa7cc273adb Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Fri, 3 Dec 2021 22:29:10 -0500 Subject: [PATCH 2/4] Control for CPU type and Rosetta in `os_arch_prefix_ci` tests --- Library/Homebrew/test/utils/analytics_spec.rb | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/test/utils/analytics_spec.rb b/Library/Homebrew/test/utils/analytics_spec.rb index c218052268..11fd3a8bd4 100644 --- a/Library/Homebrew/test/utils/analytics_spec.rb +++ b/Library/Homebrew/test/utils/analytics_spec.rb @@ -11,12 +11,28 @@ describe Utils::Analytics do described_class.clear_os_arch_prefix_ci end - it "returns OS_VERSION and prefix when HOMEBREW_PREFIX is a custom prefix" do + it "returns OS_VERSION and prefix when HOMEBREW_PREFIX is a custom prefix on intel" do allow(Hardware::CPU).to receive(:type).and_return(:intel) + allow(Hardware::CPU).to receive(:in_rosetta2?).and_return(false) allow(Homebrew).to receive(:default_prefix?).and_return(false) - arch = ", #{described_class.arch_label}" if described_class.arch_label.present? - expected = "#{OS_VERSION}#{arch}, #{described_class.custom_prefix_label}" - expect(described_class.os_arch_prefix_ci).to include(expected) + expected = "#{OS_VERSION}, #{described_class.custom_prefix_label}" + expect(described_class.os_arch_prefix_ci).to eq expected + end + + it 'returns OS_VERSION, "ARM" and prefix when HOMEBREW_PREFIX is a custom prefix on arm' do + allow(Hardware::CPU).to receive(:type).and_return(:arm) + allow(Hardware::CPU).to receive(:in_rosetta2?).and_return(false) + allow(Homebrew).to receive(:default_prefix?).and_return(false) + expected = "#{OS_VERSION}, ARM, #{described_class.custom_prefix_label}" + expect(described_class.os_arch_prefix_ci).to eq expected + end + + it 'returns OS_VERSION, "Rosetta" and prefix when HOMEBREW_PREFIX is a custom prefix using Rosetta' do + allow(Hardware::CPU).to receive(:type).and_return(:intel) + allow(Hardware::CPU).to receive(:in_rosetta2?).and_return(true) + allow(Homebrew).to receive(:default_prefix?).and_return(false) + expected = "#{OS_VERSION}, Rosetta, #{described_class.custom_prefix_label}" + expect(described_class.os_arch_prefix_ci).to eq expected end it "does not include prefix when HOMEBREW_PREFIX is the default prefix" do From 30c4663066b2b95b54fb0bbece8cb13fd8545735 Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Sat, 4 Dec 2021 12:29:31 -0500 Subject: [PATCH 3/4] Fix analytics string to test for CI --- Library/Homebrew/test/utils/analytics_spec.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/test/utils/analytics_spec.rb b/Library/Homebrew/test/utils/analytics_spec.rb index 11fd3a8bd4..509ac677f6 100644 --- a/Library/Homebrew/test/utils/analytics_spec.rb +++ b/Library/Homebrew/test/utils/analytics_spec.rb @@ -11,11 +11,13 @@ describe Utils::Analytics do described_class.clear_os_arch_prefix_ci end + ci = ", CI" if ENV["CI"] + it "returns OS_VERSION and prefix when HOMEBREW_PREFIX is a custom prefix on intel" do allow(Hardware::CPU).to receive(:type).and_return(:intel) allow(Hardware::CPU).to receive(:in_rosetta2?).and_return(false) allow(Homebrew).to receive(:default_prefix?).and_return(false) - expected = "#{OS_VERSION}, #{described_class.custom_prefix_label}" + expected = "#{OS_VERSION}, #{described_class.custom_prefix_label}#{ci}" expect(described_class.os_arch_prefix_ci).to eq expected end @@ -23,7 +25,7 @@ describe Utils::Analytics do allow(Hardware::CPU).to receive(:type).and_return(:arm) allow(Hardware::CPU).to receive(:in_rosetta2?).and_return(false) allow(Homebrew).to receive(:default_prefix?).and_return(false) - expected = "#{OS_VERSION}, ARM, #{described_class.custom_prefix_label}" + expected = "#{OS_VERSION}, ARM, #{described_class.custom_prefix_label}#{ci}" expect(described_class.os_arch_prefix_ci).to eq expected end @@ -31,7 +33,7 @@ describe Utils::Analytics do allow(Hardware::CPU).to receive(:type).and_return(:intel) allow(Hardware::CPU).to receive(:in_rosetta2?).and_return(true) allow(Homebrew).to receive(:default_prefix?).and_return(false) - expected = "#{OS_VERSION}, Rosetta, #{described_class.custom_prefix_label}" + expected = "#{OS_VERSION}, Rosetta, #{described_class.custom_prefix_label}#{ci}" expect(described_class.os_arch_prefix_ci).to eq expected end From 7656c09184da4ad1ad5d5dd4ae296a78d7dd4d15 Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Sun, 5 Dec 2021 13:03:38 -0500 Subject: [PATCH 4/4] Only check for Rosetta on macOS --- Library/Homebrew/test/utils/analytics_spec.rb | 6 +++--- manpages/brew.1 | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/test/utils/analytics_spec.rb b/Library/Homebrew/test/utils/analytics_spec.rb index 509ac677f6..de1e8c5d25 100644 --- a/Library/Homebrew/test/utils/analytics_spec.rb +++ b/Library/Homebrew/test/utils/analytics_spec.rb @@ -11,7 +11,7 @@ describe Utils::Analytics do described_class.clear_os_arch_prefix_ci end - ci = ", CI" if ENV["CI"] + let(:ci) { ", CI" if ENV["CI"] } it "returns OS_VERSION and prefix when HOMEBREW_PREFIX is a custom prefix on intel" do allow(Hardware::CPU).to receive(:type).and_return(:intel) @@ -21,7 +21,7 @@ describe Utils::Analytics do expect(described_class.os_arch_prefix_ci).to eq expected end - it 'returns OS_VERSION, "ARM" and prefix when HOMEBREW_PREFIX is a custom prefix on arm' do + it "returns OS_VERSION, ARM and prefix when HOMEBREW_PREFIX is a custom prefix on arm" do allow(Hardware::CPU).to receive(:type).and_return(:arm) allow(Hardware::CPU).to receive(:in_rosetta2?).and_return(false) allow(Homebrew).to receive(:default_prefix?).and_return(false) @@ -29,7 +29,7 @@ describe Utils::Analytics do expect(described_class.os_arch_prefix_ci).to eq expected end - it 'returns OS_VERSION, "Rosetta" and prefix when HOMEBREW_PREFIX is a custom prefix using Rosetta' do + it "returns OS_VERSION, Rosetta and prefix when HOMEBREW_PREFIX is a custom prefix on Rosetta", :needs_macos do allow(Hardware::CPU).to receive(:type).and_return(:intel) allow(Hardware::CPU).to receive(:in_rosetta2?).and_return(true) allow(Homebrew).to receive(:default_prefix?).and_return(false) diff --git a/manpages/brew.1 b/manpages/brew.1 index 3d675fde6c..0d56af5014 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BREW" "1" "November 2021" "Homebrew" "brew" +.TH "BREW" "1" "December 2021" "Homebrew" "brew" . .SH "NAME" \fBbrew\fR \- The Missing Package Manager for macOS (or Linux)