varar-runner 0.8.0 → 0.9.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/lib/varar/runner/baseline_store.rb +12 -4
- data/lib/varar/runner/cli.rb +25 -0
- data/lib/varar/runner/results.rb +15 -3
- data/lib/varar/runner/run.rb +2 -2
- data/lib/varar/runner.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 11d0992b5e1c296b7a5198c3c7a095bdc71665c70d45b50cda4482d8824bd54f
|
|
4
|
+
data.tar.gz: b0d3e370635d1eeb15fde239b18319601c11a6ad512dc7b6f28fc64273eb9f32
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 80cf1dca9e44d91e2df509f518469260683daa449e6a77b6ba0a86c5cdc903aa2aeaaa427bfc13088fdc07b28a527b7ba53f9393b21d27acdb00d4f853b6e119
|
|
7
|
+
data.tar.gz: 34242a8e55333f910d8eb5adf5444c4bd2a8f69b3ff15663b0a27dbbb1f1d3652134a1aab5648a0d45cd4d4c03d1b620d9093de924aeb41f67456c9390f283ef
|
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
require 'varar/core'
|
|
5
|
+
|
|
3
6
|
module Varar
|
|
4
7
|
module Runner
|
|
5
8
|
# The filesystem BaselineStore: the committed drift baseline lives at the
|
|
6
|
-
# project root as varar.lock.
|
|
7
|
-
# only
|
|
9
|
+
# project root as varar.lock. A version 2 varar.lock.json is read while it
|
|
10
|
+
# is the only baseline (ADR 0017), and the first write deletes it, so the
|
|
11
|
+
# project is left with exactly one. The core owns the format; this adapter
|
|
12
|
+
# only moves raw text. Port of baseline-store.ts.
|
|
8
13
|
class FileBaselineStore
|
|
9
14
|
def initialize(root)
|
|
10
|
-
@path = File.join(root.to_s,
|
|
15
|
+
@path = File.join(root.to_s, Core::Drifts::LOCK_FILE_NAME)
|
|
16
|
+
@legacy_path = File.join(root.to_s, Core::Drifts::LEGACY_LOCK_FILE_NAME)
|
|
11
17
|
end
|
|
12
18
|
|
|
13
19
|
def read
|
|
14
|
-
|
|
20
|
+
path = [@path, @legacy_path].find { |p| File.exist?(p) }
|
|
21
|
+
path ? File.read(path, encoding: 'UTF-8') : nil
|
|
15
22
|
end
|
|
16
23
|
|
|
17
24
|
def write(contents)
|
|
18
25
|
File.write(@path, contents)
|
|
26
|
+
FileUtils.rm_f(@legacy_path)
|
|
19
27
|
end
|
|
20
28
|
end
|
|
21
29
|
|
data/lib/varar/runner/cli.rb
CHANGED
|
@@ -112,9 +112,34 @@ module Varar
|
|
|
112
112
|
File.write(target, content)
|
|
113
113
|
out.puts "created #{rel}"
|
|
114
114
|
end
|
|
115
|
+
ensure_gitattributes(cwd, out)
|
|
115
116
|
0
|
|
116
117
|
end
|
|
117
118
|
|
|
119
|
+
GITATTRIBUTES_ENTRY = 'varar.lock merge=union'
|
|
120
|
+
|
|
121
|
+
# varar.lock holds one example-producing paragraph per line, so git can
|
|
122
|
+
# merge it by keeping both sides' lines; a line left over from the losing
|
|
123
|
+
# side reads as a removed paragraph, not drift, and the next run drops it
|
|
124
|
+
# (ADR 0017). Creates .gitattributes when there is none, appends the entry
|
|
125
|
+
# otherwise, and leaves a file that already has it alone.
|
|
126
|
+
def self.ensure_gitattributes(cwd, out)
|
|
127
|
+
target = File.join(cwd, '.gitattributes')
|
|
128
|
+
unless File.exist?(target)
|
|
129
|
+
File.write(target, "#{GITATTRIBUTES_ENTRY}\n")
|
|
130
|
+
out.puts "created .gitattributes (#{GITATTRIBUTES_ENTRY})"
|
|
131
|
+
return
|
|
132
|
+
end
|
|
133
|
+
source = File.read(target, encoding: 'UTF-8')
|
|
134
|
+
if source.match?(/^varar\.lock\s+merge=union\s*$/)
|
|
135
|
+
out.puts 'skipped .gitattributes (already merges varar.lock by union)'
|
|
136
|
+
return
|
|
137
|
+
end
|
|
138
|
+
sep = source.empty? || source.end_with?("\n") ? '' : "\n"
|
|
139
|
+
File.write(target, "#{source}#{sep}#{GITATTRIBUTES_ENTRY}\n")
|
|
140
|
+
out.puts "updated .gitattributes (added #{GITATTRIBUTES_ENTRY})"
|
|
141
|
+
end
|
|
142
|
+
|
|
118
143
|
# RSpec when its adapter is installed, Minitest when only that one is,
|
|
119
144
|
# RSpec as the fallback (matching the tutorial's default track).
|
|
120
145
|
def self.detect_framework
|
data/lib/varar/runner/results.rb
CHANGED
|
@@ -18,6 +18,8 @@ module Varar
|
|
|
18
18
|
def initialize
|
|
19
19
|
@sources = {}
|
|
20
20
|
@examples = {}
|
|
21
|
+
# Per oath: the other documents its steps were spliced in from (ADR 0016).
|
|
22
|
+
@documents = {}
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
# `<root>/.varar/<oath_path>.json` — the file the LSP watches.
|
|
@@ -47,9 +49,15 @@ module Varar
|
|
|
47
49
|
|
|
48
50
|
# Accumulates one example's outcome; the oath's file is written once its
|
|
49
51
|
# examples are in.
|
|
50
|
-
|
|
52
|
+
# `referenced_sources` carries the OTHER documents this oath's steps were
|
|
53
|
+
# spliced in from (ADR 0016), as path => source; their hashes go in the
|
|
54
|
+
# payload so a consumer can tell a stale failure from a live one.
|
|
55
|
+
def record(oath_path, source, result, referenced_sources = nil)
|
|
51
56
|
@sources[oath_path] = source
|
|
52
57
|
(@examples[oath_path] ||= []) << result
|
|
58
|
+
return if referenced_sources.nil? || referenced_sources.empty?
|
|
59
|
+
|
|
60
|
+
(@documents[oath_path] ||= {}).merge!(referenced_sources)
|
|
53
61
|
end
|
|
54
62
|
|
|
55
63
|
# Writes what has been recorded for `oath_path` and forgets it. Passing
|
|
@@ -59,11 +67,15 @@ module Varar
|
|
|
59
67
|
recorded = @examples.delete(oath_path)
|
|
60
68
|
return nil if recorded.nil? || recorded.empty?
|
|
61
69
|
|
|
70
|
+
documents = (@documents.delete(oath_path) || {}).sort.map do |path, text|
|
|
71
|
+
Core::ReferencedDocument.new(path: path, source_hash: Core::Hash32.hash_source(text))
|
|
72
|
+
end
|
|
62
73
|
self.class.write(root, Core::OathResults.new(
|
|
63
|
-
version:
|
|
74
|
+
version: 2,
|
|
64
75
|
oath_path: oath_path,
|
|
65
76
|
source_hash: Core::Hash32.hash_source(@sources[oath_path]),
|
|
66
|
-
examples: self.class.document_order(recorded)
|
|
77
|
+
examples: self.class.document_order(recorded),
|
|
78
|
+
documents: documents
|
|
67
79
|
))
|
|
68
80
|
end
|
|
69
81
|
|
data/lib/varar/runner/run.rb
CHANGED
|
@@ -19,8 +19,8 @@ module Varar
|
|
|
19
19
|
|
|
20
20
|
module_function
|
|
21
21
|
|
|
22
|
-
def plan_oath(path, source, registry)
|
|
23
|
-
Core::Plan.plan(Core::Parse.parse(path, source), registry)
|
|
22
|
+
def plan_oath(path, source, registry, workspace)
|
|
23
|
+
Core::Plan.plan(Core::Parse.parse(path, source), registry, workspace)
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
# Pair each PlannedExample with its lazy run closure, in plan order.
|
data/lib/varar/runner.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: varar-runner
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Aslak Hellesøy
|
|
@@ -15,28 +15,28 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - '='
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 0.
|
|
18
|
+
version: 0.9.0
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - '='
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 0.
|
|
25
|
+
version: 0.9.0
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: varar-config
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
30
|
- - '='
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 0.
|
|
32
|
+
version: 0.9.0
|
|
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.
|
|
39
|
+
version: 0.9.0
|
|
40
40
|
description: Oath/step discovery, step loading, planning, failure rendering, and the
|
|
41
41
|
drift baseline store.
|
|
42
42
|
email:
|
|
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
75
|
version: '0'
|
|
76
76
|
requirements: []
|
|
77
|
-
rubygems_version: 4.0.
|
|
77
|
+
rubygems_version: 4.0.20
|
|
78
78
|
specification_version: 4
|
|
79
79
|
summary: Markdown-native BDD — imperative shell (discovery, loading, drift)
|
|
80
80
|
test_files: []
|