path_coverage 0.4.0 → 0.6.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 +260 -300
- data/exe/path_coverage_report +4 -0
- data/lib/path_coverage/call_trace.rb +109 -0
- data/lib/path_coverage/calls.rb +73 -43
- data/lib/path_coverage/{html_syntax.rb → code_tokens.rb} +35 -33
- data/lib/path_coverage/condition.rb +14 -14
- data/lib/path_coverage/configuration.rb +7 -4
- data/lib/path_coverage/configuration_limits.rb +52 -0
- data/lib/path_coverage/configuration_paths.rb +7 -7
- data/lib/path_coverage/console_summary.rb +28 -26
- data/lib/path_coverage/{site.rb → decision.rb} +2 -2
- data/lib/path_coverage/decision_locations.rb +76 -0
- data/lib/path_coverage/{site_paths.rb → decision_paths.rb} +13 -11
- data/lib/path_coverage/{site_tree.rb → decision_tree.rb} +25 -16
- data/lib/path_coverage/fold_branches.rb +18 -0
- data/lib/path_coverage/fold_cells.rb +42 -0
- data/lib/path_coverage/{html_tree.rb → fold_rows.rb} +43 -72
- data/lib/path_coverage/gaps.rb +33 -15
- data/lib/path_coverage/json_reader.rb +54 -19
- data/lib/path_coverage/json_reports.rb +109 -0
- data/lib/path_coverage/json_writer.rb +29 -14
- data/lib/path_coverage/kernel.rb +77 -58
- data/lib/path_coverage/kinds/base.rb +16 -16
- data/lib/path_coverage/kinds/block.rb +16 -15
- data/lib/path_coverage/kinds/case.rb +14 -12
- data/lib/path_coverage/kinds/chain.rb +40 -11
- data/lib/path_coverage/kinds/choice.rb +4 -3
- data/lib/path_coverage/kinds/contains.rb +40 -32
- data/lib/path_coverage/kinds/safe.rb +38 -26
- data/lib/path_coverage/kinds/write.rb +6 -6
- data/lib/path_coverage/kinds.rb +2 -2
- data/lib/path_coverage/leaving.rb +52 -0
- data/lib/path_coverage/loop_forks.rb +57 -0
- data/lib/path_coverage/loop_nodes.rb +91 -0
- data/lib/path_coverage/manifest.rb +92 -58
- data/lib/path_coverage/manifest_blocks.rb +5 -26
- data/lib/path_coverage/manifest_case.rb +2 -2
- data/lib/path_coverage/manifest_chains.rb +8 -8
- data/lib/path_coverage/manifest_choices.rb +23 -20
- data/lib/path_coverage/manifest_disabled.rb +97 -0
- data/lib/path_coverage/manifest_folding.rb +43 -40
- data/lib/path_coverage/manifest_ignoring.rb +6 -6
- data/lib/path_coverage/manifest_writes.rb +11 -10
- data/lib/path_coverage/measured_by.rb +20 -0
- data/lib/path_coverage/merge.rb +7 -7
- data/lib/path_coverage/method_loops.rb +172 -0
- data/lib/path_coverage/method_statements.rb +150 -134
- data/lib/path_coverage/method_ways.rb +170 -0
- data/lib/path_coverage/paths_context.rb +104 -0
- data/lib/path_coverage/paths_fitting.rb +31 -0
- data/lib/path_coverage/paths_forks.rb +72 -0
- data/lib/path_coverage/paths_gaps.rb +137 -0
- data/lib/path_coverage/paths_leaving.rb +40 -0
- data/lib/path_coverage/paths_report.rb +16 -16
- data/lib/path_coverage/paths_rescues.rb +146 -0
- data/lib/path_coverage/paths_scopes.rb +37 -0
- data/lib/path_coverage/paths_tree.rb +203 -0
- data/lib/path_coverage/paths_way_lists.rb +72 -0
- data/lib/path_coverage/paths_ways.rb +193 -0
- data/lib/path_coverage/recorder.rb +71 -36
- data/lib/path_coverage/recorder_blocks.rb +17 -17
- data/lib/path_coverage/recorder_cases.rb +12 -11
- data/lib/path_coverage/recorder_chains.rb +12 -12
- data/lib/path_coverage/recorder_writes.rb +9 -9
- data/lib/path_coverage/render.rb +58 -51
- data/lib/path_coverage/rescue_forks.rb +174 -0
- data/lib/path_coverage/result.rb +32 -31
- data/lib/path_coverage/rewriter.rb +116 -35
- data/lib/path_coverage/rewriter_nested.rb +13 -13
- data/lib/path_coverage/runs_report.rb +84 -0
- data/lib/path_coverage/source_lines.rb +16 -16
- data/lib/path_coverage/source_report.rb +100 -0
- data/lib/path_coverage/stable_leaves.rb +162 -0
- data/lib/path_coverage/statement_arms.rb +53 -38
- data/lib/path_coverage/summary.rb +4 -62
- data/lib/path_coverage/totals.rb +12 -10
- data/lib/path_coverage/version.rb +1 -1
- data/lib/path_coverage/walk.rb +106 -0
- data/lib/path_coverage/way_algebras.rb +127 -0
- data/lib/path_coverage/ways_report.rb +91 -0
- data/lib/path_coverage/ways_totals.rb +46 -0
- data/lib/path_coverage/within_methods.rb +152 -97
- metadata +39 -30
- data/lib/path_coverage/card.rb +0 -14
- data/lib/path_coverage/card_tree.rb +0 -186
- data/lib/path_coverage/card_ways.rb +0 -140
- data/lib/path_coverage/html/file.html +0 -33
- data/lib/path_coverage/html/index.html +0 -29
- data/lib/path_coverage/html/settings.js +0 -50
- data/lib/path_coverage/html/side.js +0 -599
- data/lib/path_coverage/html/sort.js +0 -34
- data/lib/path_coverage/html/style.css +0 -484
- data/lib/path_coverage/html/tabs.js +0 -15
- data/lib/path_coverage/html/theme.js +0 -27
- data/lib/path_coverage/html_branch.rb +0 -30
- data/lib/path_coverage/html_cards.rb +0 -88
- data/lib/path_coverage/html_cells.rb +0 -71
- data/lib/path_coverage/html_file.rb +0 -123
- data/lib/path_coverage/html_index.rb +0 -128
- data/lib/path_coverage/html_index_head.rb +0 -29
- data/lib/path_coverage/html_labels.rb +0 -16
- data/lib/path_coverage/html_methods.rb +0 -66
- data/lib/path_coverage/html_nav.rb +0 -67
- data/lib/path_coverage/html_report.rb +0 -131
- data/lib/path_coverage/html_statements.rb +0 -186
- data/lib/path_coverage/html_tabs.rb +0 -26
- data/lib/path_coverage/html_template.rb +0 -26
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
module PathCoverage
|
|
4
|
+
# A method flow's taken ways, and its loops' passes, as the JSON
|
|
5
|
+
# report lists them: each way the steps one call, or one pass,
|
|
6
|
+
# took, in order, a decision's {"at", "path"}, a loop's {"at",
|
|
7
|
+
# "path", "passes"}, its path how many passes it made, or any
|
|
8
|
+
# other row's {"at"}, with how many took it.
|
|
9
|
+
module WaysReport
|
|
10
|
+
# [{ "way" => [step, ...], "count" => n }] of walked, { way =>
|
|
11
|
+
# n }, one unit's ways as a CallTrace counts them, in the order
|
|
12
|
+
# first taken.
|
|
13
|
+
def self.taken(walked)
|
|
14
|
+
walked.map do |each, count|
|
|
15
|
+
{ 'way' => way(each), 'count' => count }
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# [step, ...] of steps, one way, as the JSON report lists it.
|
|
20
|
+
def self.way(steps)
|
|
21
|
+
steps.map { step(_1) }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# A step as the JSON report lists it: its row's at and, for a
|
|
25
|
+
# decision's or a loop's, its path; for a loop's, the distinct
|
|
26
|
+
# ways its passes took, ordered by their JSON text.
|
|
27
|
+
def self.step(step)
|
|
28
|
+
listed = { 'at' => at(step[0]) }
|
|
29
|
+
return listed if step.size == 1
|
|
30
|
+
|
|
31
|
+
listed['path'] = step[1]
|
|
32
|
+
return listed if step.size == 2
|
|
33
|
+
|
|
34
|
+
passes = step[2].map { way(_1) }.sort_by { JSON.generate(_1) }
|
|
35
|
+
listed.merge('passes' => passes)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# { method's entry, or loop's name => { way => count } } of a
|
|
39
|
+
# JSON report's flows, as a CallTrace counts them: each flow
|
|
40
|
+
# listing its calls' ways and its loops' passes; a top flow
|
|
41
|
+
# lists neither, as no call runs it.
|
|
42
|
+
def self.ways(report)
|
|
43
|
+
report['flows'].each_with_object({}) do |(entry, flow), found|
|
|
44
|
+
next unless flow.key?('taken')
|
|
45
|
+
|
|
46
|
+
found[entry] = read(entry, flow['taken'])
|
|
47
|
+
flow['passes'].each do |at, passes|
|
|
48
|
+
loop = named(entry, at)
|
|
49
|
+
found[loop] = read(loop, passes)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# { way => count } of listed, the unit named unit's ways as
|
|
55
|
+
# taken lists them.
|
|
56
|
+
def self.read(unit, listed)
|
|
57
|
+
listed.to_h do |each|
|
|
58
|
+
[each['way'].map { unlisted(unit, _1) }, each['count']]
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# A step, as a JSON report lists it, of a unit named like
|
|
63
|
+
# unit, as a CallTrace counts it.
|
|
64
|
+
def self.unlisted(unit, step)
|
|
65
|
+
name = named(unit, step['at'])
|
|
66
|
+
return [name] unless step.key?('path')
|
|
67
|
+
return [name, step['path']] unless step.key?('passes')
|
|
68
|
+
|
|
69
|
+
ways = step['passes'].to_set do |way|
|
|
70
|
+
way.map { unlisted(unit, _1) }
|
|
71
|
+
end
|
|
72
|
+
[name, step['path'], ways]
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# The name, in the file of the unit named unit, of the row or
|
|
76
|
+
# loop at, as at gives it: "k.rb:2:2" and "4:06" give
|
|
77
|
+
# "k.rb:4:6".
|
|
78
|
+
def self.named(unit, at)
|
|
79
|
+
line, column = at.split(':')
|
|
80
|
+
file = unit.split(':')[..-3].join(':')
|
|
81
|
+
"#{file}:#{line}:#{Integer(column, 10)}"
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# The line:column of the row or loop named name, the column two
|
|
85
|
+
# digits, as a flow's rows have it: "k.rb:4:6" gives "4:06".
|
|
86
|
+
def self.at(name)
|
|
87
|
+
line, column = name.split(':').last(2)
|
|
88
|
+
format('%<line>s:%<column>02d', line:, column: Integer(column))
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require_relative 'console_summary'
|
|
2
|
+
|
|
3
|
+
module PathCoverage
|
|
4
|
+
# The terminal totals of a JSON report, read from its JSON alone,
|
|
5
|
+
# so a person reads what an AI reading the same JSON finds: the
|
|
6
|
+
# ways covered, and the methods with more paths than max paths
|
|
7
|
+
# allows.
|
|
8
|
+
module WaysTotals
|
|
9
|
+
# True when report, a JSON report as a Hash, fails: a method in
|
|
10
|
+
# it has a path no test took, a path taken that was declared
|
|
11
|
+
# impossible, or more paths than its max_paths.
|
|
12
|
+
def self.failed?(report)
|
|
13
|
+
listed, over = methods(report)
|
|
14
|
+
untaken = listed.sum do |flow|
|
|
15
|
+
flow['gaps'].size + flow['impossible_taken'].size
|
|
16
|
+
end
|
|
17
|
+
!over.empty? || untaken.positive?
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# The totals lines of report, a JSON report as a Hash: its
|
|
21
|
+
# listed methods' ways covered out of their ways, then how many
|
|
22
|
+
# methods have more paths than its max_paths, each such one
|
|
23
|
+
# failing.
|
|
24
|
+
def self.lines(report)
|
|
25
|
+
listed, over = methods(report)
|
|
26
|
+
covered = listed.sum { _1['covered'].size }
|
|
27
|
+
ways = listed.sum { _1['ways'] }
|
|
28
|
+
limit = report['max_paths']
|
|
29
|
+
["Paths: #{ConsoleSummary.figure([covered, ways])}",
|
|
30
|
+
"Functions over --max-paths=#{limit}: #{over.size}"]
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# [listed, over] of report's method flows: those listing their
|
|
34
|
+
# ways, and those with more paths than its max_paths, which
|
|
35
|
+
# list none. A top flow, run by no call, has no taken ways, so
|
|
36
|
+
# is in neither.
|
|
37
|
+
def self.methods(report)
|
|
38
|
+
found = report['flows'].values.group_by do |flow|
|
|
39
|
+
next :top unless flow.key?('taken')
|
|
40
|
+
|
|
41
|
+
flow.key?('covered') ? :listed : :over
|
|
42
|
+
end
|
|
43
|
+
[found.fetch(:listed, []), found.fetch(:over, [])]
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -1,58 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
require_relative '
|
|
3
|
-
require_relative '
|
|
4
|
-
require_relative '
|
|
1
|
+
require_relative 'paths_context'
|
|
2
|
+
require_relative 'paths_scopes'
|
|
3
|
+
require_relative 'paths_tree'
|
|
4
|
+
require_relative 'paths_way_lists'
|
|
5
|
+
require_relative 'paths_ways'
|
|
6
|
+
require_relative 'loop_forks'
|
|
7
|
+
require_relative 'method_loops'
|
|
5
8
|
require_relative 'method_statements'
|
|
9
|
+
require_relative 'method_ways'
|
|
6
10
|
require_relative 'source_lines'
|
|
7
11
|
|
|
8
12
|
module PathCoverage
|
|
9
13
|
# What is measured within each method of a covered file.
|
|
10
14
|
module WithinMethods
|
|
11
|
-
# Where each statement of the covered file at path, parsed
|
|
12
|
-
# as Manifest.parse gives it, that is no site is reached, as
|
|
13
|
-
# MethodStatements.reaches gives them.
|
|
14
|
-
def self.reaches(path, parsed, config)
|
|
15
|
-
source, sites = parsed.values_at(:source, :sites)
|
|
16
|
-
MethodStatements.reaches(source, config.relative(path), sites)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
15
|
# Example: { "k.rb:0:0" => [1, 2], "k.rb:1:0" => [2, 4] }.
|
|
20
|
-
# Each def's
|
|
21
|
-
# files, { full path => {source:,
|
|
16
|
+
# Each def's flow total, [taken, size], in every file in
|
|
17
|
+
# files, { full path => {source:, decisions:} }, from paths, as
|
|
22
18
|
# Result#paths gives them, and reached, as Recorder#reached
|
|
23
|
-
# does; and each file's top level's, its
|
|
19
|
+
# does; and each file's top level's, its decisions on no flow,
|
|
24
20
|
# named for line 0, which no def is on.
|
|
25
|
-
def self.
|
|
21
|
+
def self.flows(files, config, paths, reached)
|
|
26
22
|
files.map do |full_path, parsed|
|
|
27
23
|
path = config.relative(full_path)
|
|
28
|
-
source,
|
|
29
|
-
|
|
30
|
-
MethodStatements.
|
|
31
|
-
|
|
24
|
+
source, decisions = parsed.values_at(:source, :decisions)
|
|
25
|
+
args = [source, path, paths]
|
|
26
|
+
top = MethodStatements.top_level(*args, decisions)
|
|
27
|
+
PathsContext.totals(*args, reached, decisions)
|
|
28
|
+
.merge("#{path}:0:0" => top)
|
|
32
29
|
end.reduce({}, :merge)
|
|
33
30
|
end
|
|
34
31
|
|
|
35
32
|
# Example: { "k.rb:1:0" => { "name" => "ship", "first" => 1,
|
|
36
33
|
# "last" => 3, "rows" => [{ "at" => "2:04", ... }] } }.
|
|
37
|
-
# Each
|
|
34
|
+
# Each flow in every file in files, a def's and a top flow's,
|
|
38
35
|
# as its page draws it, for the JSON report, so a reader
|
|
39
|
-
# finds a
|
|
40
|
-
# reached as
|
|
41
|
-
|
|
36
|
+
# finds a flow's gap without the page; result a Result;
|
|
37
|
+
# counted [reached, ways], reached as flows takes it, ways as
|
|
38
|
+
# a CallTrace counts them, nil when not known.
|
|
39
|
+
def self.listed(files, config, result, counted)
|
|
42
40
|
files.map do |full_path, parsed|
|
|
43
41
|
path = config.relative(full_path)
|
|
44
42
|
recorded = [result.operands, result.paths]
|
|
45
|
-
|
|
43
|
+
limited = [*counted, config.path_limit, config.loops?]
|
|
44
|
+
listed_in(path, parsed, result.paths, limited)
|
|
46
45
|
.merge(listed_tops(path, parsed, recorded))
|
|
47
46
|
end.reduce({}, :merge)
|
|
48
47
|
end
|
|
49
48
|
|
|
50
49
|
# Example: { "k.rb" => { "1:0" => { "2:2" => { "parent" =>
|
|
51
50
|
# nil, "in" => nil, "on" => nil } } } }.
|
|
52
|
-
# How the rows of each
|
|
53
|
-
# the file's path, then its
|
|
54
|
-
# and each top
|
|
55
|
-
# as
|
|
51
|
+
# How the rows of each flow nest, in every file in files: by
|
|
52
|
+
# the file's path, then its flow's line:column, a def's flow
|
|
53
|
+
# and each top flow, as listed names them, then each row's,
|
|
54
|
+
# as PathsTree places them; result a Result.
|
|
56
55
|
def self.tree(files, config, result)
|
|
57
56
|
files.to_h do |full_path, parsed|
|
|
58
57
|
path = config.relative(full_path)
|
|
@@ -60,42 +59,42 @@ module PathCoverage
|
|
|
60
59
|
end
|
|
61
60
|
end
|
|
62
61
|
|
|
63
|
-
# How the rows of each
|
|
62
|
+
# How the rows of each flow of the file at path nest, parsed
|
|
64
63
|
# as Manifest.parse gives it, as tree gives them.
|
|
65
64
|
def self.tree_in(path, parsed, result)
|
|
66
|
-
source,
|
|
67
|
-
|
|
65
|
+
source, decisions = parsed.values_at(:source, :decisions)
|
|
66
|
+
flows = PathsTree.of(source, path, decisions).to_a +
|
|
68
67
|
tree_tops(path, parsed, result)
|
|
69
|
-
|
|
70
|
-
[
|
|
68
|
+
flows.to_h do |decision, rows|
|
|
69
|
+
[decision.split(':').last(2) * ':', rows]
|
|
71
70
|
end
|
|
72
71
|
end
|
|
73
72
|
|
|
74
|
-
# [[
|
|
73
|
+
# [[flow decision, its rows' places]] for each top flow of the
|
|
75
74
|
# file at path, as listed_tops names them.
|
|
76
75
|
def self.tree_tops(path, parsed, result)
|
|
77
|
-
source,
|
|
78
|
-
lines = SourceLines.of(source,
|
|
76
|
+
source, decisions = parsed.values_at(:source, :decisions)
|
|
77
|
+
lines = SourceLines.of(source, decisions, result.operands)
|
|
79
78
|
spans(path, parsed, lines).map do |span, rows|
|
|
80
|
-
nested =
|
|
79
|
+
nested = PathsTree.nested(source, decisions, rows)
|
|
81
80
|
["#{path}:#{span.begin}:0", nested]
|
|
82
81
|
end
|
|
83
82
|
end
|
|
84
83
|
|
|
85
|
-
# The top
|
|
86
|
-
# each under the
|
|
87
|
-
# its scope, as listed gives them; operands and
|
|
88
|
-
# Result gives them.
|
|
89
|
-
def self.listed_tops(path, parsed, (operands,
|
|
90
|
-
source,
|
|
91
|
-
lines = SourceLines.of(source,
|
|
92
|
-
scopes =
|
|
84
|
+
# The top flows of the file at path, as its page draws them:
|
|
85
|
+
# each under the decision of its first line's start, named for
|
|
86
|
+
# its scope, as listed gives them; operands and decision_paths
|
|
87
|
+
# as Result gives them.
|
|
88
|
+
def self.listed_tops(path, parsed, (operands, decision_paths))
|
|
89
|
+
source, decisions = parsed.values_at(:source, :decisions)
|
|
90
|
+
lines = SourceLines.of(source, decisions, operands)
|
|
91
|
+
scopes = PathsScopes.of(source)
|
|
93
92
|
spans(path, parsed, lines).to_h do |span, rows|
|
|
94
|
-
|
|
95
|
-
taken = rows.zip(MethodStatements.taken(rows,
|
|
96
|
-
ways =
|
|
93
|
+
decision = "#{path}:#{span.begin}:0"
|
|
94
|
+
taken = rows.zip(MethodStatements.taken(rows, decision_paths))
|
|
95
|
+
ways = PathsWays.flow(source, decisions, rows)
|
|
97
96
|
named = [scopes[span.begin], span.end, ways, nil]
|
|
98
|
-
[
|
|
97
|
+
[decision, flow(decision, named, taken)]
|
|
99
98
|
end
|
|
100
99
|
end
|
|
101
100
|
|
|
@@ -103,75 +102,131 @@ module PathCoverage
|
|
|
103
102
|
# row under the span its line is in, lines as SourceLines.of
|
|
104
103
|
# gives them.
|
|
105
104
|
def self.spans(path, parsed, lines)
|
|
106
|
-
source,
|
|
107
|
-
rows = MethodStatements.top_rows(source, path,
|
|
105
|
+
source, decisions = parsed.values_at(:source, :decisions)
|
|
106
|
+
rows = MethodStatements.top_rows(source, path, decisions)
|
|
108
107
|
rows.group_by { lines[_1.line - 1][:span] }
|
|
109
108
|
end
|
|
110
109
|
|
|
111
|
-
#
|
|
112
|
-
# gives it,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
(location.start_line..location.end_line).cover?(line)
|
|
110
|
+
# The flows of the file at path, parsed as Manifest.parse
|
|
111
|
+
# gives it, as listed gives them, each listing its ways too
|
|
112
|
+
# when counted's ways are known, counted being [reached, ways,
|
|
113
|
+
# limit, loops], limit the most ways a flow lists, loops
|
|
114
|
+
# whether each loop is a fork.
|
|
115
|
+
def self.listed_in(path, parsed, paths, (reached, *counted))
|
|
116
|
+
source, decisions = parsed.values_at(:source, :decisions)
|
|
117
|
+
titles = titles(source, path, decisions)
|
|
118
|
+
lister = WayLister.new(source, path, decisions, counted)
|
|
119
|
+
context = [source, decisions, paths, reached]
|
|
120
|
+
MethodStatements.of(source, path, decisions).to_h do |key, rows|
|
|
121
|
+
count = lister.count(key, rows)
|
|
122
|
+
named = [*titles[key], count, reached&.fetch(key, 0)]
|
|
123
|
+
shown = method_flow(key, rows, named, context)
|
|
124
|
+
[key, shown.merge(lister.lists(key, rows, count))]
|
|
127
125
|
end
|
|
128
|
-
holding.empty? ? 'file' : holding.last.name.to_s
|
|
129
126
|
end
|
|
130
127
|
|
|
131
|
-
# The
|
|
132
|
-
|
|
128
|
+
# The flow of the def at key, its rows, named as flow takes
|
|
129
|
+
# named; context is [source, decisions, paths, reached], as
|
|
130
|
+
# listed_in has them.
|
|
131
|
+
def self.method_flow(key, rows, named, context)
|
|
132
|
+
source, decisions, paths, reached = context
|
|
133
|
+
shown = PathsContext.rows(source, decisions, rows, paths,
|
|
134
|
+
reached)
|
|
135
|
+
flow(key, named, shown)
|
|
136
|
+
end
|
|
133
137
|
|
|
134
|
-
#
|
|
135
|
-
#
|
|
136
|
-
def self.
|
|
137
|
-
|
|
138
|
-
|
|
138
|
+
# { def decision => [its name, its last line] } for each def in
|
|
139
|
+
# source, at path, as its flow is titled.
|
|
140
|
+
def self.titles(source, path, decisions)
|
|
141
|
+
names = MethodStatements.names(source, path, decisions)
|
|
142
|
+
lasts = MethodStatements.lasts(source, path, decisions)
|
|
143
|
+
names.to_h { |key, name| [key, [name, lasts[key]]] }
|
|
139
144
|
end
|
|
140
145
|
|
|
141
|
-
# The
|
|
142
|
-
#
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
146
|
+
# The way lists of each flow of a file, as PathsWayLists gives
|
|
147
|
+
# them.
|
|
148
|
+
class WayLister
|
|
149
|
+
# The lister of the file at path, source, its decisions as
|
|
150
|
+
# Manifest.parse gives them; counted [ways, limit]: ways as a
|
|
151
|
+
# CallTrace counts them, nil when not known, and limit the
|
|
152
|
+
# most ways a flow lists.
|
|
153
|
+
def initialize(source, path, decisions, (ways, limit, loops))
|
|
154
|
+
@source = source
|
|
155
|
+
@decisions = decisions
|
|
156
|
+
@ways = ways
|
|
157
|
+
@limit = limit
|
|
158
|
+
@loops = MethodLoops.of(source, path, decisions)
|
|
159
|
+
@forks = LoopForks.of(source, path, decisions)
|
|
160
|
+
@rescues = RescueForks.of(source, path)
|
|
161
|
+
@forking = loops
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# How many ways go through the flow of the def at key, its
|
|
165
|
+
# rows. Each loop is a scope, and a fork when loops are. Its
|
|
166
|
+
# rescue is a fork.
|
|
167
|
+
def count(key, rows)
|
|
168
|
+
PathsWays.flow(@source, @decisions, rows,
|
|
169
|
+
WayAlgebras::Counted, [true, *scopes(key)])
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# The way lists of the flow of the def at key, its rows, with
|
|
173
|
+
# count ways through it: none when the ways are not known;
|
|
174
|
+
# those its calls took and its loops' passes; and, when count
|
|
175
|
+
# is no more than the limit, its covered, gaps and impossible.
|
|
176
|
+
def lists(key, rows, count)
|
|
177
|
+
return {} if @ways.nil?
|
|
178
|
+
|
|
179
|
+
walked = PathsWayLists.walked(key, @ways, loops(key))
|
|
180
|
+
return walked if count > @limit
|
|
181
|
+
|
|
182
|
+
split = MethodWays.split_flow(@source, @decisions, rows,
|
|
183
|
+
scopes(key))
|
|
184
|
+
checked = [split, forked(key).keys]
|
|
185
|
+
walked.merge(PathsWayLists.checked(key, @ways, checked))
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
private
|
|
189
|
+
|
|
190
|
+
# [forks, rescues, forking] of the def at key, as
|
|
191
|
+
# MethodWays.split_flow takes them. forks is each of its
|
|
192
|
+
# loops, as LoopForks gives them. rescues is its rescue
|
|
193
|
+
# forks. forking says whether its loops fork.
|
|
194
|
+
def scopes(key)
|
|
195
|
+
[@forks.fetch(key), @rescues.fetch(key), @forking]
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
# The names of the loops of the def at key: those holding a
|
|
199
|
+
# row, and those that fork.
|
|
200
|
+
def loops(key)
|
|
201
|
+
(@loops[key].values.flatten + @forks.fetch(key).keys).uniq
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
# The loops of the def at key that fork, as
|
|
205
|
+
# LoopForks gives them; none unless loops are forks.
|
|
206
|
+
def forked(key)
|
|
207
|
+
@forking ? @forks.fetch(key) : {}
|
|
153
208
|
end
|
|
154
209
|
end
|
|
155
210
|
|
|
156
|
-
# The
|
|
211
|
+
# The flow of the def at decision, named name, ending on line
|
|
157
212
|
# last, with ways through it, as ways folds them, and calls,
|
|
158
|
-
# how many times it was called, nil for a top
|
|
159
|
-
# method's, or when not known: its first line, from
|
|
213
|
+
# how many times it was called, nil for a top flow, which is no
|
|
214
|
+
# method's, or when not known: its first line, from decision, and
|
|
160
215
|
# a row for each [statement, taken] of rows.
|
|
161
|
-
def self.
|
|
162
|
-
first = Integer(
|
|
216
|
+
def self.flow(decision, (name, last, ways, calls), rows)
|
|
217
|
+
first = Integer(decision.split(':')[-2])
|
|
163
218
|
listed = rows.map { |statement, count| row(statement, count) }
|
|
164
219
|
{ 'name' => name, 'first' => first, 'last' => last,
|
|
165
220
|
'ways' => ways, 'calls' => calls, 'rows' => listed }
|
|
166
221
|
end
|
|
167
222
|
|
|
168
|
-
# A
|
|
223
|
+
# A flow's row: statement's line:column, as its page labels
|
|
169
224
|
# it, its top, its paths, count, how many were taken, and
|
|
170
|
-
# its
|
|
225
|
+
# its decision, nil for a statement that is no decision.
|
|
171
226
|
def self.row(statement, count)
|
|
172
|
-
{ 'at' =>
|
|
227
|
+
{ 'at' => MethodStatements.at(statement),
|
|
173
228
|
'top' => statement.top, 'paths' => statement.paths,
|
|
174
|
-
'taken' => count, '
|
|
229
|
+
'taken' => count, 'decision' => statement.decision }
|
|
175
230
|
end
|
|
176
231
|
end
|
|
177
232
|
end
|
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.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jon Jagger
|
|
@@ -27,48 +27,35 @@ description: Records which paths each condition and each method took, and report
|
|
|
27
27
|
the paths never taken in the terminal and as HTML.
|
|
28
28
|
executables:
|
|
29
29
|
- path_coverage_collector
|
|
30
|
+
- path_coverage_report
|
|
30
31
|
extensions: []
|
|
31
32
|
extra_rdoc_files: []
|
|
32
33
|
files:
|
|
33
34
|
- LICENSE.md
|
|
34
35
|
- README.md
|
|
35
36
|
- exe/path_coverage_collector
|
|
37
|
+
- exe/path_coverage_report
|
|
36
38
|
- lib/path_coverage.rb
|
|
37
39
|
- lib/path_coverage/auto.rb
|
|
40
|
+
- lib/path_coverage/call_trace.rb
|
|
38
41
|
- lib/path_coverage/calls.rb
|
|
39
|
-
- lib/path_coverage/
|
|
40
|
-
- lib/path_coverage/card_tree.rb
|
|
41
|
-
- lib/path_coverage/card_ways.rb
|
|
42
|
+
- lib/path_coverage/code_tokens.rb
|
|
42
43
|
- lib/path_coverage/collector.rb
|
|
43
44
|
- lib/path_coverage/condition.rb
|
|
44
45
|
- lib/path_coverage/configuration.rb
|
|
46
|
+
- lib/path_coverage/configuration_limits.rb
|
|
45
47
|
- lib/path_coverage/configuration_paths.rb
|
|
46
48
|
- lib/path_coverage/console_summary.rb
|
|
49
|
+
- lib/path_coverage/decision.rb
|
|
50
|
+
- lib/path_coverage/decision_locations.rb
|
|
51
|
+
- lib/path_coverage/decision_paths.rb
|
|
52
|
+
- lib/path_coverage/decision_tree.rb
|
|
53
|
+
- lib/path_coverage/fold_branches.rb
|
|
54
|
+
- lib/path_coverage/fold_cells.rb
|
|
55
|
+
- lib/path_coverage/fold_rows.rb
|
|
47
56
|
- lib/path_coverage/gaps.rb
|
|
48
|
-
- lib/path_coverage/html/file.html
|
|
49
|
-
- lib/path_coverage/html/index.html
|
|
50
|
-
- lib/path_coverage/html/settings.js
|
|
51
|
-
- lib/path_coverage/html/side.js
|
|
52
|
-
- lib/path_coverage/html/sort.js
|
|
53
|
-
- lib/path_coverage/html/style.css
|
|
54
|
-
- lib/path_coverage/html/tabs.js
|
|
55
|
-
- lib/path_coverage/html/theme.js
|
|
56
|
-
- lib/path_coverage/html_branch.rb
|
|
57
|
-
- lib/path_coverage/html_cards.rb
|
|
58
|
-
- lib/path_coverage/html_cells.rb
|
|
59
|
-
- lib/path_coverage/html_file.rb
|
|
60
|
-
- lib/path_coverage/html_index.rb
|
|
61
|
-
- lib/path_coverage/html_index_head.rb
|
|
62
|
-
- lib/path_coverage/html_labels.rb
|
|
63
|
-
- lib/path_coverage/html_methods.rb
|
|
64
|
-
- lib/path_coverage/html_nav.rb
|
|
65
|
-
- lib/path_coverage/html_report.rb
|
|
66
|
-
- lib/path_coverage/html_statements.rb
|
|
67
|
-
- lib/path_coverage/html_syntax.rb
|
|
68
|
-
- lib/path_coverage/html_tabs.rb
|
|
69
|
-
- lib/path_coverage/html_template.rb
|
|
70
|
-
- lib/path_coverage/html_tree.rb
|
|
71
57
|
- lib/path_coverage/json_reader.rb
|
|
58
|
+
- lib/path_coverage/json_reports.rb
|
|
72
59
|
- lib/path_coverage/json_writer.rb
|
|
73
60
|
- lib/path_coverage/kernel.rb
|
|
74
61
|
- lib/path_coverage/kinds.rb
|
|
@@ -80,17 +67,34 @@ files:
|
|
|
80
67
|
- lib/path_coverage/kinds/contains.rb
|
|
81
68
|
- lib/path_coverage/kinds/safe.rb
|
|
82
69
|
- lib/path_coverage/kinds/write.rb
|
|
70
|
+
- lib/path_coverage/leaving.rb
|
|
71
|
+
- lib/path_coverage/loop_forks.rb
|
|
72
|
+
- lib/path_coverage/loop_nodes.rb
|
|
83
73
|
- lib/path_coverage/manifest.rb
|
|
84
74
|
- lib/path_coverage/manifest_blocks.rb
|
|
85
75
|
- lib/path_coverage/manifest_case.rb
|
|
86
76
|
- lib/path_coverage/manifest_chains.rb
|
|
87
77
|
- lib/path_coverage/manifest_choices.rb
|
|
78
|
+
- lib/path_coverage/manifest_disabled.rb
|
|
88
79
|
- lib/path_coverage/manifest_folding.rb
|
|
89
80
|
- lib/path_coverage/manifest_ignoring.rb
|
|
90
81
|
- lib/path_coverage/manifest_writes.rb
|
|
82
|
+
- lib/path_coverage/measured_by.rb
|
|
91
83
|
- lib/path_coverage/merge.rb
|
|
84
|
+
- lib/path_coverage/method_loops.rb
|
|
92
85
|
- lib/path_coverage/method_statements.rb
|
|
86
|
+
- lib/path_coverage/method_ways.rb
|
|
87
|
+
- lib/path_coverage/paths_context.rb
|
|
88
|
+
- lib/path_coverage/paths_fitting.rb
|
|
89
|
+
- lib/path_coverage/paths_forks.rb
|
|
90
|
+
- lib/path_coverage/paths_gaps.rb
|
|
91
|
+
- lib/path_coverage/paths_leaving.rb
|
|
93
92
|
- lib/path_coverage/paths_report.rb
|
|
93
|
+
- lib/path_coverage/paths_rescues.rb
|
|
94
|
+
- lib/path_coverage/paths_scopes.rb
|
|
95
|
+
- lib/path_coverage/paths_tree.rb
|
|
96
|
+
- lib/path_coverage/paths_way_lists.rb
|
|
97
|
+
- lib/path_coverage/paths_ways.rb
|
|
94
98
|
- lib/path_coverage/post.rb
|
|
95
99
|
- lib/path_coverage/recorder.rb
|
|
96
100
|
- lib/path_coverage/recorder_blocks.rb
|
|
@@ -98,17 +102,22 @@ files:
|
|
|
98
102
|
- lib/path_coverage/recorder_chains.rb
|
|
99
103
|
- lib/path_coverage/recorder_writes.rb
|
|
100
104
|
- lib/path_coverage/render.rb
|
|
105
|
+
- lib/path_coverage/rescue_forks.rb
|
|
101
106
|
- lib/path_coverage/result.rb
|
|
102
107
|
- lib/path_coverage/rewriter.rb
|
|
103
108
|
- lib/path_coverage/rewriter_nested.rb
|
|
104
|
-
- lib/path_coverage/
|
|
105
|
-
- lib/path_coverage/site_paths.rb
|
|
106
|
-
- lib/path_coverage/site_tree.rb
|
|
109
|
+
- lib/path_coverage/runs_report.rb
|
|
107
110
|
- lib/path_coverage/source_lines.rb
|
|
111
|
+
- lib/path_coverage/source_report.rb
|
|
112
|
+
- lib/path_coverage/stable_leaves.rb
|
|
108
113
|
- lib/path_coverage/statement_arms.rb
|
|
109
114
|
- lib/path_coverage/summary.rb
|
|
110
115
|
- lib/path_coverage/totals.rb
|
|
111
116
|
- lib/path_coverage/version.rb
|
|
117
|
+
- lib/path_coverage/walk.rb
|
|
118
|
+
- lib/path_coverage/way_algebras.rb
|
|
119
|
+
- lib/path_coverage/ways_report.rb
|
|
120
|
+
- lib/path_coverage/ways_totals.rb
|
|
112
121
|
- lib/path_coverage/within_methods.rb
|
|
113
122
|
homepage: https://github.com/path-coverage/ruby
|
|
114
123
|
licenses:
|
data/lib/path_coverage/card.rb
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
module PathCoverage
|
|
2
|
-
# One card of a file's page, as the page lays out the code
|
|
3
|
-
# around it: its first and last lines, its def's column, its
|
|
4
|
-
# status, gaps or covered, whether it is a top card, of sites
|
|
5
|
-
# outside every def, how many sites a top card holds, its
|
|
6
|
-
# button showing that count, nil for a method's, and its HTML.
|
|
7
|
-
Card = Data.define(:first, :last, :column, :status, :top, :sites,
|
|
8
|
-
:html) do
|
|
9
|
-
# True when line is one of the card's lines.
|
|
10
|
-
def holds?(line)
|
|
11
|
-
(first..last).cover?(line)
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|