class Sbtpretty::Printer
Constants
- CHECK
- ERROR
- SMALL_ARROW
- WARNING
Public Instance Methods
contains_all_tests_passed(line)
click to toggle source
# File lib/sbtpretty.rb, line 92 def contains_all_tests_passed(line) return /All tests passed/.match(line) end
contains_date(line)
click to toggle source
gsed -r “s/[][[0-9]{1,3}m//g”
# File lib/sbtpretty.rb, line 82 def contains_date(line) # [12/18/2017 15:39:10.874] return /[0-9]*[\/,:][0-9]*[\/,:][0-9]*.*/.match(line) end
contains_failed_test(line)
click to toggle source
# File lib/sbtpretty.rb, line 87 def contains_failed_test(line) #*** FAILED *** return /\*\*\* .*FAILED.* \*\*\*/.match(line) end
contains_suites(line)
click to toggle source
# File lib/sbtpretty.rb, line 111 def contains_suites(line) # ▸ Suites: completed 9, aborted 0 #:suites return /.*Suites.* completed .* aborted .*/.match(line) end
contains_summary(line)
click to toggle source
# File lib/sbtpretty.rb, line 96 def contains_summary(line) #Passed: Total 5, Failed 0, Errors 0, Passed 5 return /Passed: Total [0-9]*, Failed [0-9]*, Errors [0-9]*, Passed [0-9]*/.match(line) end
contains_summary_line_type_2(line)
click to toggle source
# File lib/sbtpretty.rb, line 117 def contains_summary_line_type_2(line) #▸ Tests: succeeded 58, failed 1, canceled 0, ignored 0, pending 0 return /.*Tests.* succeeded .* failed .*/.match(line) end
contains_total_number_of_test_run(line)
click to toggle source
# File lib/sbtpretty.rb, line 106 def contains_total_number_of_test_run(line) ## ▸ Total number of tests run: 59 return /.*Total number of tests run.*/.match(line) end
format(line,type)
click to toggle source
# File lib/sbtpretty.rb, line 135 def format(line,type) case type when :info then "#{SMALL_ARROW.yellow} #{strip_info(line)}" when :error then line.gsub('[error]',"#{ERROR} ").red when :testfailed then line.gsub('[info] ',"#{ERROR} ").red when :alltestspass then line.gsub('[info] ',"#{CHECK} ").green when :runcompleted then "#{SMALL_ARROW.yellow} #{strip_info(line).blue}" when :summaryline then "\t#{strip_info(line).yellow}" when :totalNumberOfTestsRun then "#{SMALL_ARROW.yellow} #{strip_info(line).blue}" when :suites then "#{SMALL_ARROW.yellow} #{strip_info(line).blue}" when :summary2 then "#{SMALL_ARROW.yellow} #{strip_info(line).blue}" when :no_tests_were_executed then "#{SMALL_ARROW.yellow} #{strip_info(line)}" end end
get_type(line)
click to toggle source
# File lib/sbtpretty.rb, line 24 def get_type(line) if no_tests_were_executed(line) return :no_tests_were_executed end if contains_summary_line_type_2(line) return :summary2 end if contains_suites(line) return :suites end if contains_total_number_of_test_run(line) return :totalNumberOfTestsRun end if run_completed(line) return :runcompleted end if contains_summary(line) return :summaryline end if contains_date(line) return :none end if contains_failed_test(line) return :testfailed end if contains_all_tests_passed(line) return :alltestspass end if line.start_with?('[INFO]') return :info end if line.start_with?('[info]') return :info end if line.start_with?(' [error]') || line.start_with?('[error]') return :error end if line.start_with?('[ERROR]') return :error end # match_pos = (/\[[0-9]/ =~ line) # if match_pos != nil # puts "is not nil" # return :none # end end
no_tests_were_executed(line)
click to toggle source
# File lib/sbtpretty.rb, line 122 def no_tests_were_executed(line) # No tests were executed. return /.*No tests were executed.*/.match(line) end
print(line)
click to toggle source
# File lib/sbtpretty.rb, line 149 def print(line) line = line.chomp line = "echo '#{line}' | sed \"s,$(printf '\\033')\\\\[[0-9;]*[a-zA-Z],,g\" 2> /dev/null" stdin, stdout, stderr, wait_thr = Open3.popen3(line) val = stdout.gets stdout.close stderr.gets(nil) stderr.close if val == nil val = "" end STDOUT.print(format(val,get_type(val))) STDOUT.flush end
run_completed(line)
click to toggle source
# File lib/sbtpretty.rb, line 101 def run_completed(line) ## ▸ Run completed in 3 seconds, 774 milliseconds return /.*Run completed in .*/.match(line) end
strip_info(line)
click to toggle source
# File lib/sbtpretty.rb, line 131 def strip_info(line) return line.gsub(/\[info\] (- )?/,"") end