From 58df7885e66616588d341dfe713c90ed1c198868 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 6 Sep 2023 10:03:45 -0400 Subject: [PATCH] cask/quarantine: sudo correctly during tests. Use `NeverSudoSystemCommand` and pass it through to `Quarantine.copy_xattrs` so `brew tests` doesn't try to `sudo`. Fixes #15958 Co-authored-by: Bo Anderson Co-authored-by: Kevin --- Library/Homebrew/cask/artifact/moved.rb | 2 +- Library/Homebrew/cask/quarantine.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/cask/artifact/moved.rb b/Library/Homebrew/cask/artifact/moved.rb index d41e62cec0..a9e3470d7c 100644 --- a/Library/Homebrew/cask/artifact/moved.rb +++ b/Library/Homebrew/cask/artifact/moved.rb @@ -91,7 +91,7 @@ module Cask command.run!("/bin/cp", args: ["-pR", *source.children, target], sudo: true) end - Quarantine.copy_xattrs(source, target) + Quarantine.copy_xattrs(source, target, command: command) source.rmtree elsif target.dirname.writable? FileUtils.move(source, target) diff --git a/Library/Homebrew/cask/quarantine.rb b/Library/Homebrew/cask/quarantine.rb index 2277906293..e038011e64 100644 --- a/Library/Homebrew/cask/quarantine.rb +++ b/Library/Homebrew/cask/quarantine.rb @@ -174,11 +174,11 @@ module Cask raise CaskQuarantinePropagationError.new(to, quarantiner.stderr) end - sig { params(from: Pathname, to: Pathname).void } - def self.copy_xattrs(from, to) + sig { params(from: Pathname, to: Pathname, command: T.class_of(SystemCommand)).void } + def self.copy_xattrs(from, to, command:) odebug "Copying xattrs from #{from} to #{to}" - system_command!( + command.run!( swift, args: [ *swift_target_args,