Last active
December 25, 2015 09:19
-
-
Save NIA/6952934 to your computer and use it in GitHub Desktop.
Simple colorizer of tests output: given test program printing true or false for test passing, it paints "true" green and "false" red
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Usage example: echo 'use "hw1test.sml";' | sml | truecolor.rb | |
require 'colorize' | |
# HA HA HA I USE GLOBAL VARIABLES | |
$failed = 0 | |
$passed = 0 | |
while line = gets | |
puts( | |
line.gsub('true') do |s| | |
$passed+=1 | |
s.green | |
end.gsub(/false|<hidden-value>/) do |s| | |
$failed+=1 | |
s.red | |
end | |
) | |
end | |
puts "#$passed passed".green + if $failed > 0 then ", "+"#$failed failed".red else "" end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment