diff --git a/lib/xcode_build/build_action.rb b/lib/xcode_build/build_action.rb index c9f9d5d..326bb3d 100644 --- a/lib/xcode_build/build_action.rb +++ b/lib/xcode_build/build_action.rb @@ -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 @@ -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? @@ -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 diff --git a/lib/xcode_build/formatters/progress_formatter.rb b/lib/xcode_build/formatters/progress_formatter.rb index c19ae8e..cc3afb6 100644 --- a/lib/xcode_build/formatters/progress_formatter.rb +++ b/lib/xcode_build/formatters/progress_formatter.rb @@ -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 diff --git a/lib/xcode_build/reporting/build_reporting.rb b/lib/xcode_build/reporting/build_reporting.rb index f15a8e7..a6f35a2 100644 --- a/lib/xcode_build/reporting/build_reporting.rb +++ b/lib/xcode_build/reporting/build_reporting.rb @@ -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 @@ -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