diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-08-24 09:54:45 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-08-24 09:54:45 +0000 |
commit | 3e09ac0c10c95bb24a08af62393b4f761e2743d0 (patch) | |
tree | 778dffa2ba8798503fc047db0feef6d65426ea22 /test/covshow.rb | |
download | dtas-3e09ac0c10c95bb24a08af62393b4f761e2743d0.tar.gz |
Diffstat (limited to 'test/covshow.rb')
-rw-r--r-- | test/covshow.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/covshow.rb b/test/covshow.rb new file mode 100644 index 0000000..e50c368 --- /dev/null +++ b/test/covshow.rb @@ -0,0 +1,30 @@ +# -*- encoding: binary -*- +# Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> +# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) +# +# this works with the __covmerge method in test/helper.rb +# run this file after all tests are run + +# load the merged dump data +res = Marshal.load(IO.binread("coverage.dump")) + +# Dirty little text formatter. I tried simplecov but the default +# HTML+JS is unusable without a GUI (I hate GUIs :P) and it would've +# taken me longer to search the Internets to find a plain-text +# formatter I like... +res.keys.sort.each do |filename| + cov = res[filename] + puts "==> #{filename} <==" + File.readlines(filename).each_with_index do |line, i| + n = cov[i] + if n == 0 # BAD + print(" *** 0 #{line}") + elsif n + printf("% 7u %s", n, line) + elsif line =~ /\S/ # probably a line with just "end" in it + print(" #{line}") + else # blank line + print "\n" # don't output trailing whitespace on blank lines + end + end +end |