diff options
| author | Markus Reiter | 2017-10-04 17:08:35 +0200 |
|---|---|---|
| committer | Markus Reiter | 2017-10-04 18:47:55 +0200 |
| commit | 51a0de6368974eb3476369b819c3823feebebdce (patch) | |
| tree | 9cd1dc66b7d489042e08577aa372c6afa828594f /Library/Homebrew/test | |
| parent | 2c7ef064e4ff0833ac94a4f18f5049ad17c30b7c (diff) | |
| download | brew-51a0de6368974eb3476369b819c3823feebebdce.tar.bz2 | |
Directly save artifacts in DSL.
Diffstat (limited to 'Library/Homebrew/test')
14 files changed, 59 insertions, 34 deletions
diff --git a/Library/Homebrew/test/cask/artifact/alt_target_spec.rb b/Library/Homebrew/test/cask/artifact/alt_target_spec.rb index 02be796ed..fa5d7e650 100644 --- a/Library/Homebrew/test/cask/artifact/alt_target_spec.rb +++ b/Library/Homebrew/test/cask/artifact/alt_target_spec.rb @@ -3,7 +3,7 @@ describe Hbc::Artifact::App, :cask do let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-alt-target.rb") } let(:install_phase) { - -> { described_class.for_cask(cask).each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) } } + -> { cask.artifacts.select { |a| a.is_a?(described_class) }.each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) } } } let(:source_path) { cask.staged_path.join("Caffeine.app") } diff --git a/Library/Homebrew/test/cask/artifact/app_spec.rb b/Library/Homebrew/test/cask/artifact/app_spec.rb index f67ffd31b..5ecaaef22 100644 --- a/Library/Homebrew/test/cask/artifact/app_spec.rb +++ b/Library/Homebrew/test/cask/artifact/app_spec.rb @@ -2,7 +2,7 @@ describe Hbc::Artifact::App, :cask do let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") } let(:command) { Hbc::SystemCommand } let(:force) { false } - let(:app) { described_class.for_cask(cask).first } + let(:app) { cask.artifacts.select { |a| a.is_a?(described_class) }.first } let(:source_path) { cask.staged_path.join("Caffeine.app") } let(:target_path) { Hbc.appdir.join("Caffeine.app") } diff --git a/Library/Homebrew/test/cask/artifact/binary_spec.rb b/Library/Homebrew/test/cask/artifact/binary_spec.rb index 5ffaca861..08b0af198 100644 --- a/Library/Homebrew/test/cask/artifact/binary_spec.rb +++ b/Library/Homebrew/test/cask/artifact/binary_spec.rb @@ -26,7 +26,7 @@ describe Hbc::Artifact::Binary, :cask do end it "links the binary to the proper directory" do - described_class.for_cask(cask) + cask.artifacts.select { |a| a.is_a?(described_class) } .each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) } expect(expected_path).to be_a_symlink @@ -46,7 +46,7 @@ describe Hbc::Artifact::Binary, :cask do expect(FileUtils).to receive(:chmod) .with("+x", cask.staged_path.join("naked_non_executable")).and_call_original - described_class.for_cask(cask) + cask.artifacts.select { |a| a.is_a?(described_class) } .each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) } expect(expected_path).to be_a_symlink @@ -58,7 +58,7 @@ describe Hbc::Artifact::Binary, :cask do FileUtils.touch expected_path expect { - described_class.for_cask(cask) + cask.artifacts.select { |a| a.is_a?(described_class) } .each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) } }.to raise_error(Hbc::CaskError) @@ -68,7 +68,7 @@ describe Hbc::Artifact::Binary, :cask do it "clobbers an existing symlink" do expected_path.make_symlink("/tmp") - described_class.for_cask(cask) + cask.artifacts.select { |a| a.is_a?(described_class) } .each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) } expect(File.readlink(expected_path)).not_to eq("/tmp") @@ -77,7 +77,7 @@ describe Hbc::Artifact::Binary, :cask do it "creates parent directory if it doesn't exist" do FileUtils.rmdir Hbc.binarydir - described_class.for_cask(cask) + cask.artifacts.select { |a| a.is_a?(described_class) } .each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) } expect(expected_path.exist?).to be true @@ -91,9 +91,9 @@ describe Hbc::Artifact::Binary, :cask do } it "links the binary to the proper directory" do - Hbc::Artifact::App.for_cask(cask) + cask.artifacts.select { |a| a.is_a?(Hbc::Artifact::App) } .each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) } - described_class.for_cask(cask) + cask.artifacts.select { |a| a.is_a?(described_class) } .each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) } expect(expected_path).to be_a_symlink diff --git a/Library/Homebrew/test/cask/artifact/generic_artifact_spec.rb b/Library/Homebrew/test/cask/artifact/generic_artifact_spec.rb index bec8c2742..8dc30439d 100644 --- a/Library/Homebrew/test/cask/artifact/generic_artifact_spec.rb +++ b/Library/Homebrew/test/cask/artifact/generic_artifact_spec.rb @@ -2,7 +2,7 @@ describe Hbc::Artifact::Artifact, :cask do let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-generic-artifact.rb") } let(:install_phase) { - -> { described_class.for_cask(cask).each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) } } + -> { cask.artifacts.select { |a| a.is_a?(described_class) }.each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) } } } let(:source_path) { cask.staged_path.join("Caffeine.app") } diff --git a/Library/Homebrew/test/cask/artifact/nested_container_spec.rb b/Library/Homebrew/test/cask/artifact/nested_container_spec.rb index 41d143764..65759b5b7 100644 --- a/Library/Homebrew/test/cask/artifact/nested_container_spec.rb +++ b/Library/Homebrew/test/cask/artifact/nested_container_spec.rb @@ -5,7 +5,7 @@ describe Hbc::Artifact::NestedContainer, :cask do InstallHelper.install_without_artifacts(c) end - described_class.for_cask(cask) + cask.artifacts.select { |a| a.is_a?(described_class) } .each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) } expect(cask.staged_path.join("MyNestedApp.app")).to be_a_directory diff --git a/Library/Homebrew/test/cask/artifact/pkg_spec.rb b/Library/Homebrew/test/cask/artifact/pkg_spec.rb index c6a45c49a..d3028be9c 100644 --- a/Library/Homebrew/test/cask/artifact/pkg_spec.rb +++ b/Library/Homebrew/test/cask/artifact/pkg_spec.rb @@ -8,7 +8,7 @@ describe Hbc::Artifact::Pkg, :cask do describe "install_phase" do it "runs the system installer on the specified pkgs" do - pkg = described_class.for_cask(cask).first + pkg = cask.artifacts.select { |a| a.is_a?(described_class) }.first expect(fake_system_command).to receive(:run!).with( "/usr/sbin/installer", @@ -25,7 +25,7 @@ describe Hbc::Artifact::Pkg, :cask do let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-choices.rb") } it "passes the choice changes xml to the system installer" do - pkg = described_class.for_cask(cask).first + pkg = cask.artifacts.select { |a| a.is_a?(described_class) }.first file = double(path: Pathname.new("/tmp/choices.xml")) diff --git a/Library/Homebrew/test/cask/artifact/postflight_block_spec.rb b/Library/Homebrew/test/cask/artifact/postflight_block_spec.rb index 4a44bb59b..acd63671a 100644 --- a/Library/Homebrew/test/cask/artifact/postflight_block_spec.rb +++ b/Library/Homebrew/test/cask/artifact/postflight_block_spec.rb @@ -11,7 +11,7 @@ describe Hbc::Artifact::PostflightBlock, :cask do end end - described_class.for_cask(cask) + cask.artifacts.select { |a| a.is_a?(described_class) } .each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) } expect(called).to be true @@ -31,7 +31,7 @@ describe Hbc::Artifact::PostflightBlock, :cask do end end - described_class.for_cask(cask) + cask.artifacts.select { |a| a.is_a?(described_class) } .each { |artifact| artifact.uninstall_phase(command: Hbc::NeverSudoSystemCommand, force: false) } expect(called).to be true diff --git a/Library/Homebrew/test/cask/artifact/preflight_block_spec.rb b/Library/Homebrew/test/cask/artifact/preflight_block_spec.rb index d7d4e72d9..285a93ffb 100644 --- a/Library/Homebrew/test/cask/artifact/preflight_block_spec.rb +++ b/Library/Homebrew/test/cask/artifact/preflight_block_spec.rb @@ -11,7 +11,7 @@ describe Hbc::Artifact::PreflightBlock, :cask do end end - described_class.for_cask(cask) + cask.artifacts.select { |a| a.is_a?(described_class) } .each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) } expect(called).to be true @@ -31,7 +31,7 @@ describe Hbc::Artifact::PreflightBlock, :cask do end end - described_class.for_cask(cask) + cask.artifacts.select { |a| a.is_a?(described_class) } .each { |artifact| artifact.uninstall_phase(command: Hbc::NeverSudoSystemCommand, force: false) } expect(called).to be true diff --git a/Library/Homebrew/test/cask/artifact/suite_spec.rb b/Library/Homebrew/test/cask/artifact/suite_spec.rb index 2f913fecc..1826dffbb 100644 --- a/Library/Homebrew/test/cask/artifact/suite_spec.rb +++ b/Library/Homebrew/test/cask/artifact/suite_spec.rb @@ -2,7 +2,7 @@ describe Hbc::Artifact::Suite, :cask do let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-suite.rb") } let(:install_phase) { - -> { described_class.for_cask(cask).each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) } } + -> { cask.artifacts.select { |a| a.is_a?(described_class) }.each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) } } } let(:target_path) { Hbc.appdir.join("Caffeine") } diff --git a/Library/Homebrew/test/cask/artifact/two_apps_correct_spec.rb b/Library/Homebrew/test/cask/artifact/two_apps_correct_spec.rb index f6e0d3c97..ca8c44903 100644 --- a/Library/Homebrew/test/cask/artifact/two_apps_correct_spec.rb +++ b/Library/Homebrew/test/cask/artifact/two_apps_correct_spec.rb @@ -3,7 +3,7 @@ describe Hbc::Artifact::App, :cask do let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-two-apps-correct.rb") } let(:install_phase) { - -> { described_class.for_cask(cask).each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) } } + -> { cask.artifacts.select { |a| a.is_a?(described_class) }.each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) } } } let(:source_path_mini) { cask.staged_path.join("Caffeine Mini.app") } diff --git a/Library/Homebrew/test/cask/artifact/uninstall_no_zap_spec.rb b/Library/Homebrew/test/cask/artifact/uninstall_no_zap_spec.rb index d6a8393da..da0bfbb78 100644 --- a/Library/Homebrew/test/cask/artifact/uninstall_no_zap_spec.rb +++ b/Library/Homebrew/test/cask/artifact/uninstall_no_zap_spec.rb @@ -2,7 +2,7 @@ describe Hbc::Artifact::Zap, :cask do let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installable.rb") } let(:zap_artifact) { - described_class.for_cask(cask).first + cask.artifacts.select { |a| a.is_a?(described_class) }.first } before(:each) do 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 4fdab60d0..f1eb1b913 100644 --- a/Library/Homebrew/test/cask/artifact/uninstall_zap_shared_examples.rb +++ b/Library/Homebrew/test/cask/artifact/uninstall_zap_shared_examples.rb @@ -1,6 +1,6 @@ shared_examples "#uninstall_phase or #zap_phase" do let(:artifact_dsl_key) { described_class.dsl_key } - let(:artifact) { described_class.for_cask(cask).first } + let(:artifact) { cask.artifacts.select { |a| a.is_a?(described_class) }.first } let(:fake_system_command) { Hbc::FakeSystemCommand } subject { artifact.public_send(:"#{artifact_dsl_key}_phase", command: fake_system_command) } diff --git a/Library/Homebrew/test/cask/cli/list_spec.rb b/Library/Homebrew/test/cask/cli/list_spec.rb index 75da82762..4f59aafe9 100644 --- a/Library/Homebrew/test/cask/cli/list_spec.rb +++ b/Library/Homebrew/test/cask/cli/list_spec.rb @@ -72,7 +72,7 @@ describe Hbc::CLI::List, :cask do it "lists the installed files for those Casks" do casks.each(&InstallHelper.method(:install_without_artifacts_with_caskfile)) - Hbc::Artifact::App.for_cask(transmission) + transmission.artifacts.select { |a| a.is_a?(Hbc::Artifact::App) } .each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) } expect { diff --git a/Library/Homebrew/test/cask/dsl_spec.rb b/Library/Homebrew/test/cask/dsl_spec.rb index e03af9aef..390e56b18 100644 --- a/Library/Homebrew/test/cask/dsl_spec.rb +++ b/Library/Homebrew/test/cask/dsl_spec.rb @@ -216,12 +216,12 @@ describe Hbc::DSL, :cask do app "Bar.app" end - expect(cask.artifacts[Hbc::Artifact::App].map(&:to_s)).to eq(["Foo.app (App)", "Bar.app (App)"]) + expect(cask.artifacts.select { |a| a.is_a?(Hbc::Artifact::App) }.map(&:to_s)).to eq(["Foo.app (App)", "Bar.app (App)"]) end it "allow app stanzas to be empty" do cask = Hbc::Cask.new("cask-with-no-apps") - expect(cask.artifacts[Hbc::Artifact::App]).to be_empty + expect(cask.artifacts.select { |a| a.is_a?(Hbc::Artifact::App) }).to be_empty end end @@ -249,7 +249,7 @@ describe Hbc::DSL, :cask do pkg "Bar.pkg" end - expect(cask.artifacts[Hbc::Artifact::Pkg].map(&:to_s)).to eq(["Foo.pkg (Pkg)", "Bar.pkg (Pkg)"]) + expect(cask.artifacts.select { |a| a.is_a?(Hbc::Artifact::Pkg) }.map(&:to_s)).to eq(["Foo.pkg (Pkg)", "Bar.pkg (Pkg)"]) end end @@ -501,10 +501,10 @@ describe Hbc::DSL, :cask do let(:token) { "with-installer-script" } it "allows installer script to be specified" do - expect(cask.artifacts[Hbc::Artifact::Installer].first.path).to eq(Pathname("/usr/bin/true")) - expect(cask.artifacts[Hbc::Artifact::Installer].first.args[:args]).to eq(["--flag"]) - expect(cask.artifacts[Hbc::Artifact::Installer].to_a[1].path).to eq(Pathname("/usr/bin/false")) - expect(cask.artifacts[Hbc::Artifact::Installer].to_a[1].args[:args]).to eq(["--flag"]) + expect(cask.artifacts.select { |a| a.is_a?(Hbc::Artifact::Installer) }.first.path).to eq(Pathname("/usr/bin/true")) + expect(cask.artifacts.select { |a| a.is_a?(Hbc::Artifact::Installer) }.first.args[:args]).to eq(["--flag"]) + expect(cask.artifacts.select { |a| a.is_a?(Hbc::Artifact::Installer) }.to_a[1].path).to eq(Pathname("/usr/bin/false")) + expect(cask.artifacts.select { |a| a.is_a?(Hbc::Artifact::Installer) }.to_a[1].args[:args]).to eq(["--flag"]) end end @@ -512,7 +512,7 @@ describe Hbc::DSL, :cask do let(:token) { "with-installer-manual" } it "allows installer manual to be specified" do - installer = cask.artifacts[Hbc::Artifact::Installer].first + installer = cask.artifacts.select { |a| a.is_a?(Hbc::Artifact::Installer) }.first expect(installer).to be_a(Hbc::Artifact::Installer::ManualInstaller) expect(installer.path).to eq(cask.staged_path.join("Caffeine.app")) end @@ -524,7 +524,7 @@ describe Hbc::DSL, :cask do let(:token) { "stage-only" } it "allows stage_only stanza to be specified" do - expect(cask.artifacts[Hbc::Artifact::StageOnly]).not_to be_empty + expect(cask.artifacts.select { |a| a.is_a?(Hbc::Artifact::StageOnly) }).not_to be_empty end end @@ -545,12 +545,12 @@ describe Hbc::DSL, :cask do end end - describe "appdir" do + describe "#appdir" do context "interpolation of the appdir in stanzas" do let(:token) { "appdir-interpolation" } it "is allowed" do - expect(cask.artifacts[Hbc::Artifact::Binary].first.source).to eq(Hbc.appdir/"some/path") + expect(cask.artifacts.select { |a| a.is_a?(Hbc::Artifact::Binary) }.first.source).to eq(Hbc.appdir/"some/path") end end @@ -563,10 +563,35 @@ describe Hbc::DSL, :cask do binary "#{appdir}/some/path" end - expect(cask.artifacts[Hbc::Artifact::Binary].first.source).to eq(original_appdir/"some/path") + expect(cask.artifacts.select { |a| a.is_a?(Hbc::Artifact::Binary) }.first.source).to eq(original_appdir/"some/path") ensure Hbc.appdir = original_appdir end end end + + describe "#artifacts" do + it "sorts artifacts according to the preferable installation order" do + cask = Hbc::Cask.new("appdir-trailing-slash") do + postflight do + next + end + + preflight do + next + end + + binary "binary" + + app "App.app" + end + + expect(cask.artifacts.map(&:class).map(&:dsl_key)).to eq [ + :preflight, + :app, + :binary, + :postflight, + ] + end + end end |
