File: results_to_excludes.rb

package info (click to toggle)
jruby 9.4.8.0%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 89,244 kB
  • sloc: ruby: 548,574; java: 276,189; yacc: 25,873; ansic: 6,178; xml: 6,111; sh: 1,855; sed: 94; makefile: 78; jsp: 48; tcl: 40; exp: 12
file content (42 lines) | stat: -rw-r--r-- 1,088 bytes parent folder | download | duplicates (2)
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
31
32
33
34
35
36
37
38
39
40
41
42
# results_to_excludes: convert test/unit output to exclude files based on failure lines
#
# usage: results_to_excludes result_output.txt target_dir "exclude reason"

require 'fileutils'

results_filename = ARGV[0]
target_dir = ARGV[1] || "excludes"
comment = ARGV[2] || "work in progress"

cls_to_method = Hash.new {|h, k| h[k] = []}
cls_to_file = Hash.new {|h, k| h[k] = []}

File.readlines(results_filename).grep(/^\[\w*\d+\/\d+\] (.*) =/) {|l|
  failure = $1
  cls, method = failure.split('#')
  cls_pieces = cls.split('::')
  file = cls_pieces[-1] + '.rb'
  if cls_pieces.size > 1
    dir = cls_pieces[0...-1].join('/')
    cls_to_file[cls] = [dir, file]
  else
    cls_to_file[cls] = [file]
  end

  cls_to_method[cls] << method
}

cls_to_file.each do |cls, path|
  puts path.join("/")
  target = target_dir
  if path.size == 2
    target = File.join(target_dir, path[0])
  end
  FileUtils.mkdir_p(target)

  File.open(File.join(target, path[-1]), 'a') do |file|
    cls_to_method[cls].sort.each do |method|
      file.puts "exclude :\"#{method}\", \"#{comment}\""
    end
  end
end