aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
authorMarkus Reiter2017-06-30 14:38:57 +0200
committerGitHub2017-06-30 14:38:57 +0200
commit29ffe158903c0528c672da50c2b83b1b5d8cbe1c (patch)
tree607c312a5146c74b6d26cde2aeeef6474e5c43a8 /Library/Homebrew/test
parent0077e4f20ef9d107a0ca8c5ab75cac552163fb45 (diff)
parenta636d5806705c2ccc68fb9d4fad0ee92dfe06bc8 (diff)
downloadbrew-29ffe158903c0528c672da50c2b83b1b5d8cbe1c.tar.bz2
Merge pull request #2819 from reitermarkus/trash
🗑️ Use AppleScript instead of Swift for trashing.
Diffstat (limited to 'Library/Homebrew/test')
-rw-r--r--Library/Homebrew/test/cask/artifact/uninstall_zap_shared_examples.rb8
-rw-r--r--Library/Homebrew/test/spec_helper.rb10
-rw-r--r--Library/Homebrew/test/utils/trash_spec.rb32
3 files changed, 16 insertions, 34 deletions
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 6c2fd1a05..b84c1fd00 100644
--- a/Library/Homebrew/test/cask/artifact/uninstall_zap_shared_examples.rb
+++ b/Library/Homebrew/test/cask/artifact/uninstall_zap_shared_examples.rb
@@ -176,6 +176,14 @@ shared_examples "#uninstall_phase or #zap_phase" do
let(:fake_system_command) { Hbc::NeverSudoSystemCommand }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-#{artifact_name}-#{directive}.rb") }
+ before(:each) do
+ allow_any_instance_of(Hbc::Artifact::UninstallBase).to receive(:trash_paths)
+ .and_wrap_original do |method, *args|
+ result = method.call(*args)
+ FileUtils.rm_rf result.stdout.split("\0")
+ end
+ end
+
it "is supported" do
paths.each do |path|
expect(path).to exist
diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb
index 03b14720b..75540caad 100644
--- a/Library/Homebrew/test/spec_helper.rb
+++ b/Library/Homebrew/test/spec_helper.rb
@@ -68,12 +68,18 @@ RSpec.configure do |config|
end
config.around(:each) do |example|
+ def find_files
+ Find.find(TEST_TMPDIR)
+ .reject { |f| File.basename(f) == ".DS_Store" }
+ .map { |f| f.sub(TEST_TMPDIR, "") }
+ end
+
begin
TEST_DIRECTORIES.each(&:mkpath)
@__homebrew_failed = Homebrew.failed?
- @__files_before_test = Find.find(TEST_TMPDIR).map { |f| f.sub(TEST_TMPDIR, "") }
+ @__files_before_test = find_files
@__argv = ARGV.dup
@__env = ENV.to_hash # dup doesn't work on ENV
@@ -106,7 +112,7 @@ RSpec.configure do |config|
CoreTap.instance.path/"formula_renames.json",
]
- files_after_test = Find.find(TEST_TMPDIR).map { |f| f.sub(TEST_TMPDIR, "") }
+ files_after_test = find_files
diff = Set.new(@__files_before_test) ^ Set.new(files_after_test)
expect(diff).to be_empty, <<-EOS.undent
diff --git a/Library/Homebrew/test/utils/trash_spec.rb b/Library/Homebrew/test/utils/trash_spec.rb
deleted file mode 100644
index 9f2f7df15..000000000
--- a/Library/Homebrew/test/utils/trash_spec.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-require "open3"
-
-describe "trash", :needs_macos do
- let(:executable) { HOMEBREW_LIBRARY_PATH/"utils/trash.swift" }
- let(:dir) { mktmpdir }
- let(:file) { dir/"new_file" }
-
- it "moves existing files to the trash" do
- FileUtils.touch file
-
- expect(file).to exist
-
- out, err, status = Open3.capture3(executable, file)
-
- expect(out).to match %r{moved #{file} to .*/\.Trash/\.*}
- expect(err).to be_empty
- expect(status).to be_a_success
-
- expect(file).not_to exist
-
- trashed_path = out.sub(/^moved #{Regexp.escape(file.to_s)} to (.*)\n$/, '\1')
- FileUtils.rm_f trashed_path
- end
-
- it "fails when files don't exist" do
- out, err, status = Open3.capture3(executable, file)
-
- expect(out).to be_empty
- expect(err).to eq "could not move #{file} to trash\n"
- expect(status).to be_a_failure
- end
-end