From 965ca015965bfb376cb20e40c2c534f9572edb37 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 1 Oct 2017 01:47:08 +0200 Subject: [PATCH 1/2] Fix `brew tests` leaving last file in trash. --- .../Homebrew/cask/lib/hbc/artifact/abstract_uninstall.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cask/lib/hbc/artifact/abstract_uninstall.rb b/Library/Homebrew/cask/lib/hbc/artifact/abstract_uninstall.rb index badd549ce7..d0b2eb6ef7 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/abstract_uninstall.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/abstract_uninstall.rb @@ -253,7 +253,7 @@ module Hbc end def trash_paths(*paths, command: nil, **_) - command.run!("/usr/bin/osascript", args: ["-e", <<-'EOS'.undent, *paths]) + result = command.run!("/usr/bin/osascript", args: ["-e", <<-'EOS'.undent, *paths]) on run argv repeat with i from 1 to (count argv) set item i of argv to (item i of argv as POSIX file) @@ -267,7 +267,7 @@ module Hbc set trashedItem to POSIX path of (item i of trashedItems as string) set output to output & trashedItem if i < count trashedItems then - set output to output & (do shell script "printf \"\\0\"") + set output to output & character id 0 end if end repeat @@ -275,6 +275,9 @@ module Hbc end tell end run EOS + + # Remove AppleScript's automatic newline. + result.tap { |r| r.stdout.sub!(/\n$/, "") } end def uninstall_rmdir(*directories, command: nil, **_) From 3bb89f5440c030e06819affe3b821a771e86a671 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 1 Oct 2017 22:26:04 +0200 Subject: [PATCH 2/2] Only run trash test when collecting coverage. --- .../test/cask/artifact/uninstall_zap_shared_examples.rb | 2 ++ 1 file changed, 2 insertions(+) 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 06eec4a011..4fdab60d00 100644 --- a/Library/Homebrew/test/cask/artifact/uninstall_zap_shared_examples.rb +++ b/Library/Homebrew/test/cask/artifact/uninstall_zap_shared_examples.rb @@ -149,6 +149,8 @@ shared_examples "#uninstall_phase or #zap_phase" do end [:delete, :trash].each do |directive| + next if directive == :trash && ENV["HOMEBREW_TESTS_COVERAGE"].nil? + context "using :#{directive}" do let(:dir) { TEST_TMPDIR } let(:absolute_path) { Pathname.new("#{dir}/absolute_path") }