aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
authorMike McQuaid2016-08-14 17:34:54 +0100
committerMike McQuaid2016-08-15 08:33:58 +0100
commit6e887fbf5ac5bc1fb551a3e4222ad1804b490def (patch)
treedcf544089081597bc66812cb18d6be90a1b81390 /Library/Homebrew/test
parentca3e4fcc1de70be7d540142b186b312968e22a1a (diff)
downloadbrew-6e887fbf5ac5bc1fb551a3e4222ad1804b490def.tar.bz2
sandbox: add formula? method and sandbox core.
Add a new `Sandbox.formula?` method to see if a given formula should be sandboxed. Use the formula to check its tap against a list of pre-approved taps where we know every formula builds under the sandbox (currently just homebrew/core).
Diffstat (limited to 'Library/Homebrew/test')
-rw-r--r--Library/Homebrew/test/test_sandbox.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/Library/Homebrew/test/test_sandbox.rb b/Library/Homebrew/test/test_sandbox.rb
index de60551d1..cb33c3ffa 100644
--- a/Library/Homebrew/test/test_sandbox.rb
+++ b/Library/Homebrew/test/test_sandbox.rb
@@ -13,6 +13,22 @@ class SandboxTest < Homebrew::TestCase
@dir.rmtree
end
+ def test_formula?
+ f = formula { url "foo-1.0" }
+ f2 = formula { url "bar-1.0" }
+ f2.stubs(:tap).returns(Tap.fetch("test/tap"))
+
+ ARGV.stubs(:sandbox?).returns true
+ assert Sandbox.formula?(f),
+ "Formulae should be sandboxed if --sandbox was passed."
+
+ ARGV.stubs(:sandbox?).returns false
+ assert Sandbox.formula?(f),
+ "Formulae should be sandboxed if in a sandboxed tap."
+ refute Sandbox.formula?(f2),
+ "Formulae should not be sandboxed if not in a sandboxed tap."
+ end
+
def test_test?
ARGV.stubs(:no_sandbox?).returns false
assert Sandbox.test?,