diff options
| author | Andrew Janke | 2016-05-27 01:53:08 -0400 |
|---|---|---|
| committer | Andrew Janke | 2016-08-19 01:04:32 -0400 |
| commit | 954445634cdd6138c589ce9f91a9398d93c8bba8 (patch) | |
| tree | efca700f4f7ccb5e2acc466644248f381c3c2c87 | |
| parent | db2e9b8375535f5cb71b5974909bc0fcc3d29e9d (diff) | |
| download | brew-954445634cdd6138c589ce9f91a9398d93c8bba8.tar.bz2 | |
separate build and test logs
| -rw-r--r-- | Library/Homebrew/cmd/postinstall.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/test.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/formula.rb | 42 | ||||
| -rw-r--r-- | Library/Homebrew/formula_installer.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/postinstall.rb | 2 |
5 files changed, 43 insertions, 7 deletions
diff --git a/Library/Homebrew/cmd/postinstall.rb b/Library/Homebrew/cmd/postinstall.rb index 798907339..325916d86 100644 --- a/Library/Homebrew/cmd/postinstall.rb +++ b/Library/Homebrew/cmd/postinstall.rb @@ -27,7 +27,7 @@ module Homebrew if Sandbox.formula?(formula) sandbox = Sandbox.new formula.logs.mkpath - sandbox.record_log(formula.logs/"sandbox.postinstall.log") + sandbox.record_log(formula.logs/"postinstall.sandbox.log") sandbox.allow_write_temp_and_cache sandbox.allow_write_log(formula) sandbox.allow_write_cellar(formula) diff --git a/Library/Homebrew/cmd/test.rb b/Library/Homebrew/cmd/test.rb index 495ea8ec8..a80fa5e4f 100644 --- a/Library/Homebrew/cmd/test.rb +++ b/Library/Homebrew/cmd/test.rb @@ -63,7 +63,7 @@ module Homebrew if Sandbox.test? sandbox = Sandbox.new f.logs.mkpath - sandbox.record_log(f.logs/"sandbox.test.log") + sandbox.record_log(f.logs/"test.sandbox.log") sandbox.allow_write_temp_and_cache sandbox.allow_write_log(f) sandbox.allow_write_xcode diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 3730b135c..42251e085 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -127,6 +127,11 @@ class Formula # @private attr_accessor :local_bottle_path + # When performing a build, test, or other loggable action, indicates which + # log file location to use. + # @private + attr_reader :active_log_type + # The {BuildOptions} for this {Formula}. Lists the arguments passed and any # {#options} in the {Formula}. Note that these may differ at different times # during the installation of a {Formula}. This is annoying but the result of @@ -730,12 +735,30 @@ class Formula prefix+".bottle" end - # The directory where the formula's installation logs will be written. + # The directory where the formula's installation or test logs will be written. # @private def logs HOMEBREW_LOGS+name end + # The prefix, if any, to use in filenames for logging current activity + def active_log_prefix + if active_log_type + "#{active_log_type}." + else + "" + end + end + + # Runs a block with the given log type in effect for its duration + def with_logging(log_type) + old_log_type = @active_log_type + @active_log_type = log_type + yield + ensure + @active_log_type = old_log_type + end + # This method can be overridden to provide a plist. # For more examples read Apple's handy manpage: # https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man5/plist.5.html @@ -856,6 +879,17 @@ class Formula method(:post_install).owner == self.class end + # @private + def run_post_install + build = self.build + self.build = Tab.for_formula(self) + with_logging("post_install") do + post_install + end + ensure + self.build = build + end + # Tell the user about any caveats regarding this package. # @return [String] # <pre>def caveats @@ -1374,7 +1408,9 @@ class Formula ENV["HOME"] = @testpath setup_home @testpath begin - test + with_logging("test") do + test + end rescue Exception staging.retain! if ARGV.debug? raise @@ -1466,7 +1502,7 @@ class Formula @exec_count ||= 0 @exec_count += 1 - logfn = "#{logs}/%02d.%s" % [@exec_count, File.basename(cmd).split(" ").first] + logfn = "#{logs}/#{active_log_prefix}%02d.%s" % [@exec_count, File.basename(cmd).split(" ").first] logs.mkpath File.open(logfn, "w") do |log| diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 03c9f8314..a1fd5ba0e 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -597,7 +597,7 @@ class FormulaInstaller if Sandbox.formula?(formula) sandbox = Sandbox.new formula.logs.mkpath - sandbox.record_log(formula.logs/"sandbox.build.log") + sandbox.record_log(formula.logs/"build.sandbox.log") sandbox.allow_write_temp_and_cache sandbox.allow_write_log(formula) sandbox.allow_write_xcode diff --git a/Library/Homebrew/postinstall.rb b/Library/Homebrew/postinstall.rb index c5c7ace31..0b6d8f6b0 100644 --- a/Library/Homebrew/postinstall.rb +++ b/Library/Homebrew/postinstall.rb @@ -13,7 +13,7 @@ begin formula = ARGV.resolved_formulae.first formula.extend(Debrew::Formula) if ARGV.debug? - formula.post_install + formula.run_post_install rescue Exception => e Marshal.dump(e, error_pipe) error_pipe.close |
