aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/formula.rb
diff options
context:
space:
mode:
authorAndrew Janke2016-08-19 12:27:37 -0400
committerGitHub2016-08-19 12:27:37 -0400
commit5d603c3e8f658d67bce9975de93ee5101d94d8f3 (patch)
treed027f7f4d23eb1b7da2a83c4a0438463bdcc0c0a /Library/Homebrew/formula.rb
parent893c80d3ba4aaacba640a7b3a8234e755721ad3f (diff)
parent954445634cdd6138c589ce9f91a9398d93c8bba8 (diff)
downloadbrew-5d603c3e8f658d67bce9975de93ee5101d94d8f3.tar.bz2
separate build and test logs
Diffstat (limited to 'Library/Homebrew/formula.rb')
-rw-r--r--Library/Homebrew/formula.rb42
1 files changed, 39 insertions, 3 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index 3a50fcb0b..ac6093880 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -130,6 +130,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
@@ -735,12 +740,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
@@ -861,6 +884,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
@@ -1384,7 +1418,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
@@ -1476,7 +1512,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|