Created
September 24, 2010 13:03
-
-
Save nsf/595319 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| # encoding: utf-8 | |
| RED = "\033[0;31m" | |
| GRN = "\033[0;32m" | |
| NC = "\033[0m" | |
| PASS = "#{GRN}PASS!#{NC}" | |
| FAIL = "#{RED}FAIL!#{NC}" | |
| LINE = "████████████████████████████████████████████████████████████████████" | |
| Stats = Struct.new :total, :ok, :fail | |
| $stats = Stats.new 0, 0, 0 | |
| def print_fail_report(t, out, outexpected) | |
| puts "#{t}: #{FAIL}" | |
| puts "--------------------------------------------------------" | |
| puts "Got:\n#{out}" | |
| puts "--------------------------------------------------------" | |
| puts "Expected:\n#{outexpected}" | |
| puts "--------------------------------------------------------" | |
| end | |
| def print_pass_report(t) | |
| puts "#{t}: #{PASS}" | |
| end | |
| def print_stats | |
| puts "\nSummary (total: #{$stats.total})" | |
| puts "#{GRN} PASS#{NC}: #{$stats.ok}" | |
| puts "#{RED} FAIL#{NC}: #{$stats.fail}" | |
| puts "#{$stats.fail == 0 ? GRN : RED}#{LINE}#{NC}" | |
| end | |
| def run_test(t) | |
| $stats.total += 1 | |
| cursorpos = Dir["#{t}/cursor.*"].map{|d| File.extname(d)[1..-1]}.first | |
| outexpected = IO.read("#{t}/out.expected") rescue "To be determined" | |
| filename = "#{t}/test.go" | |
| out = %x[gocode -in #{filename} autocomplete #{filename} #{cursorpos}] | |
| if out != outexpected then | |
| print_fail_report(t, out, outexpected) | |
| $stats.fail += 1 | |
| else | |
| print_pass_report(t) | |
| $stats.ok += 1 | |
| end | |
| end | |
| Dir["test.*"].sort.each do |t| | |
| run_test t | |
| end | |
| print_stats |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment