@@ -35,18 +35,33 @@ def self.start(modes = Truffle::UNDEFINED)
35
35
nil
36
36
end
37
37
38
- def self . result ( stop : true , clear : true )
38
+ def self . result ( **options )
39
+ if options . empty?
40
+ stop = true
41
+ clear = true
42
+ else
43
+ stop = options [ :stop ]
44
+ clear = options [ :clear ]
45
+ end
46
+
47
+ if stop && !clear
48
+ warn 'stop implies clear' , uplevel : 1
49
+ end
50
+
39
51
result = peek_result
52
+
53
+ # TODO: There should be a difference between :stop and :clear in a way they affect counters.
54
+ # :stop means to remove all the counters at all, :clear - to set 0 values only.
55
+ # Now we remove counters in both cases.
40
56
Truffle ::Coverage . disable if stop || clear
41
57
Truffle ::Coverage . enable if !stop && clear
42
58
43
- # if there is only the default mode (:lines only) - return result as array per file,
44
- # otherwise return result for each mode separately (e.g. for :branches, :methods, :lines)
59
+ # By default provides only lines coverage measurement.
60
+ # If some mode was specified explicitly then return counters per mode separately (e.g. for :lines, :branches, etc).
61
+ # Support only :lines for now.
45
62
if !@default_mode
46
- result . transform_values! do |_ , *lines_array |
47
- # need to add nil to the beginning of each lines array, because the
48
- # first line has index 1 and not 0
49
- { lines : lines_array . unshift ( nil ) }
63
+ result . transform_values! do |lines |
64
+ { lines : lines }
50
65
end
51
66
end
52
67
0 commit comments