Skip to content

Instantly share code, notes, and snippets.

@NIA
Last active Dec 25, 2015
Embed
What would you like to do?
Simple colorizer of tests output: given test program printing true or false for test passing, it paints "true" green and "false" red
#!/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