diff options
| author | Markus Reiter | 2016-12-06 15:08:21 +0100 |
|---|---|---|
| committer | GitHub | 2016-12-06 15:08:21 +0100 |
| commit | 049206bf16ed48ae101bef959613ae23aa368cc2 (patch) | |
| tree | 9008798655a9ec358f90af56a7cb92ca3e74cc79 /Library/Homebrew/cask/test | |
| parent | 29aa1c8c3da244abf6eb1de48d262e091d52f51e (diff) | |
| parent | 86a80c8a3dfdad2275a9937df5fe39cbe8f417dd (diff) | |
| download | brew-049206bf16ed48ae101bef959613ae23aa368cc2.tar.bz2 | |
Merge pull request #1464 from reitermarkus/quit-with-launchctl
Use `launchctl` to get running processes by bundle ID.
Diffstat (limited to 'Library/Homebrew/cask/test')
| -rw-r--r-- | Library/Homebrew/cask/test/cask/artifact/uninstall_test.rb | 14 | ||||
| -rw-r--r-- | Library/Homebrew/cask/test/cask/artifact/zap_test.rb | 14 |
2 files changed, 6 insertions, 22 deletions
diff --git a/Library/Homebrew/cask/test/cask/artifact/uninstall_test.rb b/Library/Homebrew/cask/test/cask/artifact/uninstall_test.rb index b9c5c3187..b09d39833 100644 --- a/Library/Homebrew/cask/test/cask/artifact/uninstall_test.rb +++ b/Library/Homebrew/cask/test/cask/artifact/uninstall_test.rb @@ -207,21 +207,17 @@ describe Hbc::Artifact::Uninstall do describe "when using quit" do let(:cask) { Hbc.load("with-uninstall-quit") } let(:bundle_id) { "my.fancy.package.app" } - let(:count_processes_script) { - 'tell application "System Events" to count processes ' + - %Q(whose bundle identifier is "#{bundle_id}") - } let(:quit_application_script) { %Q(tell application id "#{bundle_id}" to quit) } it "can uninstall" do Hbc::FakeSystemCommand.stubs_command( - sudo(%W[/usr/bin/osascript -e #{count_processes_script}]), "1" + %w[/bin/launchctl list], "999\t0\t#{bundle_id}\n" ) Hbc::FakeSystemCommand.stubs_command( - sudo(%W[/usr/bin/osascript -e #{quit_application_script}]) + %w[/bin/launchctl list] ) subject @@ -233,14 +229,10 @@ describe Hbc::Artifact::Uninstall do let(:bundle_id) { "my.fancy.package.app" } let(:signals) { %w[TERM KILL] } let(:unix_pids) { [12_345, 67_890] } - let(:get_unix_pids_script) { - 'tell application "System Events" to get the unix id of every process ' + - %Q(whose bundle identifier is "#{bundle_id}") - } it "can uninstall" do Hbc::FakeSystemCommand.stubs_command( - sudo(%W[/usr/bin/osascript -e #{get_unix_pids_script}]), unix_pids.join(", ") + %w[/bin/launchctl list], unix_pids.map { |pid| [pid, 0, bundle_id].join("\t") }.join("\n") ) signals.each do |signal| diff --git a/Library/Homebrew/cask/test/cask/artifact/zap_test.rb b/Library/Homebrew/cask/test/cask/artifact/zap_test.rb index fbbf520a0..b65b0bf5c 100644 --- a/Library/Homebrew/cask/test/cask/artifact/zap_test.rb +++ b/Library/Homebrew/cask/test/cask/artifact/zap_test.rb @@ -208,21 +208,17 @@ describe Hbc::Artifact::Zap do describe "when using quit" do let(:cask) { Hbc.load("with-zap-quit") } let(:bundle_id) { "my.fancy.package.app" } - let(:count_processes_script) { - 'tell application "System Events" to count processes ' + - %Q(whose bundle identifier is "#{bundle_id}") - } let(:quit_application_script) { %Q(tell application id "#{bundle_id}" to quit) } it "can zap" do Hbc::FakeSystemCommand.stubs_command( - sudo(%W[/usr/bin/osascript -e #{count_processes_script}]), "1" + %w[/bin/launchctl list], "999\t0\t#{bundle_id}\n" ) Hbc::FakeSystemCommand.stubs_command( - sudo(%W[/usr/bin/osascript -e #{quit_application_script}]) + %w[/bin/launchctl list] ) subject @@ -234,14 +230,10 @@ describe Hbc::Artifact::Zap do let(:bundle_id) { "my.fancy.package.app" } let(:signals) { %w[TERM KILL] } let(:unix_pids) { [12_345, 67_890] } - let(:get_unix_pids_script) { - 'tell application "System Events" to get the unix id of every process ' + - %Q(whose bundle identifier is "#{bundle_id}") - } it "can zap" do Hbc::FakeSystemCommand.stubs_command( - sudo(%W[/usr/bin/osascript -e #{get_unix_pids_script}]), unix_pids.join(", ") + %w[/bin/launchctl list], unix_pids.map { |pid| [pid, 0, bundle_id].join("\t") }.join("\n") ) signals.each do |signal| |
