diff options
| author | Xu Cheng | 2015-04-09 17:42:54 +0800 | 
|---|---|---|
| committer | Xu Cheng | 2015-04-09 17:42:54 +0800 | 
| commit | e82c3ce71878d2615a29832e6989387587c99a56 (patch) | |
| tree | f05835d999d860e9c803e28ca97acccb39ee25b6 /Library/Homebrew/test | |
| parent | 16387ff98d61f79c8d437952405a08779f41fa1f (diff) | |
| download | homebrew-e82c3ce71878d2615a29832e6989387587c99a56.tar.bz2 | |
preliminary write control only sandbox
Closes #38361.
Signed-off-by: Xu Cheng <xucheng@me.com>
Diffstat (limited to 'Library/Homebrew/test')
| -rw-r--r-- | Library/Homebrew/test/test_sandbox.rb | 28 | 
1 files changed, 28 insertions, 0 deletions
diff --git a/Library/Homebrew/test/test_sandbox.rb b/Library/Homebrew/test/test_sandbox.rb new file mode 100644 index 000000000..4564edb3b --- /dev/null +++ b/Library/Homebrew/test/test_sandbox.rb @@ -0,0 +1,28 @@ +require "testing_env" +require "sandbox" + +class SandboxTest < Homebrew::TestCase +  def setup +    skip "sandbox not implemented" unless Sandbox.available? +  end + +  def test_allow_write +    s = Sandbox.new +    testpath = Pathname.new(TEST_TMPDIR) +    foo = testpath/"foo" +    s.allow_write "#{testpath}", :type => :subpath +    s.exec "touch", foo +    assert_predicate foo, :exist? +    foo.unlink +  end + +  def test_deny_write +    s = Sandbox.new +    testpath = Pathname.new(TEST_TMPDIR) +    bar = testpath/"bar" +    shutup do +      assert_raises(ErrorDuringExecution) { s.exec "touch", bar } +    end +    refute_predicate bar, :exist? +  end +end  | 
