Skip to content
Snippets Groups Projects
Commit ba26567b authored by Jack Nagel's avatar Jack Nagel
Browse files

Manage sandbox test resources in setup/teardown

parent a9725657
No related branches found
No related tags found
No related merge requests found
......@@ -4,25 +4,25 @@ require "sandbox"
class SandboxTest < Homebrew::TestCase
def setup
skip "sandbox not implemented" unless Sandbox.available?
@sandbox = Sandbox.new
@dir = Pathname.new(Dir.mktmpdir)
@file = @dir/"foo"
end
def teardown
@dir.rmtree
end
def test_allow_write
s = Sandbox.new
testpath = Pathname.new(TEST_TMPDIR)
foo = testpath/"foo"
s.allow_write foo
s.exec "touch", foo
assert_predicate foo, :exist?
foo.unlink
@sandbox.allow_write @file
@sandbox.exec "touch", @file
assert_predicate @file, :exist?
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 }
assert_raises(ErrorDuringExecution) { @sandbox.exec "touch", @file }
end
refute_predicate bar, :exist?
refute_predicate @file, :exist?
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment