diff options
| author | Mike McQuaid | 2016-08-14 17:33:05 +0100 | 
|---|---|---|
| committer | Mike McQuaid | 2016-08-15 08:33:58 +0100 | 
| commit | fed96385acc2ee10909870997950f2e48a86026f (patch) | |
| tree | 12b3c3f10e5c81febac3e1c9a529cb2411024d12 /Library/Homebrew | |
| parent | b630ab3d1717c1a436610a1542c71ebaadcf3bc0 (diff) | |
| download | brew-fed96385acc2ee10909870997950f2e48a86026f.tar.bz2 | |
sandbox: add test? method.
Simplify checking if we’re going to sandbox a test with `Sandbox.test?`.
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/sandbox.rb | 5 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_sandbox.rb | 6 | 
2 files changed, 11 insertions, 0 deletions
diff --git a/Library/Homebrew/sandbox.rb b/Library/Homebrew/sandbox.rb index 4823baf7f..c299d2f45 100644 --- a/Library/Homebrew/sandbox.rb +++ b/Library/Homebrew/sandbox.rb @@ -8,6 +8,11 @@ class Sandbox      OS.mac? && File.executable?(SANDBOX_EXEC)    end +  def self.test? +    return false unless available? +    !ARGV.no_sandbox? +  end +    def self.print_sandbox_message      unless @printed_sandbox_message        ohai "Using the sandbox" diff --git a/Library/Homebrew/test/test_sandbox.rb b/Library/Homebrew/test/test_sandbox.rb index dc907d428..de60551d1 100644 --- a/Library/Homebrew/test/test_sandbox.rb +++ b/Library/Homebrew/test/test_sandbox.rb @@ -13,6 +13,12 @@ class SandboxTest < Homebrew::TestCase      @dir.rmtree    end +  def test_test? +    ARGV.stubs(:no_sandbox?).returns false +    assert Sandbox.test?, +      "Tests should be sandboxed unless --no-sandbox was passed." +  end +    def test_allow_write      @sandbox.allow_write @file      @sandbox.exec "touch", @file  | 
