Skip to content

Instantly share code, notes, and snippets.

@NIA
Last active December 25, 2015 09:19
Show Gist options
  • Save NIA/6952934 to your computer and use it in GitHub Desktop.
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
#!/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