From acc9a7ca8554bc2413dee2d6d0f407b3a59c628c Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sun, 10 Apr 2016 22:53:56 -0400 Subject: brew test, install, update-test: add --keep-tmp option Also enables sandbox for --interactive and --debug use of install and test, using automatic retention. Closes #66. Signed-off-by: Andrew Janke --- Library/Homebrew/cmd/install.rb | 5 ++++- Library/Homebrew/cmd/postinstall.rb | 8 ++------ Library/Homebrew/cmd/test-bot.rb | 19 +++++++++++++++---- Library/Homebrew/cmd/test.rb | 13 ++++++------- 4 files changed, 27 insertions(+), 18 deletions(-) (limited to 'Library/Homebrew/cmd') diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index 7e1edc237..22be53ad0 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -1,4 +1,4 @@ -#: * `install` [`--debug`] [`--env=`|] [`--ignore-dependencies`] [`--only-dependencies`] [`--cc=`] [`--build-from-source`|`--force-bottle`] [`--devel`|`--HEAD`] : +#: * `install` [`--debug`] [`--env=`|] [`--ignore-dependencies`] [`--only-dependencies`] [`--cc=`] [`--build-from-source`|`--force-bottle`] [`--devel`|`--HEAD`] [`--keep-tmp`] : #: Install . #: #: is usually the name of the formula to install, but it can be specified @@ -35,6 +35,9 @@ #: If `--HEAD` is passed, and defines it, install the HEAD version, #: aka master, trunk, unstable. #: +#: If `--keep-tmp` is passed, the temporary files created for the test are +#: not deleted. +#: #: To install a newer version of HEAD use #: `brew rm && brew install --HEAD `. #: diff --git a/Library/Homebrew/cmd/postinstall.rb b/Library/Homebrew/cmd/postinstall.rb index 5987fda16..95bd3f8ef 100644 --- a/Library/Homebrew/cmd/postinstall.rb +++ b/Library/Homebrew/cmd/postinstall.rb @@ -22,15 +22,11 @@ module Homebrew end if Sandbox.available? && ARGV.sandbox? - if Sandbox.auto_disable? - Sandbox.print_autodisable_warning - else - Sandbox.print_sandbox_message - end + Sandbox.print_sandbox_message end Utils.safe_fork do - if Sandbox.available? && ARGV.sandbox? && !Sandbox.auto_disable? + if Sandbox.available? && ARGV.sandbox? sandbox = Sandbox.new formula.logs.mkpath sandbox.record_log(formula.logs/"sandbox.postinstall.log") diff --git a/Library/Homebrew/cmd/test-bot.rb b/Library/Homebrew/cmd/test-bot.rb index 85c75d0ab..414558b2c 100644 --- a/Library/Homebrew/cmd/test-bot.rb +++ b/Library/Homebrew/cmd/test-bot.rb @@ -21,6 +21,7 @@ # --verbose: Print test step output in realtime. Has the side effect of passing output # as raw bytes instead of re-encoding in UTF-8. # --fast: Don't install any packages, but run e.g. audit anyway. +# --keep-tmp: Keep temporary files written by main installs and tests that are run. # # --ci-master: Shortcut for Homebrew master branch CI options. # --ci-pr: Shortcut for Homebrew pull request CI options. @@ -532,7 +533,12 @@ module Homebrew end test "brew", "fetch", "--retry", *fetch_args test "brew", "uninstall", "--force", formula_name if formula.installed? - install_args = ["--verbose"] + + # shared_*_args are applied to both the main and --devel spec + shared_install_args = ["--verbose"] + shared_install_args << "--keep-tmp" if ARGV.keep_tmp? + # install_args is just for the main (stable, or devel if in a devel-only tap) spec + install_args = [] install_args << "--build-bottle" if !ARGV.include?("--fast") && !ARGV.include?("--no-bottle") && !formula.bottle_disabled? install_args << "--HEAD" if ARGV.include? "--HEAD" @@ -548,6 +554,7 @@ module Homebrew formula_bottled = formula.bottled? end + install_args.concat(shared_install_args) install_args << formula_name # Don't care about e.g. bottle failures for dependencies. install_passed = false @@ -582,7 +589,9 @@ module Homebrew test "brew", "install", bottle_filename end end - test "brew", "test", "--verbose", formula_name if formula.test_defined? + shared_test_args = ["--verbose"] + shared_test_args << "--keep-tmp" if ARGV.keep_tmp? + test "brew", "test", formula_name, *shared_test_args if formula.test_defined? testable_dependents.each do |dependent| unless dependent.installed? test "brew", "fetch", "--retry", dependent.name @@ -607,11 +616,13 @@ module Homebrew && !ARGV.include?("--HEAD") && !ARGV.include?("--fast") \ && satisfied_requirements?(formula, :devel) test "brew", "fetch", "--retry", "--devel", *fetch_args - run_as_not_developer { test "brew", "install", "--devel", "--verbose", formula_name } + run_as_not_developer do + test "brew", "install", "--devel", formula_name, *shared_install_args + end devel_install_passed = steps.last.passed? test "brew", "audit", "--devel", *audit_args if devel_install_passed - test "brew", "test", "--devel", "--verbose", formula_name if formula.test_defined? + test "brew", "test", "--devel", formula_name, *shared_test_args if formula.test_defined? test "brew", "uninstall", "--devel", "--force", formula_name end end diff --git a/Library/Homebrew/cmd/test.rb b/Library/Homebrew/cmd/test.rb index ffb9c169d..0218e1c80 100644 --- a/Library/Homebrew/cmd/test.rb +++ b/Library/Homebrew/cmd/test.rb @@ -1,4 +1,4 @@ -#: * `test` [`--devel`|`--HEAD`] [`--debug`] : +#: * `test` [`--devel`|`--HEAD`] [`--debug`] [`--keep-tmp`] : #: A few formulae provide a test method. `brew test` runs this #: test method. There is no standard output or return code, but it should #: generally indicate to the user if something is wrong with the installed @@ -10,6 +10,9 @@ #: If `--debug` is passed and the test fails, an interactive debugger will be #: launched with access to IRB or a shell inside the temporary test directory. #: +#: If `--keep-tmp` is passed, the temporary files created for the test are +#: not deleted. +#: #: Example: `brew install jruby && brew test jruby` require "extend/ENV" @@ -55,15 +58,11 @@ module Homebrew end if Sandbox.available? && !ARGV.no_sandbox? - if Sandbox.auto_disable? - Sandbox.print_autodisable_warning - else - Sandbox.print_sandbox_message - end + Sandbox.print_sandbox_message end Utils.safe_fork do - if Sandbox.available? && !ARGV.no_sandbox? && !Sandbox.auto_disable? + if Sandbox.available? && !ARGV.no_sandbox? sandbox = Sandbox.new f.logs.mkpath sandbox.record_log(f.logs/"sandbox.test.log") -- cgit v1.2.3