From 96e5b8d9b156f9538eab34f5281d0f44f9f188bf Mon Sep 17 00:00:00 2001 From: Jan Viljanen <527069+javian@users.noreply.github.com> Date: Fri, 12 Oct 2018 23:47:55 +0200 Subject: [PATCH 1/3] fix rubocop offences --- Library/Homebrew/test/.rubocop_todo.yml | 11 ------ .../artifact/uninstall_zap_shared_examples.rb | 5 +-- .../Homebrew/test/compiler_selector_spec.rb | 37 +------------------ Library/Homebrew/test/utils/shell_spec.rb | 5 --- 4 files changed, 3 insertions(+), 55 deletions(-) diff --git a/Library/Homebrew/test/.rubocop_todo.yml b/Library/Homebrew/test/.rubocop_todo.yml index c3bbe7dc26..6666df7549 100644 --- a/Library/Homebrew/test/.rubocop_todo.yml +++ b/Library/Homebrew/test/.rubocop_todo.yml @@ -121,17 +121,6 @@ RSpec/RepeatedDescription: - 'rubocops/lines_cop_spec.rb' - 'tab_spec.rb' -# Offense count: 10 -RSpec/RepeatedExample: - Exclude: - - 'compiler_selector_spec.rb' - - 'utils/shell_spec.rb' - -# Offense count: 2 -RSpec/ScatteredLet: - Exclude: - - 'cask/artifact/uninstall_zap_shared_examples.rb' - # Offense count: 31 RSpec/SubjectStub: Exclude: diff --git a/Library/Homebrew/test/cask/artifact/uninstall_zap_shared_examples.rb b/Library/Homebrew/test/cask/artifact/uninstall_zap_shared_examples.rb index 56a8408360..650b275e13 100644 --- a/Library/Homebrew/test/cask/artifact/uninstall_zap_shared_examples.rb +++ b/Library/Homebrew/test/cask/artifact/uninstall_zap_shared_examples.rb @@ -158,6 +158,8 @@ shared_examples "#uninstall_phase or #zap_phase" do let(:glob_path1) { Pathname.new("#{dir}/glob_path1") } let(:glob_path2) { Pathname.new("#{dir}/glob_path2") } let(:paths) { [absolute_path, path_with_tilde, glob_path1, glob_path2] } + let(:fake_system_command) { NeverSudoSystemCommand } + let(:cask) { Cask::CaskLoader.load(cask_path("with-#{artifact_dsl_key}-#{directive}")) } around(:each) do |example| begin @@ -171,9 +173,6 @@ shared_examples "#uninstall_phase or #zap_phase" do end end - let(:fake_system_command) { NeverSudoSystemCommand } - let(:cask) { Cask::CaskLoader.load(cask_path("with-#{artifact_dsl_key}-#{directive}")) } - before(:each) do allow_any_instance_of(Cask::Artifact::AbstractUninstall).to receive(:trash_paths) .and_wrap_original do |method, *args| diff --git a/Library/Homebrew/test/compiler_selector_spec.rb b/Library/Homebrew/test/compiler_selector_spec.rb index 784fdbc5bf..1a0be87545 100644 --- a/Library/Homebrew/test/compiler_selector_spec.rb +++ b/Library/Homebrew/test/compiler_selector_spec.rb @@ -27,29 +27,10 @@ describe CompilerSelector do end describe "#compiler" do - it "raises an error if no matching compiler can be found" do - software_spec.fails_with(:clang) - software_spec.fails_with(:gcc_4_2) - software_spec.fails_with(gcc: "4.8") - software_spec.fails_with(gcc: "4.7") - - expect { subject.compiler }.to raise_error(CompilerSelectionError) - end - it "defaults to cc" do expect(subject.compiler).to eq(cc) end - it "returns gcc if it fails with clang" do - software_spec.fails_with(:clang) - expect(subject.compiler).to eq(:gcc_4_2) - end - - it "returns clang if it fails with gcc" do - software_spec.fails_with(:gcc_4_2) - expect(subject.compiler).to eq(:clang) - end - it "returns clang if it fails with non-Apple gcc" do software_spec.fails_with(gcc: "4.8") expect(subject.compiler).to eq(:clang) @@ -84,23 +65,7 @@ describe CompilerSelector do expect(subject.compiler).to eq("gcc-4.7") end - it "prefers gcc" do - software_spec.fails_with(:clang) - software_spec.fails_with(:gcc_4_2) - expect(subject.compiler).to eq("gcc-4.8") - end - - it "raises an error when gcc is missing" do - allow(versions).to receive(:gcc_4_2_build_version).and_return(Version::NULL) - - software_spec.fails_with(:clang) - software_spec.fails_with(gcc: "4.8") - software_spec.fails_with(gcc: "4.7") - - expect { subject.compiler }.to raise_error(CompilerSelectionError) - end - - it "raises an error when llvm and gcc are missing" do + it "raises an error when gcc or llvm is missing" do allow(versions).to receive(:gcc_4_2_build_version).and_return(Version::NULL) software_spec.fails_with(:clang) diff --git a/Library/Homebrew/test/utils/shell_spec.rb b/Library/Homebrew/test/utils/shell_spec.rb index a9456ae117..b2e1a481c6 100644 --- a/Library/Homebrew/test/utils/shell_spec.rb +++ b/Library/Homebrew/test/utils/shell_spec.rb @@ -7,11 +7,6 @@ describe Utils::Shell do expect(subject.profile).to eq("~/.bash_profile") end - it "returns ~/.bash_profile for Sh" do - ENV["SHELL"] = "/bin/another_shell" - expect(subject.profile).to eq("~/.bash_profile") - end - it "returns ~/.bash_profile for Bash" do ENV["SHELL"] = "/bin/bash" expect(subject.profile).to eq("~/.bash_profile") From bd3bc09720c0adc764b7082622cdedc933d0d28e Mon Sep 17 00:00:00 2001 From: Jan Viljanen <527069+javian@users.noreply.github.com> Date: Sat, 20 Oct 2018 08:53:19 +0200 Subject: [PATCH 2/3] restore sh test --- Library/Homebrew/test/utils/shell_spec.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Library/Homebrew/test/utils/shell_spec.rb b/Library/Homebrew/test/utils/shell_spec.rb index b2e1a481c6..e22c2efa4f 100644 --- a/Library/Homebrew/test/utils/shell_spec.rb +++ b/Library/Homebrew/test/utils/shell_spec.rb @@ -7,6 +7,11 @@ describe Utils::Shell do expect(subject.profile).to eq("~/.bash_profile") end + it "returns ~/.bash_profile by default" do + ENV["SHELL"] = "/bin/sh" + expect(subject.profile).to eq("~/.bash_profile") + end + it "returns ~/.bash_profile for Bash" do ENV["SHELL"] = "/bin/bash" expect(subject.profile).to eq("~/.bash_profile") From 2b123153def4a7c4fccbf2a646f6511515080b97 Mon Sep 17 00:00:00 2001 From: Jan Viljanen <527069+javian@users.noreply.github.com> Date: Sat, 20 Oct 2018 09:26:40 +0200 Subject: [PATCH 3/3] update description --- Library/Homebrew/test/utils/shell_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/test/utils/shell_spec.rb b/Library/Homebrew/test/utils/shell_spec.rb index e22c2efa4f..f92afd4f26 100644 --- a/Library/Homebrew/test/utils/shell_spec.rb +++ b/Library/Homebrew/test/utils/shell_spec.rb @@ -7,7 +7,7 @@ describe Utils::Shell do expect(subject.profile).to eq("~/.bash_profile") end - it "returns ~/.bash_profile by default" do + it "returns ~/.bash_profile for sh" do ENV["SHELL"] = "/bin/sh" expect(subject.profile).to eq("~/.bash_profile") end