path_coverage 0.7.2 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +45 -19
- data/lib/path_coverage/call_trace.rb +1 -1
- data/lib/path_coverage/calls.rb +35 -8
- data/lib/path_coverage/condition.rb +24 -6
- data/lib/path_coverage/current_test.rb +28 -0
- data/lib/path_coverage/decision_tree.rb +11 -21
- data/lib/path_coverage/evaluated.rb +23 -0
- data/lib/path_coverage/fold_rows.rb +7 -8
- data/lib/path_coverage/gaps.rb +4 -4
- data/lib/path_coverage/json_reader.rb +22 -17
- data/lib/path_coverage/json_reports.rb +5 -3
- data/lib/path_coverage/json_writer.rb +12 -8
- data/lib/path_coverage/kernel.rb +11 -3
- data/lib/path_coverage/kinds/base.rb +9 -0
- data/lib/path_coverage/kinds/block.rb +7 -1
- data/lib/path_coverage/kinds/case.rb +63 -20
- data/lib/path_coverage/kinds/chain.rb +13 -3
- data/lib/path_coverage/kinds/choice.rb +5 -0
- data/lib/path_coverage/kinds/contains.rb +6 -0
- data/lib/path_coverage/kinds/safe.rb +3 -3
- data/lib/path_coverage/kinds/write.rb +3 -3
- data/lib/path_coverage/kinds.rb +14 -0
- data/lib/path_coverage/loop_nodes.rb +5 -3
- data/lib/path_coverage/manifest.rb +57 -33
- data/lib/path_coverage/manifest_case.rb +43 -26
- data/lib/path_coverage/manifest_folding.rb +20 -0
- data/lib/path_coverage/merge.rb +8 -8
- data/lib/path_coverage/method_statements.rb +5 -4
- data/lib/path_coverage/minitest.rb +7 -0
- data/lib/path_coverage/minitest_tests.rb +25 -0
- data/lib/path_coverage/paths_context.rb +2 -2
- data/lib/path_coverage/paths_forks.rb +6 -3
- data/lib/path_coverage/paths_leaving.rb +3 -1
- data/lib/path_coverage/paths_regions.rb +78 -0
- data/lib/path_coverage/paths_rescues.rb +5 -2
- data/lib/path_coverage/paths_scopes.rb +2 -1
- data/lib/path_coverage/paths_tree.rb +10 -68
- data/lib/path_coverage/paths_way_lists.rb +11 -10
- data/lib/path_coverage/recorder.rb +28 -47
- data/lib/path_coverage/recorder_blocks.rb +3 -3
- data/lib/path_coverage/recorder_cases.rb +70 -17
- data/lib/path_coverage/recorder_chains.rb +2 -2
- data/lib/path_coverage/render.rb +7 -3
- data/lib/path_coverage/report_tallies.rb +79 -0
- data/lib/path_coverage/report_text.rb +23 -0
- data/lib/path_coverage/rescue_forks.rb +3 -0
- data/lib/path_coverage/result.rb +17 -16
- data/lib/path_coverage/rewriter.rb +42 -114
- data/lib/path_coverage/rewriter_marks.rb +108 -0
- data/lib/path_coverage/source_report.rb +5 -6
- data/lib/path_coverage/stable_leaves.rb +6 -26
- data/lib/path_coverage/statement_arms.rb +18 -5
- data/lib/path_coverage/tally.rb +129 -0
- data/lib/path_coverage/testing.rb +13 -0
- data/lib/path_coverage/totals.rb +3 -3
- data/lib/path_coverage/version.rb +1 -1
- data/lib/path_coverage/walk.rb +4 -3
- data/lib/path_coverage/ways_report.rb +11 -10
- data/lib/path_coverage/within_methods.rb +12 -3
- metadata +11 -1
|
@@ -14,7 +14,7 @@ module PathCoverage
|
|
|
14
14
|
SCHEMA = 1
|
|
15
15
|
|
|
16
16
|
# The URL of the schema the source report follows.
|
|
17
|
-
SCHEMA_URL = 'https://path-coverage.github.io/schemas/
|
|
17
|
+
SCHEMA_URL = 'https://path-coverage.github.io/schemas/v3/' \
|
|
18
18
|
'path_coverage.source.schema.json'.freeze
|
|
19
19
|
|
|
20
20
|
# The source report of a run, headed by its schema's URL and
|
|
@@ -78,7 +78,7 @@ module PathCoverage
|
|
|
78
78
|
# The decision named name, of decisions, { name => Condition }, in
|
|
79
79
|
# source: the [first, last] lines it spans, and its fold's
|
|
80
80
|
# rows, headed by top, its row's top, a column for each of
|
|
81
|
-
# paths, [{path:,
|
|
81
|
+
# paths, [{path:, tests:}], in their order.
|
|
82
82
|
def self.decision(source, decisions, name, paths, top)
|
|
83
83
|
condition = decisions.fetch(name)
|
|
84
84
|
last = SourceLines.end_line(source, condition.leaves.last)
|
|
@@ -86,15 +86,14 @@ module PathCoverage
|
|
|
86
86
|
{ span:, fold: fold(source, condition, paths, top) }
|
|
87
87
|
end
|
|
88
88
|
|
|
89
|
-
# The rows of condition's fold, headed by top,
|
|
90
|
-
#
|
|
89
|
+
# The rows of condition's fold, headed by top, a column for each
|
|
90
|
+
# of paths.
|
|
91
91
|
def self.fold(source, condition, paths, top)
|
|
92
92
|
outcomes = paths.map { _1[:path] }
|
|
93
93
|
tree = DecisionTree.built(source, condition, outcomes)
|
|
94
94
|
located = DecisionLocations.located(source, condition, tree)
|
|
95
95
|
else_at = DecisionLocations.else_at(source, condition)
|
|
96
|
-
|
|
97
|
-
[own.except(:counts), *rest]
|
|
96
|
+
FoldRows.rows(located.merge(else_at:, label: top))
|
|
98
97
|
end
|
|
99
98
|
end
|
|
100
99
|
end
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
require 'prism'
|
|
2
2
|
require_relative 'condition'
|
|
3
|
+
require_relative 'evaluated'
|
|
4
|
+
require_relative 'kinds'
|
|
3
5
|
|
|
4
6
|
module PathCoverage
|
|
5
7
|
# The leaves of a flow whose outcomes cannot differ within one
|
|
@@ -8,12 +10,6 @@ module PathCoverage
|
|
|
8
10
|
# variable's truthiness. Every such read in a call has the same
|
|
9
11
|
# outcome, so a way needing two outcomes of it is no way.
|
|
10
12
|
module StableLeaves
|
|
11
|
-
# The operators whose leaf operands' outcomes are their
|
|
12
|
-
# truthiness. A when's leaf is whether its pattern matched, a
|
|
13
|
-
# &. receiver's whether it was nil, false included in not nil,
|
|
14
|
-
# and a block method's leaves count items or answers.
|
|
15
|
-
TRUTHY = (%w[&& and || or] + CHOICES).freeze
|
|
16
|
-
|
|
17
13
|
# The calls through which code can reach a method's locals
|
|
18
14
|
# and rewrite them out of its sight: a binding, a string eval,
|
|
19
15
|
# or any call by name, which could be either.
|
|
@@ -32,7 +28,7 @@ module PathCoverage
|
|
|
32
28
|
# calls any of REWRITERS.
|
|
33
29
|
def self.of(source, decisions, rows)
|
|
34
30
|
conditions = decisions.values_at(*rows.map(&:decision).compact)
|
|
35
|
-
ranges = conditions.flat_map { truthy_leaves(_1) }
|
|
31
|
+
ranges = conditions.flat_map { Kinds.truthy_leaves(_1) }
|
|
36
32
|
return {} if ranges.empty?
|
|
37
33
|
|
|
38
34
|
method = def_of(source, ranges.first)
|
|
@@ -41,24 +37,6 @@ module PathCoverage
|
|
|
41
37
|
shared(read_in(method).slice(*ranges))
|
|
42
38
|
end
|
|
43
39
|
|
|
44
|
-
# The leaves of condition, a leaf a byte range, whose outcome
|
|
45
|
-
# is their truthiness, its nested conditions' included.
|
|
46
|
-
def self.truthy_leaves(condition)
|
|
47
|
-
operands = condition.operands
|
|
48
|
-
own = TRUTHY.include?(condition.operator) ? operands : []
|
|
49
|
-
own.grep(Range) + operands.flat_map { inner_leaves(_1) }
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
# The truthy leaves of operand, a leaf, a Condition or an Arm:
|
|
53
|
-
# none for a leaf, which its condition counts, or a plain arm.
|
|
54
|
-
def self.inner_leaves(operand)
|
|
55
|
-
case operand
|
|
56
|
-
when Condition then truthy_leaves(operand)
|
|
57
|
-
when Arm then operand.body ? truthy_leaves(operand.body) : []
|
|
58
|
-
else []
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
40
|
# The innermost def in source holding the bytes range, nil
|
|
63
41
|
# when none does.
|
|
64
42
|
def self.def_of(source, range)
|
|
@@ -73,7 +51,7 @@ module PathCoverage
|
|
|
73
51
|
# Every def node in node, node itself included.
|
|
74
52
|
def self.defs_in(node)
|
|
75
53
|
own = node.type == :def_node ? [node] : []
|
|
76
|
-
own + node.
|
|
54
|
+
own + Evaluated.children(node).flat_map { defs_in(_1) }
|
|
77
55
|
end
|
|
78
56
|
|
|
79
57
|
# { read byte range => local name } of each read in the def
|
|
@@ -104,6 +82,8 @@ module PathCoverage
|
|
|
104
82
|
# another variable; each local written anywhere; and whether
|
|
105
83
|
# any of REWRITERS is called.
|
|
106
84
|
class Reads < Prism::Visitor
|
|
85
|
+
include Evaluated::Visitor
|
|
86
|
+
|
|
107
87
|
# Starts outside any block, having noted nothing.
|
|
108
88
|
def initialize
|
|
109
89
|
@reads = {}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require_relative 'evaluated'
|
|
2
|
+
|
|
1
3
|
module PathCoverage
|
|
2
4
|
# The lists of statements a method's flow has rows for: a def's
|
|
3
5
|
# body, the arms of each decision in it whose arms are statements,
|
|
@@ -96,14 +98,25 @@ module PathCoverage
|
|
|
96
98
|
end
|
|
97
99
|
end
|
|
98
100
|
|
|
99
|
-
# node's children outside its arms of statements: all
|
|
100
|
-
#
|
|
101
|
-
# case
|
|
101
|
+
# node's children outside its arms of statements: all those
|
|
102
|
+
# that can run for a node with none, so none of a defined?'s,
|
|
103
|
+
# else its predicate; for a case, its subject, when it has one,
|
|
104
|
+
# and its patterns.
|
|
102
105
|
def heads(node)
|
|
103
|
-
return node
|
|
106
|
+
return Evaluated.children(node) if arms_of(node).empty?
|
|
104
107
|
return [node.predicate] unless node.type == :case_node
|
|
105
108
|
|
|
106
|
-
|
|
109
|
+
node.compact_child_nodes.flat_map { case_heads(_1) }
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# The heads among child, a child of a case: a when's patterns,
|
|
113
|
+
# none of its else, or else child itself, its subject.
|
|
114
|
+
def case_heads(child)
|
|
115
|
+
case child.type
|
|
116
|
+
when :when_node then child.conditions
|
|
117
|
+
when :else_node then []
|
|
118
|
+
else [child]
|
|
119
|
+
end
|
|
107
120
|
end
|
|
108
121
|
|
|
109
122
|
# The statements of node's arms, then's before else's; none
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
require 'digest'
|
|
2
|
+
|
|
3
|
+
module PathCoverage
|
|
4
|
+
# How often something happened, by test: every count of what a
|
|
5
|
+
# run did is a Tally, { test id => n }, so a report can tell which
|
|
6
|
+
# tests take which paths. Its total is the sum over its tests,
|
|
7
|
+
# never stored beside it. A Tally is no Integer, so a count left
|
|
8
|
+
# unconverted anywhere fails loudly rather than miscounting. The
|
|
9
|
+
# JSON report lists a tally by its tests' keys, each the first 12
|
|
10
|
+
# hex digits of the sha256 of the test's id, and names each key's
|
|
11
|
+
# test once, in its tests.
|
|
12
|
+
class Tally
|
|
13
|
+
# The id of what runs outside every test, eg a file's load.
|
|
14
|
+
NO_TEST = '(no test)'.freeze
|
|
15
|
+
|
|
16
|
+
# How many hex digits of a test id's sha256 its key keeps.
|
|
17
|
+
KEY_DIGITS = 12
|
|
18
|
+
|
|
19
|
+
# The tally of by_test, { test id => n }; ArgumentError naming
|
|
20
|
+
# a test whose n is below 1.
|
|
21
|
+
def initialize(by_test = {})
|
|
22
|
+
@by_test = by_test.dup
|
|
23
|
+
@by_test.each do |test, count|
|
|
24
|
+
raise ArgumentError, "#{test} counted #{count}" if count < 1
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# { test id => n } of the tests that made it happen.
|
|
29
|
+
attr_reader :by_test
|
|
30
|
+
|
|
31
|
+
# Counts one more happening, made by test.
|
|
32
|
+
def add(test)
|
|
33
|
+
@by_test[test] = @by_test.fetch(test, 0) + 1
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# How often it happened, over every test.
|
|
37
|
+
def total
|
|
38
|
+
@by_test.values.sum
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# True when no test made it happen.
|
|
42
|
+
def empty?
|
|
43
|
+
@by_test.empty?
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# The tally of self's happenings and other's, test by test.
|
|
47
|
+
def +(other)
|
|
48
|
+
Tally.new(@by_test.merge(other.by_test) { |_, a, b| a + b })
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# True when other, a Tally, counts the same tests, each the same
|
|
52
|
+
# number of times. A bare count is no Tally, so comparing one
|
|
53
|
+
# fails loudly rather than coming out quietly unequal.
|
|
54
|
+
def ==(other)
|
|
55
|
+
@by_test == other.by_test
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Tally({ test id => n }), as it is built.
|
|
59
|
+
def inspect
|
|
60
|
+
"Tally(#{@by_test.inspect})"
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# { key => Tally } that starts each key's Tally empty the first
|
|
64
|
+
# time the key is read, as a run counts on every event.
|
|
65
|
+
def self.per_key
|
|
66
|
+
Hash.new { |tallies, key| tallies[key] = Tally.new }
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# The key the JSON report lists test's counts under.
|
|
70
|
+
def self.key(test)
|
|
71
|
+
Digest::SHA256.hexdigest(test)[0, KEY_DIGITS]
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# { key => test id } of tests, as the JSON report's tests lists
|
|
75
|
+
# them; ArgumentError when two share a key, as joined refuses.
|
|
76
|
+
def self.named(tests)
|
|
77
|
+
joined(tests.map { { key(_1) => _1 } })
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# { key => test id } of maps, each a report's tests, joined;
|
|
81
|
+
# ArgumentError naming a key and both ids when maps give it
|
|
82
|
+
# two, as their counts would be added as one test's.
|
|
83
|
+
def self.joined(maps)
|
|
84
|
+
maps.each_with_object({}) do |each, found|
|
|
85
|
+
each.each do |at, test|
|
|
86
|
+
known = found.fetch(at) { found[at] = test }
|
|
87
|
+
next if known == test
|
|
88
|
+
|
|
89
|
+
raise ArgumentError,
|
|
90
|
+
"key #{at} names both #{known} and #{test}"
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# report, of Hashes, Arrays and values, with every Tally in it
|
|
96
|
+
# listed, and 'tests' naming the key of each test those tallies
|
|
97
|
+
# count, in id order: the one place a report's tests come from,
|
|
98
|
+
# so its tests and its tallies always agree.
|
|
99
|
+
def self.jsonable(report)
|
|
100
|
+
ids = []
|
|
101
|
+
body = listed_in(report, ids)
|
|
102
|
+
body.merge('tests' => named(ids.uniq.sort))
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# value with every Tally in it listed, each Tally's tests added
|
|
106
|
+
# to ids.
|
|
107
|
+
def self.listed_in(value, ids)
|
|
108
|
+
case value
|
|
109
|
+
when Tally
|
|
110
|
+
ids.concat(value.by_test.keys)
|
|
111
|
+
listed(value)
|
|
112
|
+
when Hash then value.transform_values { listed_in(_1, ids) }
|
|
113
|
+
when Array then value.map { listed_in(_1, ids) }
|
|
114
|
+
else value
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# { key => n } of counted, a Tally, as the JSON report lists it.
|
|
119
|
+
def self.listed(counted)
|
|
120
|
+
counted.by_test.transform_keys { key(_1) }
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# The Tally of listed, { key => n } as listed gives it, tests
|
|
124
|
+
# being the report's { key => test id }.
|
|
125
|
+
def self.read(listed, tests)
|
|
126
|
+
Tally.new(listed.transform_keys { tests.fetch(_1) })
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require_relative 'current_test'
|
|
2
|
+
|
|
3
|
+
# The part of path coverage's API that names the test under way,
|
|
4
|
+
# so the JSON report tells which tests take which paths.
|
|
5
|
+
module PathCoverage
|
|
6
|
+
# Counts everything measured from now on, in this thread and any
|
|
7
|
+
# thread it starts, under test, a test's id, or Tally::NO_TEST as
|
|
8
|
+
# a test ends: for a test framework with no hook here, eg in an
|
|
9
|
+
# RSpec around hook; Minitest's is path_coverage/minitest.
|
|
10
|
+
def self.testing(test)
|
|
11
|
+
CurrentTest.testing(test)
|
|
12
|
+
end
|
|
13
|
+
end
|
data/lib/path_coverage/totals.rb
CHANGED
|
@@ -5,11 +5,11 @@ module PathCoverage
|
|
|
5
5
|
module Totals
|
|
6
6
|
# Paths alone, each decision's counted on its own:
|
|
7
7
|
# decision_paths, as Result#paths gives them, lists every
|
|
8
|
-
# possible path of each decision with its
|
|
9
|
-
#
|
|
8
|
+
# possible path of each decision with its Tally; one some test
|
|
9
|
+
# took was taken.
|
|
10
10
|
def self.alone(decision_paths)
|
|
11
11
|
every = decision_paths.values.flatten
|
|
12
|
-
[every.count { |each| each[:
|
|
12
|
+
[every.count { |each| !each[:tests].empty? }, every.size]
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
# Example: flows [4, 6] and [17, 21] give [21, 27].
|
data/lib/path_coverage/walk.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require_relative 'condition'
|
|
2
|
+
require_relative 'current_test'
|
|
2
3
|
|
|
3
4
|
module PathCoverage
|
|
4
5
|
# The way one call is taking through its method, kept as a stack
|
|
@@ -95,11 +96,11 @@ module PathCoverage
|
|
|
95
96
|
@units.last.steps << [ended.name, [items], ended.seen]
|
|
96
97
|
end
|
|
97
98
|
|
|
98
|
-
# Counts unit's steps as one more taking of its way,
|
|
99
|
-
# among the ways seen.
|
|
99
|
+
# Counts unit's steps as one more taking of its way, under the
|
|
100
|
+
# test under way, noting it among the ways seen.
|
|
100
101
|
def count(unit)
|
|
101
102
|
way = unit.steps.dup.freeze
|
|
102
|
-
(@ways[unit.name] ||=
|
|
103
|
+
(@ways[unit.name] ||= Tally.per_key)[way].add(CurrentTest.id)
|
|
103
104
|
unit.seen << way
|
|
104
105
|
end
|
|
105
106
|
end
|
|
@@ -5,14 +5,14 @@ module PathCoverage
|
|
|
5
5
|
# report lists them: each way the steps one call, or one pass,
|
|
6
6
|
# took, in order, a decision's {"at", "path"}, a loop's {"at",
|
|
7
7
|
# "path", "passes"}, its path how many passes it made, or any
|
|
8
|
-
# other row's {"at"}, with
|
|
8
|
+
# other row's {"at"}, with the Tally of the tests that took it.
|
|
9
9
|
module WaysReport
|
|
10
|
-
# [{ "way" => [step, ...], "
|
|
11
|
-
#
|
|
12
|
-
# first taken.
|
|
10
|
+
# [{ "way" => [step, ...], "tests" => Tally }] of walked, { way
|
|
11
|
+
# => Tally }, one unit's ways as a CallTrace counts them, in the
|
|
12
|
+
# order first taken.
|
|
13
13
|
def self.taken(walked)
|
|
14
|
-
walked.map do |each,
|
|
15
|
-
{ 'way' => way(each), '
|
|
14
|
+
walked.map do |each, tests|
|
|
15
|
+
{ 'way' => way(each), 'tests' => tests }
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
|
|
@@ -35,8 +35,9 @@ module PathCoverage
|
|
|
35
35
|
listed.merge('passes' => passes)
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
# { method's entry, or loop's name => { way =>
|
|
39
|
-
# JSON report's flows,
|
|
38
|
+
# { method's entry, or loop's name => { way => Tally } } of a
|
|
39
|
+
# JSON report's flows, its tallies read as JsonReader.load reads
|
|
40
|
+
# them, as a CallTrace counts them: each flow
|
|
40
41
|
# listing its calls' ways and its loops' passes; a top flow
|
|
41
42
|
# lists neither, as no call runs it.
|
|
42
43
|
def self.ways(report)
|
|
@@ -51,11 +52,11 @@ module PathCoverage
|
|
|
51
52
|
end
|
|
52
53
|
end
|
|
53
54
|
|
|
54
|
-
# { way =>
|
|
55
|
+
# { way => Tally } of listed, the unit named unit's ways as
|
|
55
56
|
# taken lists them.
|
|
56
57
|
def self.read(unit, listed)
|
|
57
58
|
listed.to_h do |each|
|
|
58
|
-
[each['way'].map { unlisted(unit, _1) }, each['
|
|
59
|
+
[each['way'].map { unlisted(unit, _1) }, each['tests']]
|
|
59
60
|
end
|
|
60
61
|
end
|
|
61
62
|
|
|
@@ -7,6 +7,7 @@ require_relative 'method_loops'
|
|
|
7
7
|
require_relative 'method_statements'
|
|
8
8
|
require_relative 'method_ways'
|
|
9
9
|
require_relative 'source_lines'
|
|
10
|
+
require_relative 'tally'
|
|
10
11
|
|
|
11
12
|
module PathCoverage
|
|
12
13
|
# What is measured within each method of a covered file.
|
|
@@ -120,12 +121,19 @@ module PathCoverage
|
|
|
120
121
|
context = [source, decisions, [paths, reached], lister]
|
|
121
122
|
MethodStatements.of(source, path, decisions).to_h do |key, rows|
|
|
122
123
|
count = lister.count(key, rows)
|
|
123
|
-
named = [*titles[key], count, reached
|
|
124
|
+
named = [*titles[key], count, calls_of(reached, key)]
|
|
124
125
|
shown = method_flow(key, rows, named, context)
|
|
125
126
|
[key, shown.merge(lister.lists(key, rows, count))]
|
|
126
127
|
end
|
|
127
128
|
end
|
|
128
129
|
|
|
130
|
+
# The Tally of the calls of the def at key, its entry's reaches
|
|
131
|
+
# in reached, empty for one never called; nil when reached is
|
|
132
|
+
# nil, not known.
|
|
133
|
+
def self.calls_of(reached, key)
|
|
134
|
+
reached&.fetch(key) { Tally.new }
|
|
135
|
+
end
|
|
136
|
+
|
|
129
137
|
# The flow of the def at key, its rows, named as flow takes
|
|
130
138
|
# named; context is [source, decisions, recorded, lister], as
|
|
131
139
|
# listed_in has them, recorded as PathsContext takes it, and
|
|
@@ -211,8 +219,9 @@ module PathCoverage
|
|
|
211
219
|
|
|
212
220
|
# The flow of the def at decision, named name, ending on line
|
|
213
221
|
# last, with ways through it, as ways folds them, and calls,
|
|
214
|
-
#
|
|
215
|
-
# method's, or when not known: its first line, from
|
|
222
|
+
# the Tally of the tests that called it, nil for a top flow,
|
|
223
|
+
# which is no method's, or when not known: its first line, from
|
|
224
|
+
# decision, and
|
|
216
225
|
# a row for each [statement, taken] of rows.
|
|
217
226
|
def self.flow(decision, (name, last, ways, calls), rows)
|
|
218
227
|
first = Integer(decision.split(':')[-2])
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: path_coverage
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jon Jagger
|
|
@@ -46,11 +46,13 @@ files:
|
|
|
46
46
|
- lib/path_coverage/configuration_limits.rb
|
|
47
47
|
- lib/path_coverage/configuration_paths.rb
|
|
48
48
|
- lib/path_coverage/console_summary.rb
|
|
49
|
+
- lib/path_coverage/current_test.rb
|
|
49
50
|
- lib/path_coverage/decision.rb
|
|
50
51
|
- lib/path_coverage/decision_locations.rb
|
|
51
52
|
- lib/path_coverage/decision_paths.rb
|
|
52
53
|
- lib/path_coverage/decision_sites.rb
|
|
53
54
|
- lib/path_coverage/decision_tree.rb
|
|
55
|
+
- lib/path_coverage/evaluated.rb
|
|
54
56
|
- lib/path_coverage/fold_branches.rb
|
|
55
57
|
- lib/path_coverage/fold_cells.rb
|
|
56
58
|
- lib/path_coverage/fold_rows.rb
|
|
@@ -85,11 +87,14 @@ files:
|
|
|
85
87
|
- lib/path_coverage/method_loops.rb
|
|
86
88
|
- lib/path_coverage/method_statements.rb
|
|
87
89
|
- lib/path_coverage/method_ways.rb
|
|
90
|
+
- lib/path_coverage/minitest.rb
|
|
91
|
+
- lib/path_coverage/minitest_tests.rb
|
|
88
92
|
- lib/path_coverage/paths_context.rb
|
|
89
93
|
- lib/path_coverage/paths_fitting.rb
|
|
90
94
|
- lib/path_coverage/paths_forks.rb
|
|
91
95
|
- lib/path_coverage/paths_gaps.rb
|
|
92
96
|
- lib/path_coverage/paths_leaving.rb
|
|
97
|
+
- lib/path_coverage/paths_regions.rb
|
|
93
98
|
- lib/path_coverage/paths_report.rb
|
|
94
99
|
- lib/path_coverage/paths_rescues.rb
|
|
95
100
|
- lib/path_coverage/paths_scopes.rb
|
|
@@ -103,9 +108,12 @@ files:
|
|
|
103
108
|
- lib/path_coverage/recorder_chains.rb
|
|
104
109
|
- lib/path_coverage/recorder_writes.rb
|
|
105
110
|
- lib/path_coverage/render.rb
|
|
111
|
+
- lib/path_coverage/report_tallies.rb
|
|
112
|
+
- lib/path_coverage/report_text.rb
|
|
106
113
|
- lib/path_coverage/rescue_forks.rb
|
|
107
114
|
- lib/path_coverage/result.rb
|
|
108
115
|
- lib/path_coverage/rewriter.rb
|
|
116
|
+
- lib/path_coverage/rewriter_marks.rb
|
|
109
117
|
- lib/path_coverage/rewriter_nested.rb
|
|
110
118
|
- lib/path_coverage/runs_report.rb
|
|
111
119
|
- lib/path_coverage/source_lines.rb
|
|
@@ -114,6 +122,8 @@ files:
|
|
|
114
122
|
- lib/path_coverage/statement_arms.rb
|
|
115
123
|
- lib/path_coverage/statement_tops.rb
|
|
116
124
|
- lib/path_coverage/summary.rb
|
|
125
|
+
- lib/path_coverage/tally.rb
|
|
126
|
+
- lib/path_coverage/testing.rb
|
|
117
127
|
- lib/path_coverage/totals.rb
|
|
118
128
|
- lib/path_coverage/version.rb
|
|
119
129
|
- lib/path_coverage/walk.rb
|