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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46298c6e8b7301ae6a5853dec7ffd596f5a6d9025536eb8932af54bac545944d
4
- data.tar.gz: 67beb4b0519aece1442ab3ec0972eb6a5f41d6f5a68b72db022732f795a084bf
3
+ metadata.gz: 11d0992b5e1c296b7a5198c3c7a095bdc71665c70d45b50cda4482d8824bd54f
4
+ data.tar.gz: b0d3e370635d1eeb15fde239b18319601c11a6ad512dc7b6f28fc64273eb9f32
5
5
  SHA512:
6
- metadata.gz: f5c0baf64a0643451fd6b0f70e482818086d609e8ff9168c5e9654e061ac7452d55a576301da196a5b6654731e19d47c953ff25c388f34267eb642d90f2afef6
7
- data.tar.gz: e701f85184c8738acd5dda28eda4a9b37db06c667c5e839224bc292c556bb9ef173095899fbe395e393f3691a9325e663411c69f971a1170c005832ba4bf0e42
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.json. The core owns the format; this adapter
7
- # only moves raw text. Port of baseline_store.py.
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, 'varar.lock.json')
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
- File.exist?(@path) ? File.read(@path, encoding: 'UTF-8') : nil
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
 
@@ -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
@@ -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
- def record(oath_path, source, result)
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: 1,
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
 
@@ -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
@@ -9,7 +9,7 @@ module Varar
9
9
  # rendering, and the filesystem drift baseline store. Depends on the facade
10
10
  # and config; never on a test framework. Port of varar-runner.
11
11
  module Runner
12
- VERSION = '0.8.0'
12
+ VERSION = '0.9.0'
13
13
  end
14
14
  end
15
15
 
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.8.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.8.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.8.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.8.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.8.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.16
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: []