sandbox: add test? method.
Simplify checking if we’re going to sandbox a test with `Sandbox.test?`.
This commit is contained in:
		
							parent
							
								
									b630ab3d17
								
							
						
					
					
						commit
						fed96385ac
					
				@ -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"
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user