Fix type errors in Sandbox.

This commit is contained in:
Markus Reiter 2020-11-23 17:31:17 +01:00
parent 9ee8cc97c9
commit cf169e5270
2 changed files with 43 additions and 35 deletions

View File

@ -5,9 +5,12 @@
# #
# @api private # @api private
module OS module OS
extend T::Sig
# Check if the operating system is macOS. # Check if the operating system is macOS.
# #
# @api public # @api public
sig { returns(T::Boolean) }
def self.mac? def self.mac?
return false if ENV["HOMEBREW_TEST_GENERIC_OS"] return false if ENV["HOMEBREW_TEST_GENERIC_OS"]
@ -17,6 +20,7 @@ module OS
# Check if the operating system is Linux. # Check if the operating system is Linux.
# #
# @api public # @api public
sig { returns(T::Boolean) }
def self.linux? def self.linux?
return false if ENV["HOMEBREW_TEST_GENERIC_OS"] return false if ENV["HOMEBREW_TEST_GENERIC_OS"]
@ -26,6 +30,7 @@ module OS
# Get the kernel version. # Get the kernel version.
# #
# @api public # @api public
sig { returns(Version) }
def self.kernel_version def self.kernel_version
@kernel_version ||= Version.new(Utils.safe_popen_read("uname", "-r").chomp) @kernel_version ||= Version.new(Utils.safe_popen_read("uname", "-r").chomp)
end end

View File

@ -1,4 +1,4 @@
# typed: false # typed: true
# frozen_string_literal: true # frozen_string_literal: true
require "erb" require "erb"
@ -56,12 +56,12 @@ class Sandbox
end end
def allow_cvs def allow_cvs
allow_write_path "#{Dir.home(ENV["USER"])}/.cvspass" allow_write_path "#{Dir.home(ENV.fetch("USER"))}/.cvspass"
end end
def allow_fossil def allow_fossil
allow_write_path "#{Dir.home(ENV["USER"])}/.fossil" allow_write_path "#{Dir.home(ENV.fetch("USER"))}/.fossil"
allow_write_path "#{Dir.home(ENV["USER"])}/.fossil-journal" allow_write_path "#{Dir.home(ENV.fetch("USER"))}/.fossil-journal"
end end
def allow_write_cellar(formula) def allow_write_cellar(formula)
@ -72,7 +72,7 @@ class Sandbox
# Xcode projects expect access to certain cache/archive dirs. # Xcode projects expect access to certain cache/archive dirs.
def allow_write_xcode def allow_write_xcode
allow_write_path "#{Dir.home(ENV["USER"])}/Library/Developer" allow_write_path "#{Dir.home(ENV.fetch("USER"))}/Library/Developer"
end end
def allow_write_log(formula) def allow_write_log(formula)
@ -94,7 +94,9 @@ class Sandbox
seatbelt.write(@profile.dump) seatbelt.write(@profile.dump)
seatbelt.close seatbelt.close
@start = Time.now @start = Time.now
safe_system SANDBOX_EXEC, "-f", seatbelt.path, *args
begin
T.unsafe(self).safe_system SANDBOX_EXEC, "-f", seatbelt.path, *args
rescue rescue
@failed = true @failed = true
raise raise
@ -131,6 +133,7 @@ class Sandbox
end end
end end
end end
end
private private