varar-minitest 0.8.0 → 0.8.1
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/lib/varar/minitest.rb +37 -7
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 22ad2f75ce8cdd3344dfd3476214668b7a70504a5069a88f545a52ebc28b5fcf
|
|
4
|
+
data.tar.gz: 9b423a22bac3427ff99f03f8a00bc5ff0cbde4fb886197d55efef0b467e4e5f1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9e541d6817a9680027b002bcee219dea2ea60011981bc67b4d789104d8580533402f22e2285f1509c98449a9c1bf84789c73e21e4cc03507892bd66cb3cc2638
|
|
7
|
+
data.tar.gz: 2d29d85a17b10c820f41221f992aea51cc48b5577456abf17020afbd2782c22f5a20cc025e1ad8461d9445c632de5604eae1c5156c5d8e6e6b37e2c684cfa34c
|
data/lib/varar/minitest.rb
CHANGED
|
@@ -12,7 +12,7 @@ module Varar
|
|
|
12
12
|
# require "varar/minitest"
|
|
13
13
|
# Varar::Minitest.generate_tests
|
|
14
14
|
module Minitest
|
|
15
|
-
VERSION = '0.8.
|
|
15
|
+
VERSION = '0.8.1'
|
|
16
16
|
|
|
17
17
|
module_function
|
|
18
18
|
|
|
@@ -38,16 +38,44 @@ module Varar
|
|
|
38
38
|
# everything.
|
|
39
39
|
Core::Drifts.prune_baselines(store, oaths.map { |p| Runner.rel_posix(p, root) }, update: update)
|
|
40
40
|
|
|
41
|
+
workspace = project_workspace(oaths, root)
|
|
42
|
+
|
|
41
43
|
oaths.each do |oath_path|
|
|
42
|
-
klass = build_test_case(oath_path, root, loaded, store, update, results)
|
|
44
|
+
klass = build_test_case(oath_path, root, loaded, store, update, results, workspace)
|
|
43
45
|
namespace.const_set("Var_#{identifier(Runner.rel_posix(oath_path, root))}", klass)
|
|
44
46
|
end
|
|
45
47
|
end
|
|
46
48
|
|
|
47
|
-
|
|
49
|
+
# Whether a section is a standalone example depends on whether another oath
|
|
50
|
+
# references it, which is whole-project knowledge (ADR 0016). Built from the
|
|
51
|
+
# config globs — the full set, for the same reason baseline pruning is.
|
|
52
|
+
# The sources of every oath this plan's steps were spliced in from (ADR
|
|
53
|
+
# 0016). Their hashes go in the run record, so a consumer can tell a stale
|
|
54
|
+
# failure from a live one.
|
|
55
|
+
def referenced_sources(plan, workspace)
|
|
56
|
+
plan.examples.flat_map { |ex| ex.steps.map(&:doc_path) }.compact.uniq.each_with_object({}) do |path, out|
|
|
57
|
+
doc = workspace.docs[path]
|
|
58
|
+
out[path] = doc.source if doc
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def project_workspace(oaths, root)
|
|
63
|
+
docs = oaths.filter_map do |path|
|
|
64
|
+
Core::Parse.parse(Runner.rel_posix(path, root), File.read(path, encoding: 'UTF-8'))
|
|
65
|
+
rescue SystemCallError
|
|
66
|
+
nil
|
|
67
|
+
end
|
|
68
|
+
Core::Reference.build_workspace(docs)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def build_test_case(oath_path, root, loaded, store, update, results, workspace)
|
|
48
72
|
rel = Runner.rel_posix(oath_path, root)
|
|
49
73
|
source = File.read(oath_path, encoding: 'UTF-8')
|
|
50
|
-
|
|
74
|
+
# `rel`, not the basename: doc.path is an oath's identity in every port,
|
|
75
|
+
# so a relative reference resolves alike and two same-named oaths in
|
|
76
|
+
# different directories stay distinct (ADR 0016).
|
|
77
|
+
plan = Runner.plan_oath(rel, source, loaded.registry, workspace)
|
|
78
|
+
referenced = referenced_sources(plan, workspace)
|
|
51
79
|
pairs = Runner.examples_with_runs(plan, loaded.create_context, Runner::RecordingReporter.new)
|
|
52
80
|
|
|
53
81
|
klass = Class.new(::Minitest::Test)
|
|
@@ -58,7 +86,9 @@ module Varar
|
|
|
58
86
|
idx = seen[stem]
|
|
59
87
|
seen[stem] += 1
|
|
60
88
|
method_name = idx.zero? ? "test_#{stem}" : "test_#{stem}_#{idx}"
|
|
61
|
-
|
|
89
|
+
# Lines in THIS oath: a step a reference block spliced in from another
|
|
90
|
+
# oath (ADR 0016) contributes none, since its line is not in this file.
|
|
91
|
+
lines = example.steps.reject(&:doc_path).map { |step| step.match_span.start_line }.uniq
|
|
62
92
|
klass.define_method(method_name) do
|
|
63
93
|
run.call
|
|
64
94
|
rescue StandardError => e
|
|
@@ -67,14 +97,14 @@ module Varar
|
|
|
67
97
|
results.record(rel, source, Core::ExampleResult.new(
|
|
68
98
|
name: example.name, status: 'failed', lines: lines,
|
|
69
99
|
failure: Core::Failures.to_failure(e, rel, lines.first || 0)
|
|
70
|
-
))
|
|
100
|
+
), referenced)
|
|
71
101
|
raise ::Minitest::Assertion, Runner.render_failure(e, source, rel) if Minitest.var_diff_error?(e)
|
|
72
102
|
|
|
73
103
|
raise
|
|
74
104
|
else
|
|
75
105
|
results.record(rel, source, Core::ExampleResult.new(
|
|
76
106
|
name: example.name, status: 'passed', lines: lines, failure: nil
|
|
77
|
-
))
|
|
107
|
+
), referenced)
|
|
78
108
|
end
|
|
79
109
|
end
|
|
80
110
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: varar-minitest
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Aslak Hellesøy
|
|
@@ -29,14 +29,14 @@ dependencies:
|
|
|
29
29
|
requirements:
|
|
30
30
|
- - '='
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 0.8.
|
|
32
|
+
version: 0.8.1
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - '='
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: 0.8.
|
|
39
|
+
version: 0.8.1
|
|
40
40
|
description: 'Minitest adapter: one selectable test per Markdown example, with a drift
|
|
41
41
|
gate.'
|
|
42
42
|
email:
|