lib/cerberus/builder/maven2.rb in cerberus-0.2.2 vs lib/cerberus/builder/maven2.rb in cerberus-0.2.3

- old
+ new

@@ -7,25 +7,29 @@ def run Dir.chdir @config[:application_root] cmd = @config[:builder, :maven2, :cmd] || 'mvn' task = @config[:builder, :maven2, :task] || 'test' - output = `#{@config[:bin_path]}#{cmd} #{task} 2>&1` - @output = add_error_information(output) + @output = `#{@config[:bin_path]}#{cmd} #{task} 2>&1` + add_error_information successful? end def successful? $?.exitstatus == 0 and not @output.include?('[ERROR] BUILD FAILURE') end - def add_error_information(str) - output = '' - while str =~ /^(.|\n)*Running (.*)\n(.|\n)* <<< FAILURE!$/ + def add_error_information + str = @output + @output = '' + while str =~ / <<< FAILURE!$/ + s = $' + + $` =~ /^(.|\n)*Running (.*)$/ failed_class = $2 - output << $` << $& - output << "\n" << IO.readlines("#{@config[:application_root]}/target/surefire-reports/#{failed_class}.txt")[4..-1].join - str = $' + @output << $` << $& << ' <<< FAILURE!' + @output << "\n" << IO.readlines("#{@config[:application_root]}/target/surefire-reports/#{failed_class}.txt")[4..-1].join.lstrip #map{|str| ' ' + str}..gsub(' <<< FAILURE!','') + str = s end - output << str + @output << str end end \ No newline at end of file