yahns.git  about / heads / tags
sleepy, multi-threaded, non-blocking application server for Ruby
blob 1ad4e7dcc34684a9df4dbb1edd748b0cb54d1b4c 1010 bytes (raw)
$ git show HEAD:test/covshow.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
# Copyright (C) 2013-2016 all contributors <yahns-public@yhbt.net>
# License: GPL-3.0+ (https://www.gnu.org/licenses/gpl-3.0.txt)
# frozen_string_literal: true
#
# 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

git clone git://yhbt.net/yahns.git
git clone https://yhbt.net/yahns.git