Merge pull request #6706 from MikeMcQuaid/fix-tests

Fix some tests
This commit is contained in:
Mike McQuaid 2019-11-06 15:24:21 +00:00 committed by GitHub
commit e80008d6de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 33 deletions

View File

@ -6,34 +6,6 @@ describe Cask::Pkg, :cask do
let(:empty_response) { double(stdout: "", plist: { "volume" => "/", "install-location" => "", "paths" => {} }) } let(:empty_response) { double(stdout: "", plist: { "volume" => "/", "install-location" => "", "paths" => {} }) }
let(:pkg) { described_class.new("my.fake.pkg", fake_system_command) } let(:pkg) { described_class.new("my.fake.pkg", fake_system_command) }
it "removes files and dirs referenced by the pkg" do
some_files = Array.new(3) { Pathname.new(Tempfile.new("plain_file").path) }
allow(pkg).to receive(:pkgutil_bom_files).and_return(some_files)
some_specials = Array.new(3) { Pathname.new(Tempfile.new("special_file").path) }
allow(pkg).to receive(:pkgutil_bom_specials).and_return(some_specials)
some_dirs = Array.new(3) { mktmpdir }
allow(pkg).to receive(:pkgutil_bom_dirs).and_return(some_dirs)
root_dir = Pathname.new(mktmpdir)
allow(pkg).to receive(:root).and_return(root_dir)
allow(pkg).to receive(:forget)
pkg.uninstall
some_files.each do |file|
expect(file).not_to exist
end
some_dirs.each do |dir|
expect(dir).not_to exist
end
expect(root_dir).not_to exist
end
context "pkgutil" do context "pkgutil" do
it "forgets the pkg" do it "forgets the pkg" do
allow(fake_system_command).to receive(:run!).with( allow(fake_system_command).to receive(:run!).with(

View File

@ -124,8 +124,19 @@ RSpec.configure do |config|
end end
config.before(:each, :needs_svn) do config.before(:each, :needs_svn) do
homebrew_bin = File.dirname HOMEBREW_BREW_FILE svn_paths = PATH.new(ENV["PATH"])
skip "subversion not installed." unless %W[/usr/bin/svn #{homebrew_bin}/svn].map { |x| File.executable?(x) }.any? if OS.mac?
xcrun_svn = Utils.popen_read("xcrun", "-f", "svn")
svn_paths.append(File.dirname(xcrun_svn)) if $CHILD_STATUS.success? && xcrun_svn.present?
end
svn = which("svn", svn_paths)
svnadmin = which("svnadmin", svn_paths)
skip "subversion not installed." if !svn || !svnadmin
ENV["PATH"] = PATH.new(ENV["PATH"])
.append(svn.dirname)
.append(svnadmin.dirname)
end end
config.before(:each, :needs_unzip) do config.before(:each, :needs_unzip) do

View File

@ -8,9 +8,7 @@ describe UnpackStrategy::Subversion, :needs_svn do
let(:path) { working_copy } let(:path) { working_copy }
before do before do
svnadmin = ["svnadmin"] safe_system "svnadmin", "create", repo
svnadmin = ["xcrun", *svnadmin] if OS.mac? && MacOS.version >= :catalina
safe_system(*svnadmin, "create", repo)
safe_system "svn", "checkout", "file://#{repo}", working_copy safe_system "svn", "checkout", "file://#{repo}", working_copy
FileUtils.touch working_copy/"test" FileUtils.touch working_copy/"test"