Navigation Menu

Skip to content

Commit

Permalink
Display error and warning totals.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeredpath committed Feb 10, 2012
1 parent 723a81a commit 913bf70
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
23 changes: 22 additions & 1 deletion lib/xcode_build/build_action.rb
Expand Up @@ -4,13 +4,14 @@

module XcodeBuild
class BuildAction
attr_reader :steps_completed
attr_reader :steps_completed, :warnings
attr_writer :finished_at

def initialize(metadata)
@steps_completed = []
@metadata = metadata
@started_at = Time.now
@warnings = []
super()
end

Expand Down Expand Up @@ -51,6 +52,14 @@ def finished?
def has_errors?
failed_steps.any?
end

def has_warnings?
warnings.any?
end

def error_count
has_errors? ? (failed_steps.map { |s| s.errors.length }) : 0
end

def duration
return nil unless finished?
Expand All @@ -76,5 +85,17 @@ def configuration
def default_configuration?
@metadata[:default]
end

def add_warning(params)
@warnings << Warning.new(params)
end

private

class Warning < OpenStruct
def warning_detail
"in #{self.file}:#{self.line.to_s}"
end
end
end
end
8 changes: 6 additions & 2 deletions lib/xcode_build/formatters/progress_formatter.rb
Expand Up @@ -53,9 +53,13 @@ def report_finished(object)
puts "Finished in #{object.duration} seconds."

if object.successful?
puts green("#{object.label} succeeded.")
if object.has_warnings?
puts green("#{object.label} succeeded.") + yellow(" (#{object.warnings.length} warnings)")
else
puts green("#{object.label} succeeded.")
end
else
puts red("#{object.label} failed.")
puts red("#{object.label} failed. (#{object.error_count} errors)")
puts
puts "Failed #{object.label.downcase} steps:"
puts
Expand Down
15 changes: 1 addition & 14 deletions lib/xcode_build/reporting/build_reporting.rb
Expand Up @@ -73,13 +73,12 @@ def build_finished
end

class Build < BuildAction
attr_reader :environment, :warnings
attr_reader :environment
attr_writer :label

def initialize(metadata)
super(metadata)
@environment = {}
@warnings = []
@label = "Build"
end

Expand All @@ -90,18 +89,6 @@ def set_environment_variable(key, value)
def target_build_directory
@environment["TARGET_BUILD_DIR"]
end

def add_warning(params)
@warnings << Warning.new(params)
end

private

class Warning < OpenStruct
def warning_detail
"in #{self.file}:#{self.line.to_s}"
end
end
end
end
end
Expand Down

0 comments on commit 913bf70

Please sign in to comment.