diff options
| author | Markus Reiter | 2016-11-09 09:32:54 +0100 |
|---|---|---|
| committer | Markus Reiter | 2016-12-05 00:20:29 +0100 |
| commit | 86a80c8a3dfdad2275a9937df5fe39cbe8f417dd (patch) | |
| tree | 10f37f45d02bf4c4e2895a8408a7a722f15a5116 /Library/Homebrew/cask/test | |
| parent | 88d0e8c2e6c02d07111d99250e24f2bc201c8444 (diff) | |
| download | brew-86a80c8a3dfdad2275a9937df5fe39cbe8f417dd.tar.bz2 | |
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| |
