nukadoko 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/CHANGELOG.md +78 -0
- data/README.ja.md +12 -2
- data/README.md +10 -3
- data/lib/nukadoko/check.rb +15 -4
- data/lib/nukadoko/cli.rb +10 -4
- data/lib/nukadoko/command.rb +22 -4
- data/lib/nukadoko/error_frames.rb +44 -0
- data/lib/nukadoko/features.rb +3 -1
- data/lib/nukadoko/fixtures.rb +108 -7
- data/lib/nukadoko/judgment_file.rb +21 -0
- data/lib/nukadoko/judgments.rb +30 -0
- data/lib/nukadoko/run.rb +126 -27
- data/lib/nukadoko/run_record.rb +9 -5
- data/lib/nukadoko/schema.rb +165 -37
- data/lib/nukadoko/step_fixtures.rb +225 -0
- data/lib/nukadoko/summary.rb +4 -1
- data/lib/nukadoko/verdict.rb +18 -1
- data/lib/nukadoko/version.rb +1 -1
- data/lib/nukadoko/vocabulary.rb +1 -1
- data/lib/nukadoko.rb +2 -0
- data/llms.txt +3 -2
- data/sig/generated/nukadoko/command.rbs +13 -4
- data/sig/generated/nukadoko/error_frames.rbs +24 -0
- data/sig/generated/nukadoko/fixtures.rbs +38 -2
- data/sig/generated/nukadoko/judgment_file.rbs +6 -0
- data/sig/generated/nukadoko/judgments.rbs +10 -0
- data/sig/generated/nukadoko/run.rbs +25 -4
- data/sig/generated/nukadoko/schema.rbs +91 -27
- data/sig/generated/nukadoko/step_fixtures.rbs +129 -0
- data/sig/generated/nukadoko/verdict.rbs +8 -0
- data/skills/nukadoko/SKILL.md +1 -1
- data/skills/nukadoko/references/done.md +22 -0
- data/skills/nukadoko/references/judgments.md +6 -0
- data/skills/nukadoko/references/ruby.md +80 -0
- metadata +6 -1
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# rbs_inline: enabled
|
|
3
|
+
|
|
4
|
+
require "time"
|
|
5
|
+
require "timeout"
|
|
6
|
+
|
|
7
|
+
# The fixtures a step body uses to say where it went, to wait for a state
|
|
8
|
+
# that is not there yet, and to keep evidence only it can produce. The
|
|
9
|
+
# TypeScript engine gives the same three on ctx. Each one fills a list the
|
|
10
|
+
# engine writes into the step record, also when the step raises, because a
|
|
11
|
+
# failed step is the one whose record a reader opens.
|
|
12
|
+
module Nukadoko
|
|
13
|
+
# poll gave up: the budget ended before the block returned a value.
|
|
14
|
+
class PollTimeoutError < StandardError
|
|
15
|
+
attr_reader :timeout_ms #: Numeric
|
|
16
|
+
attr_reader :description #: String?
|
|
17
|
+
|
|
18
|
+
#: (Numeric, String?) -> void
|
|
19
|
+
def initialize(timeout_ms, description)
|
|
20
|
+
@timeout_ms = timeout_ms
|
|
21
|
+
@description = description
|
|
22
|
+
super("poll timed out after #{timeout_ms}ms#{" while waiting for #{description}" if description}")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# A timeout or interval that cannot be a budget. Raised before the first
|
|
27
|
+
# attempt, so it is not in the record: there is no attempt to count.
|
|
28
|
+
class InvalidPollOptionsError < ArgumentError; end
|
|
29
|
+
|
|
30
|
+
# An evidence name that would land outside the step's directory.
|
|
31
|
+
class InvalidEvidenceNameError < ArgumentError; end
|
|
32
|
+
|
|
33
|
+
# An evidence name the engine itself writes into the step's directory.
|
|
34
|
+
class ReservedEvidenceNameError < ArgumentError; end
|
|
35
|
+
|
|
36
|
+
# A pageAs name that cannot be part of a file name.
|
|
37
|
+
class InvalidContextNameError < ArgumentError; end
|
|
38
|
+
|
|
39
|
+
# A pageAs call that asks an open context for options it was not made with.
|
|
40
|
+
class ContextOptionsConflictError < ArgumentError; end
|
|
41
|
+
|
|
42
|
+
module Engine
|
|
43
|
+
#: () -> String
|
|
44
|
+
def self.now_iso = Time.now.utc.iso8601(3)
|
|
45
|
+
|
|
46
|
+
# `section.("label")` marks that the body reached a stage. It is a bare
|
|
47
|
+
# marker, not a block wrapper, so nesting and an early return need no
|
|
48
|
+
# meaning: the record answers where the body stopped.
|
|
49
|
+
class Sections
|
|
50
|
+
attr_reader :entries #: Array[Hash[Symbol, String]]
|
|
51
|
+
|
|
52
|
+
#: () -> void
|
|
53
|
+
def initialize
|
|
54
|
+
@entries = []
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
#: (String | Symbol) -> nil
|
|
58
|
+
def call(label)
|
|
59
|
+
@entries << { label: label.to_s, at: Engine.now_iso }
|
|
60
|
+
nil
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# `poll.(description:, timeout:, interval:) { value or nil }` calls the
|
|
65
|
+
# block until it gives a value other than nil. The budget holds the
|
|
66
|
+
# attempt in flight too, so a value that arrives after it is not
|
|
67
|
+
# returned. Every finished call is kept, so the record tells a wait that
|
|
68
|
+
# did nothing from one that took seconds.
|
|
69
|
+
class Polls
|
|
70
|
+
DEFAULT_TIMEOUT_MS = 30_000
|
|
71
|
+
DEFAULT_INTERVAL_MS = 500
|
|
72
|
+
# The longest timer Node accepts, kept so both engines refuse the same values.
|
|
73
|
+
MAX_MS = 2_147_483_647
|
|
74
|
+
|
|
75
|
+
# An Exception, not a StandardError, so a block that rescues its own
|
|
76
|
+
# errors cannot swallow the end of its budget.
|
|
77
|
+
class AttemptOver < Exception; end
|
|
78
|
+
|
|
79
|
+
attr_reader :entries #: Array[Hash[Symbol, untyped]]
|
|
80
|
+
|
|
81
|
+
#: () -> void
|
|
82
|
+
def initialize
|
|
83
|
+
@entries = []
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
#: [T] (?description: String?, ?timeout: Numeric?, ?interval: Numeric?) { () -> T? } -> T
|
|
87
|
+
def call(description: nil, timeout: nil, interval: nil, &block)
|
|
88
|
+
raise ArgumentError, "poll needs a block that returns nil until the state exists" unless block
|
|
89
|
+
|
|
90
|
+
timeout_ms = timeout || DEFAULT_TIMEOUT_MS
|
|
91
|
+
seconds = budget(timeout_ms, "timeout")
|
|
92
|
+
pause = budget(interval || DEFAULT_INTERVAL_MS, "interval")
|
|
93
|
+
started = monotonic
|
|
94
|
+
at = Engine.now_iso
|
|
95
|
+
attempts = 0
|
|
96
|
+
outcome = "resolved"
|
|
97
|
+
over = lambda do
|
|
98
|
+
outcome = "timed_out"
|
|
99
|
+
raise PollTimeoutError.new(timeout_ms, description)
|
|
100
|
+
end
|
|
101
|
+
begin
|
|
102
|
+
loop do
|
|
103
|
+
left = seconds - (monotonic - started)
|
|
104
|
+
over.() unless left.positive?
|
|
105
|
+
attempts += 1
|
|
106
|
+
value = begin
|
|
107
|
+
Timeout.timeout(left, AttemptOver) { block.call } #: untyped
|
|
108
|
+
rescue AttemptOver
|
|
109
|
+
over.()
|
|
110
|
+
rescue StandardError
|
|
111
|
+
outcome = "failed"
|
|
112
|
+
raise
|
|
113
|
+
end
|
|
114
|
+
return value unless value.nil?
|
|
115
|
+
|
|
116
|
+
left = seconds - (monotonic - started)
|
|
117
|
+
over.() if left < pause
|
|
118
|
+
sleep(pause)
|
|
119
|
+
end
|
|
120
|
+
ensure
|
|
121
|
+
@entries << { description: description, at: at, attempts: attempts,
|
|
122
|
+
waited_ms: ((monotonic - started) * 1000).round, outcome: outcome }.compact
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
private
|
|
127
|
+
|
|
128
|
+
# The budget in seconds, from milliseconds.
|
|
129
|
+
#: (untyped, String) -> Float
|
|
130
|
+
def budget(value, option)
|
|
131
|
+
# A String or a Complex is not a number of milliseconds, so it reads as NaN.
|
|
132
|
+
number = value.is_a?(Numeric) && value.real? ? (_ = value).to_f : Float::NAN #: Float
|
|
133
|
+
return number / 1000 if number.finite? && number.positive? && number <= MAX_MS
|
|
134
|
+
|
|
135
|
+
raise InvalidPollOptionsError, "poll #{option} must be a finite number of milliseconds greater than 0 and " \
|
|
136
|
+
"at most #{MAX_MS} (got #{value.inspect})"
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
#: () -> Float
|
|
140
|
+
def monotonic = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# `evidence.attach(name, body)` writes a file into the step's own
|
|
144
|
+
# directory, and `evidence.path(name)` gives a path there without
|
|
145
|
+
# writing. A name used twice keeps both files. A name that differs only
|
|
146
|
+
# by case counts as the same, since a case-insensitive volume would put
|
|
147
|
+
# the two on one file.
|
|
148
|
+
class Evidence
|
|
149
|
+
# The files and directories the engine writes into the same directory.
|
|
150
|
+
HARNESS = %w[record.json final.png trace.zip requests.zip http.jsonl mcp.jsonl websocket.jsonl
|
|
151
|
+
program-log.txt program-log-late.txt events.jsonl events-late.jsonl events-read.jsonl judged].freeze
|
|
152
|
+
PROCESS_FILE = /\Aprocess-[1-9][0-9]*\.((stdout|stderr|stdin)\.txt|json)\z/
|
|
153
|
+
NAMED_FILE = /\A(?:trace\.[a-z0-9][a-z0-9-]{0,63}\.zip|final\.[a-z0-9][a-z0-9-]{0,63}\.png)\z/
|
|
154
|
+
MAX_ATTACHMENTS = 100
|
|
155
|
+
|
|
156
|
+
#: (String, ?reserved: Array[String]) -> void
|
|
157
|
+
def initialize(dir, reserved: [])
|
|
158
|
+
@dir = dir
|
|
159
|
+
@reserved = reserved
|
|
160
|
+
@used = (HARNESS + reserved).to_h { [_1.downcase, true] }
|
|
161
|
+
@attached = []
|
|
162
|
+
@paths = []
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
#: (String | Symbol, String) -> nil
|
|
166
|
+
def attach(name, body)
|
|
167
|
+
file = allocate(name.to_s)
|
|
168
|
+
FileUtils.mkdir_p(@dir)
|
|
169
|
+
File.binwrite(File.join(@dir, file), body)
|
|
170
|
+
@attached << { name: name.to_s, file: file, at: Engine.now_iso }
|
|
171
|
+
nil
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
#: (String | Symbol) -> String
|
|
175
|
+
def path(name)
|
|
176
|
+
file = allocate(name.to_s)
|
|
177
|
+
FileUtils.mkdir_p(@dir)
|
|
178
|
+
@paths << { name: name.to_s, file: file }
|
|
179
|
+
File.join(@dir, file)
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
# What the step left: its attachments, and each path it wrote to, by
|
|
183
|
+
# time, at most MAX_ATTACHMENTS of them, with the whole count when
|
|
184
|
+
# there were more.
|
|
185
|
+
#: () -> [Array[Hash[Symbol, String]], Integer?]
|
|
186
|
+
def snapshot
|
|
187
|
+
written = @paths.filter_map do |entry|
|
|
188
|
+
full = File.join(@dir, entry[:file])
|
|
189
|
+
{ **entry, at: File.mtime(full).utc.iso8601(3) } if File.exist?(full)
|
|
190
|
+
end
|
|
191
|
+
# Ruby's sort is not stable, and two files can share a millisecond.
|
|
192
|
+
all = (@attached + written).each_with_index.sort_by { |entry, index| [entry[:at], index] }.map(&:first)
|
|
193
|
+
[all.first(MAX_ATTACHMENTS), all.size > MAX_ATTACHMENTS ? all.size : nil]
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
private
|
|
197
|
+
|
|
198
|
+
#: (String) -> String
|
|
199
|
+
def allocate(name)
|
|
200
|
+
if name.empty? || %w[. ..].include?(name) || name.match?(%r{[/\\]})
|
|
201
|
+
raise InvalidEvidenceNameError, %(evidence name #{name.inspect} is not allowed: it must not contain "/" or "\\", ) +
|
|
202
|
+
%(and must not be ".", "..", or empty. Every attachment and path is written inside this step's own evidence directory.)
|
|
203
|
+
end
|
|
204
|
+
key = name.downcase
|
|
205
|
+
if (HARNESS + @reserved).any? { _1.downcase == key } || key.match?(PROCESS_FILE) || key.match?(NAMED_FILE)
|
|
206
|
+
raise ReservedEvidenceNameError, "evidence name #{name.inspect} is reserved for a file the engine writes itself " \
|
|
207
|
+
"(record.json, final.png, trace.zip, http.jsonl, the program's log lines, the trace.<name>.zip and " \
|
|
208
|
+
"final.<name>.png files of a pageAs context, and the process-<n> files of a run_command). " \
|
|
209
|
+
"A name that differs only by case is reserved too. Choose a different name."
|
|
210
|
+
end
|
|
211
|
+
unless @used.key?(key)
|
|
212
|
+
@used[key] = true
|
|
213
|
+
return name
|
|
214
|
+
end
|
|
215
|
+
dot = name.rindex(".")
|
|
216
|
+
stem, ext = dot&.positive? ? [name[0...dot].to_s, name[dot..].to_s] : [name, ""]
|
|
217
|
+
counter = 2
|
|
218
|
+
counter += 1 while @used.key?("#{stem}-#{counter}#{ext}".downcase)
|
|
219
|
+
candidate = "#{stem}-#{counter}#{ext}"
|
|
220
|
+
@used[candidate.downcase] = true
|
|
221
|
+
candidate
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
end
|
data/lib/nukadoko/summary.rb
CHANGED
|
@@ -451,8 +451,11 @@ module Nukadoko
|
|
|
451
451
|
|
|
452
452
|
by = judgment[:reads].map { _1.dig(:judgment, :by) || "" }.uniq.map { code_span(_1) }.join(", ")
|
|
453
453
|
aria = judgment[:reads].any? { _1[:measured] == "aria-snapshot" } ? "; it is bound to the ARIA snapshot, so a change only to how the page looks keeps it current" : ""
|
|
454
|
+
# Under --base, a judgment the change itself brought is the change
|
|
455
|
+
# judging its own output, which the reviewer reads first.
|
|
456
|
+
added = judgment[:reads].any? { _1.dig(:judgment, :in_base) == false } ? " that this change added" : ""
|
|
454
457
|
{ kind: "judgment", feature: row[:feature], line: row[:line], text: row[:name],
|
|
455
|
-
detail: "stands on a judgment by #{by}: nukadoko checked that the value is the one judged, not the judgment#{aria}" }
|
|
458
|
+
detail: "stands on a judgment by #{by}#{added}: nukadoko checked that the value is the one judged, not the judgment#{aria}" }
|
|
456
459
|
end
|
|
457
460
|
end
|
|
458
461
|
|
data/lib/nukadoko/verdict.rb
CHANGED
|
@@ -17,6 +17,8 @@ module Nukadoko
|
|
|
17
17
|
"working-tree-unknown" => "No change is necessary. In a git repository with a commit, nuka verdict compares the tree with the one the run judged."
|
|
18
18
|
}.freeze
|
|
19
19
|
|
|
20
|
+
TRAILER_KEY = "Nukadoko-Verdict" #: String
|
|
21
|
+
|
|
20
22
|
attr_reader :judged #: String
|
|
21
23
|
attr_reader :findings #: Array[Hash[Symbol, untyped]]
|
|
22
24
|
attr_reader :newest #: Hash[Symbol, untyped]?
|
|
@@ -51,7 +53,22 @@ module Nukadoko
|
|
|
51
53
|
#: () -> Hash[Symbol, untyped]
|
|
52
54
|
def envelope_fields
|
|
53
55
|
{ judged: judged, working_tree: working_tree, run_id: newest&.fetch(:run_id), run_dir: newest&.fetch(:run_dir, nil),
|
|
54
|
-
run_working_tree: newest && recorded, base: newest&.dig(:table, :base) }
|
|
56
|
+
run_working_tree: newest && recorded, base: newest&.dig(:table, :base), trailer: trailer }
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# One git trailer line that stamps a commit with this answer. The tree
|
|
60
|
+
# named is the one the run recorded, so a reader compares it with the
|
|
61
|
+
# commit's own tree later and knows whether the stamp speaks for it.
|
|
62
|
+
#: () -> String
|
|
63
|
+
def trailer
|
|
64
|
+
run = newest or return "#{TRAILER_KEY}: none"
|
|
65
|
+
word = case judged
|
|
66
|
+
when "stale" then "stale"
|
|
67
|
+
when "unknown" then "unknown"
|
|
68
|
+
else open? ? "failed" : "passed"
|
|
69
|
+
end
|
|
70
|
+
tree = recorded
|
|
71
|
+
"#{TRAILER_KEY}: #{word} run #{run[:run_id]}#{" tree #{tree}" if tree}"
|
|
55
72
|
end
|
|
56
73
|
|
|
57
74
|
#: () -> String
|
data/lib/nukadoko/version.rb
CHANGED
data/lib/nukadoko/vocabulary.rb
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# engine's vocabulary without opening a file.
|
|
7
7
|
module Nukadoko
|
|
8
8
|
module Vocabulary
|
|
9
|
-
BROWSER = %i[page context pageAs].freeze
|
|
9
|
+
BROWSER = %i[page context pageAs page_as].freeze
|
|
10
10
|
|
|
11
11
|
#: (singleton(Step), String) -> Hash[Symbol, untyped]
|
|
12
12
|
def self.entry(step, project)
|
data/lib/nukadoko.rb
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
require "json"
|
|
5
5
|
require_relative "nukadoko/version"
|
|
6
6
|
require_relative "nukadoko/project_files"
|
|
7
|
+
require_relative "nukadoko/error_frames"
|
|
7
8
|
require_relative "nukadoko/spaces"
|
|
8
9
|
require_relative "nukadoko/js_pattern"
|
|
9
10
|
require_relative "nukadoko/schema"
|
|
@@ -29,6 +30,7 @@ require_relative "nukadoko/claim_check_run"
|
|
|
29
30
|
require_relative "nukadoko/check"
|
|
30
31
|
require_relative "nukadoko/trace"
|
|
31
32
|
require_relative "nukadoko/trace_actions"
|
|
33
|
+
require_relative "nukadoko/step_fixtures"
|
|
32
34
|
require_relative "nukadoko/fixtures"
|
|
33
35
|
require_relative "nukadoko/http_recording"
|
|
34
36
|
require_relative "nukadoko/secrets"
|
data/llms.txt
CHANGED
|
@@ -30,7 +30,8 @@ The `nukadoko` gem is a second engine that reads the same feature files and judg
|
|
|
30
30
|
- `gem "nukadoko", group: :test` in the Gemfile, then `bundle exec nuka init`: it writes `nukadoko.config.rb`, `features/steps/`, the `.gitignore` entries, and a `scenarios` task in the Rakefile. Run every command as `bundle exec nuka`. It needs Ruby 3.4 or later.
|
|
31
31
|
- A step is a class in `features/steps/<name>.rb` (`add_todo.rb` is `add-todo`): `class AddTodo < Nukadoko::Step` with `pattern`, `description`, `mutates`, `args { string :title, "what it is" }`, `returns { ... }`, `from title: [CreateTodo, :title]`, `parts [...]`, and `def run(request:, args:)`. Field kinds are `string`, `integer`, `number`, `boolean`, `enum`, `strings`, `table`, `object { ... }`, `unknown`, and `field :key, OtherStep.returns[:key]`; `null: true` allows nil.
|
|
32
32
|
- A Then step has `claims [{ actual: "body", compare: "equal", expected: { from: "created" } }]` and `def observe(...)` in place of `run`, with `poll timeout_ms: 3000` when it waits.
|
|
33
|
-
- The keyword arguments of `run` or `observe` name the fixtures, with `args:` only when the body reads them: `request`, `page`, `
|
|
33
|
+
- The keyword arguments of `run` or `observe` name the fixtures, with `args:` only when the body reads them: the TypeScript names (`request`, `page`, `context`, `pageAs`, `env`, `requireEnv`, `baseURL`, `resultOf`, `call`, `section`, `poll`, `evidence`, `scratch`), and each `Nukadoko.fixture(:name) { |use| use.(value) }` in `nukadoko.config.rb`. `base_url`, `require_env`, `page_as`, and `result_of` are snake_case names of the same fixtures. A fixture TypeScript calls is a lambda: `page_as.("aki")`, `section.("paid")`, and `poll.(description: "the order") { value or nil }`. `skills/nukadoko/references/ruby.md` maps each TypeScript shape to its Ruby form.
|
|
34
|
+
- `page`, `context`, and `page_as` give playwright-ruby-client objects. Its `page.wait_for_url` takes a String or a Regexp (a Proc never matches), and `context.expect_page` raises ArgumentError: wait for a tab with `context.expect_event("page") { ... }`.
|
|
34
35
|
- `Nukadoko.run_command(command, args, cwd:, env:, input:, timeout:, redact:)` runs a program and returns `{ exitCode:, signal:, stdout:, stderr: }`, kept in the step record. Its `env` is added to the runner's environment, and `timeout` is in seconds.
|
|
35
36
|
- `Nukadoko.config(program: -> { { serve: { command: "... {port}", ready: "/up" }, environments: { ... } } })` holds the program under test, an environment's own env files under `envFiles:`. A `nukadoko.program.rb` of an earlier release is refused with `program-file-moved`.
|
|
36
37
|
- `Nukadoko.config(envFiles: [".env"], secrets: { public: [...], redact: [...] })` loads env files and classifies their secrets as above.
|
|
@@ -50,7 +51,7 @@ Run them in this order. Exit 0 is the only pass.
|
|
|
50
51
|
- `nuka check [feature..] [--json] [--fail-on <code>] [--env <name>]...`: static checks for the files `nuka run` would select (a file, several, a directory, or every feature with no target), and the program's placeholders for the worlds a `nuka run` with the same `--env` flags would start. Findings are errors, warnings, and notes; a note is rot rather than breakage (an unbound pattern, an unused `from` or fixture, a field with no `.describe()`), and only a check with no target reports notes, because they are facts about every feature the project scans. Exit 1 on any error, or on a code `--fail-on` names (one value per flag, repeatable, or comma-separated; the finding keeps its severity, and `--json` lists the hits in `fail_on_hits`; a note code with targets, which compute no notes, is refused with `fail-on-note-with-targets`); warnings and notes alone exit 0. `nuka check --codes` prints every code `check`, `run`, and a refusal can carry; the table under "Findings" is that list. Condition tags are read against the environments `--env` names, as `nuka run --env` does, or without it the ones a run without `--env` selects: `condition-tag-malformed`, `condition-unknown` (a condition no environment declares), and `condition-unmet` (a scenario no selected environment meets) are errors.
|
|
51
52
|
- `nuka run [feature..] [--no-check] [--env <name>]... [--tag <expression>]... [--concurrency <n>] [--repeat <n>] [--order file|shuffled[:<seed>]] [--proof-runs <n>] [--base <git ref>] [--step] [--records] [--json]`: runs `check` first for the selected scenarios and refuses on an error (`--no-check` runs anyway). `<file>:<line>` runs one scenario. Progress, failures, and the paths it wrote go to stderr (none of them under `--json`); each step's line says `passed`, `failed`, or `skipped`, the word its step record uses. stdout stays empty unless asked: `--records` writes each scenario's `run.json` entry there as one JSON line when it finishes (a step's `program_log_late` is only in `run.json`, written when the world stops), and `--json` prints `run.json` itself, which is the envelope: `run_dir` (the run directory, relative to the project root, the argument `nuka report` takes), `commit` (`sha`, `dirty`, and `working_tree`, the working tree as one git tree id: tracked files as on disk and untracked files `.gitignore` does not leave out, the state directory left out; absent when git gives none), `environments` (each `name`, `target_version`, `base_url`, its world's URL or `null`, and `conditions` when it declares them), `worlds` (each world the run started, with `name`, `tree`, `url`, `commands`, `timings`, `log`, and `error`; empty with no program), `selection` (`partial` when a `:line` target left out a scenario of its file), `order` (`{ kind: "file" }`, or `{ kind: "shuffled", seed }` under `--order shuffled`), `counts` (`scenarios`, `passed`, `failed`, and `stopped` (a walk stopped them, `--step`) of the executions of required cells, `not_run` required cells, `controls` of the executions of controls, and `controls_not_run` control cells), `table` (the verdict table: `base` (`{ ref, commit }` under `--base`, else `null`), `mapping_changed` and `mapping_changes` (`files`, `config`, `conditions`, `default_environments`, `unseen`; `null` without `--base`), `worlds`, its columns `{ world, environment }` with `world` of `head`, `base`, or `old`, `left_out`, the selected criteria `--env` left out, `proof_runs`, the `--proof-runs` a control's `runs` is measured against, and `rows`, one per selected criterion and then one per removed one, with `feature`, `line`, `name`, `change` (`null`, or under `--base` `unchanged`, `changed`, `new`, or `removed`), `renamed_from` (`{ feature, name }` at the base), `retagged` (`true` for an unchanged row whose tags differ from the base's), `conditions` (its condition tags and `@held`), `cells` (each `world`, `environment`, `role` of `required` or `control`, `conditions` (each condition its row's tags name, with the value its environment declares, `null` where none), `outcome` of `pass`, `fail`, `broke`, `stopped`, `flaky`, or `not-run`, the `line` of every one but `pass` and `not-run`, `runs`, for `fail` the `claim` every run broke and `actuals`, each run's actual value, and a `reason` for `not-run`, for a `broke` a hook caused, and for a control `broke` whose proof round could not finish), `verdict` of `held`, `proven`, `removed`, `failed`, `unproven`, or `moved`, `reason`, one sentence, and for a removed row `lines`, its sentences at the base), `flags` (only when a head step's execution events name a flag or a head world's `lists.flags` list declares one: one row per `name` and `side`, a declared side no criterion evaluated included with no `criteria`, each with `listed_in` (each environment whose list declares the side, empty for one no list declares) whenever a flags list was read, and `only_side_evaluated: true` on a flag's one side when the criteria evaluated no other, the side as its lines name it and never as an environment's conditions declare it, with `criteria`, each criterion that evaluated it there with its row's `verdict` and its `cells` on that side (`environment`, `role`, `outcome`, `line`, and `gates`, each gate its lines named or `null`), and `counts` by verdict, where a criterion seen on the side only in controls counts as `controls`; evidence to join with the program's own record of the flag by `name` and `side`, not a verdict on the flag; the summary gives each row one line under "Flags"), `routes` (only when a head world read a `lists.routes` list: one entry per `method` and `route` a list or a head step's `request` line names, `null` for the requests the program matched to no route, ordered by route and then method, with `handlers`, `listed_in` (each environment whose list holds it; empty for a route no list names), `requests` (every `request` line of a head step naming it, a late one included, each line in exactly one entry; 0 for one no step requested), `statuses`, and `criteria` and `counts` by the rules of `flags`, each cell with its `requests` and `statuses`; a request counts the same in a Given as in a Then and says the program matched the route, never that a claim read its answer; the summary's "Routes" names the listed routes no step requested, apart from those whose handler a request reached through another route (PUT and PATCH of one resource), the requests no list names, and each world whose list was not read), `paths` (only when a pair of sides read execution events: under `--base` each environment's base world against its head world, `between: { kind: "base" }`, base pairs first, for the rows the base ran there, which, when both programs name `{events}`, is every row whose head cell there is required and ran (head's `{events}` alone builds the base world for this even when no criterion is new or changed, so a refactor is compared), and two environments whose `conditions` differ in exactly one, `between: { kind: "condition", name, a, b }`; one entry per pair, with the sides `a` and `b` (`world`, `environment`), side `a` being the base world, or the environment where the condition is `false` or not declared, `unread` naming why nothing was compared or `null`, `counts` of `changed`, `open`, `same_so_far` (open, with every open count one range on both sides under the same gap words), `marked_only` (the only differences are on tables marked as bookkeeping or infrastructure; a criterion's `result` reads every other difference), `same`, and `not_compared`, `criteria` with each criterion's `result`, under a base pair `explained_by` on a `changed` one (`criterion_change` when it is new or changed, `null` when it is unchanged and nothing in the feature files asked for the difference), its side executions `a` and `b` (`scenario_record_id`, the cell's `outcome` and `line`), and `steps`, the steps with a difference aligned by line: `ran: "both"` with `changed` and `open` entries, each carrying the range of its count on side `a` and side `b`, and `holds` on a marked table, and `gaps`, or `ran: "a"` or `"b"` for a step only that side ran; a count a side's missing lines could still reach is `open`, never `changed`, a flag's side is the premise of a pair of environments and never compared there, while against the base a flag whose side changed is a difference, and `not_compared` names each criterion left out with a `reason`, such as `did not run at the base`; `unread` says when the base's program names no `{events}`; evidence, not a verdict; the summary lists up to 20 criteria per heading under "Changed paths", every base pair under one `base → head` heading that lists a criterion with the same lines in several environments once, counts the unchanged criteria compared (`Each of the 2 unchanged criteria compared did the same at the base and at head.` when each did), and lists the unchanged criteria that changed first, then the new or changed ones, then those that may differ, each group under a line of its own, and then, under `Bookkeeping and infrastructure writes that differ, which no sentence is about, though another reader of those tables may be:`, the differences with `holds`, which never rank a criterion), `limits` (what the run does not show, computed from the other fields of run.json: `left-out`, `check-skipped`, `control-not-proving` for a held row where no control failed at a Then, `no-claim`, `unmeasured`, `after-record`, `unrecorded-log`, and `unrecorded-events`, each with a `detail` and, where one exists, a `do` or `fix`; the summary renders it under `What this run does not show` right after the table, and stderr ends with one line of counts by kind, `limits: <n> <kind>, ... (run.json limits)`), and per scenario execution its `environment`, `role`, under `--base` the `world` and `row` of a base or old execution, and `for_paths` (`outcome`, and `line` when it did not pass) on a base execution run for `paths` alone, which is no cell, gets no proof runs, never changes the table, and whose stderr line ends `(for paths)`, and steps (each with `line`, `text`, `step`, `status`, `step_record_id`, `record`, `record_unreadable` with a `step-record-unreadable` warning when its step record could not be read back, a claim step's `claims`, `observation`, and `attempts`, and for a failure `error` with `kind` and `message` and the `used` results it read, a result over 4096 bytes of JSON cut to a preview with `truncated` and `result_bytes`), a failed scenario's `do` (a control has none), and every finding the run raised. `run.json` is written to `.nukadoko/runs/<run_id>/run.json` either way, and every path inside it (`record`, `evidence.dir`) is relative to that run directory; there is no scenario record file. The Markdown run summary, rendered from `run.json` alone, is always written beside it and appended to `$GITHUB_STEP_SUMMARY` when that is set; the run writes no Allure results or messages stream. Each failed scenario is a `scenario-failed` finding on stderr whose ` do:` line is the `nuka run <file>:<line>` that reruns it (under `--order shuffled`, which runs the feature files and then each file's scenarios in the order a seed names, with the seed on stderr before the first scenario, in `order`, and in the summary, the line names the scenarios that ran before it in its pass, then it, with `--order shuffled:<seed>`, or is the run itself under `--repeat` or `--concurrency` above 1), and a scenario a walk stopped is a `walk-stopped` one. `--step` walks one scenario with a person: see `nuka step` below. `--env` repeats: `--env a --env b` is one run with one `run_id` that runs every selected scenario in `a`, then in `b`; each environment gets its own env files, secrets, version probe, world, BeforeAll and AfterAll, and process-scope fixtures. A run without `--env` runs the environments the program's `defaultEnvironments` names, or else every environment that declares `conditions`, in the order the file lists them, and `default` when none does; any other, such as a deployment target, runs when `--env` names it. Under `--env`, a scenario no named environment meets is not run: its row is left out of the table, counted in `table.left_out`, in one line on stderr (`<n> criteria not run: their conditions hold in no selected environment`), and as the `left-out` entry of `limits`, and `nuka check` reports `condition-unmet` for the default selection only. `--env default` names the top-level environment (as run.json names it), whether or not the program defines it, so it combines with named ones. The tags `@with:<condition>`, `@with:<condition>=<value>` (exact text; `=true` and `=false` are malformed, write `@with:` or `@without:`), and `@without:<condition>` (off: `false` or not declared) on a Feature, Rule, Scenario, or Examples line make a scenario's cell `required` in an environment that meets them all and a `control` elsewhere; a scenario with none is required everywhere, and `@held` says the base already has the behaviour. `@expects:status=<500-599>`, `@expects:page-error=<name>`, and `@expects:error=<class>` on the same lines accept one failure underneath the scenario: a passed execution whose step got a 5xx response, whose page threw an error nothing caught, or whose trace holds an `error` with `handled: false`, is `broke@<that step's line>` unless a tag names that failure (`unexpected-failure` names it and spells the tag; `expects-unseen` notes a tag that matched nothing); only a pass moves, and like condition tags they are content under `--base`. A cell is `pass`, `fail@<line>` (each execution broke a claim at that line in Then position), `broke@<line>` (each stopped there before a claim was judged: a Given or When error, an undefined line, an unjudged claim; or, at the scenario's line, a hook, which the cell's `reason` names with when it ran), `flaky@<line>` (its executions disagree), `stopped@<line>` (a walk was stopped after the step at that line with `nuka step stop`), or `·` (none ran, with the `reason`). A required cell runs once, or `--repeat` times; a control that failed at a Then line runs again in the same world until it has broken the same claim there `--proof-runs` times (default 2) or a run disagrees (runs agree on the claim, by its position in the step, not on its value, which may differ), each a `proof run <k>/<n>` line on stderr; under `--concurrency` a proof round runs in a worker of its own, which runs BeforeAll and AfterAll again, and a hook that fails there, or a worker that records nothing, makes the round's control cells `broke` with the reason and a `proof-run-incomplete` warning, and the row reads as one no control proves (under `--base`, the base world runs for a new or changed row). A row is `failed` when a required cell is not `pass` or it has no required cell (only under `--no-check` without `--env`, with a `criterion-without-required-cell` finding whose `do:` runs the scenario where it is met, or `nuka check` on its file), `proven` when every required cell passed and a control failed in `--proof-runs` runs, and `held` otherwise. The exit code is 1 when a row is `failed`, `unproven`, or `moved`, or when the run failed outside every scenario: a BeforeAll or AfterAll of a pass failed (at any `--concurrency`), a head world did not start (`program-start-failed`), or a `--concurrency` worker exited before each of its scenarios had a record (`run-incomplete`); a control never makes it red. A `held` row whose control passed says the Then does not see what the switch changes, or the switch does not reach it: read it before calling the criterion covered. The stderr count line counts required cells alone, and a run with a control adds a `<n> control runs, <k> not run` line and a `criteria: <held> held, <proven> proven, <failed> failed` line under it, which every run under `--base` has, with `<unproven> unproven, <moved> moved, <removed> removed` after them. The summary opens with the table, one row per criterion and one `head <environment>` column per environment, headed with the conditions it declares (and `base <environment>` and `old <environment>` under `--base`), then one line per red row with its reason and where it stopped; a failure's `do:` names its environment. Naming one environment twice is refused. `--base <git ref>` compares each criterion with the commit the ref names: its identity is its feature file and name, and its content its steps with their effective keyword, docstrings, and tables, its Examples row, and its condition tags and `@held`, so a rename, a move, or another tag leaves it `unchanged` (with `renamed_from` when its name or file differs, and `retagged` when its tags differ) and an edit makes it `changed`; the rest are `new` or `removed`. The mapping (files under the features directory other than `.feature` files, the whole config but `stateDir` and `retention`, by its value and by the config file's own bytes, so a constant a config function closes over counts and an edit to those two fields alone does too, and each environment's `conditions` and `defaultEnvironments`) is compared as one unit. A `new` or `changed` row that passed at head also runs in the `base` world (the base's code under head's criteria and mapping, built from the base's program in `trees/base` under the run directory), where a base cell proves like a control after `--proof-runs` failures at one Then line; it is `proven` then, `unproven` (red) when nothing proves it (a compat Then never can, and the reason says so), and a row tagged `@held` is `held` when the base passes it. An `unchanged` row that passed at head runs in the `old` world (head's code under the base's feature files and mapping, in `trees/old`) when the mapping changed or the row is retagged or renamed, and is `moved` (red) when it does not pass there, or else `proven` when a control proves it, as without `--base`, and `held` when none does. Each `unproven` or `moved` row is a `criterion-unproven` or `criterion-moved` finding whose `do:` is `nuka run <file>:<line> --base <commit>`, naming the full hash the ref resolved to, which judges it again against the same commit after the ref moves. `--base` does not support yet a symbolic link at, above, or under the features directory or at the config file, a feature file outside the features directory, a submodule or a nested repository, or, for the base world alone, a workspace package linked into `node_modules` from inside the repository: the world such a shape reaches is not built, its cells are `·` with the reason, and a red row's finding has a `do:` that runs the row without `--base` and a `fix:` when an edit lets `--base` build the world; a shape that hides part of the mapping is named in `mapping_changes.unseen` and makes `mapping_changed` true. A criterion only the base holds is a `removed` row, quoted under the summary's "Removed criteria". The trees install nothing and resolve packages from head's project; a `url` function receives `tree` (`"base"` or `"head"`) and may return nothing for the base, and one that returns head's URL for the base leaves the base world not run, so it has to branch on `tree`. A tree whose cells do not run says why on stderr, `<world> <environment> not run: <reason>`. The summary opens with a line naming the base and what changed. A project outside git is refused with `base-outside-git`, a ref that names no commit with `base-ref-unknown`, a shallow clone without it with `base-shallow` (its `do` is the `git fetch`), a git failure with `base-git-failed`, and a `featuresDir` at the project root with `base-features-at-root`; `--since` is refused with `removed-flag`.
|
|
52
53
|
- `nuka report [<run dir>] --format markdown|allure|messages [--out <path>] [--json]`: renders one finished run from its run directory alone, so a run directory copied off a CI machine renders too: `markdown` reads `run.json` alone, and `allure` and `messages` read `run.json`, the step records, and `sources.json`, the feature text the run parsed. With no run dir it renders the newest run. `markdown` is the run summary, on stdout or to `--out` (the file a CI step posts as a pull request comment); `allure` writes Allure 2 format results to `.nukadoko/export/allure-results/` or the directory `--out` names; `messages` is a cucumber-messages NDJSON stream on stdout or to `--out`, where a run over several environments gives each environment its own pickle, named `<scenario> (<environment>)`, and every execution of a control is left out, so a JUnit report of a green run is green; Allure keeps each control with the status it ran to, named `<scenario> (control)` with a `role` label, so a control that failed is a failed result there by design, and a CI gates on `nuka run`'s exit code. A file written under `.nukadoko/export/` is noted in the run's exports manifest, so retention removes it with the run, and rendering the same run there again replaces it; a file written anywhere else is not noted, and stays unless it sits inside a run directory that is removed. `--json` prints the envelope with `run_id`, `format`, and `written`, and needs `--out` for `markdown` and `messages`. A directory with no `run.json` is refused with `run-not-found`, and one whose `run.json` this release does not read with `run-invalid`; for `allure` and `messages`, one with no `sources.json` (a run from an earlier release) is refused with `run-sources-missing`, and one whose `sources.json` is corrupt or of another version with `run-sources-invalid`. A missing directory on the way to `--out` is created; anything else in the way (a directory where a file goes, a file where the Allure directory goes, a FIFO, a dangling symbolic link, a path under a regular file, or `allure-history.jsonl` in the export directory in any letter case) is refused with `report-out-invalid` before the run is read, and so is a markdown or messages file the file system refuses to write, with its error code; an Allure directory the file system refuses to write into ends as `report-incomplete`. A render that left out part of the run (a scenario, a step record, or an attachment it could not read) writes the rest and exits 1 with `report-incomplete`; a step whose step record is gone is never shown passed.
|
|
53
|
-
- `nuka verdict [--json]`: before you say a change is done. It reads the newest run that ended and never starts one, and exits 1 when no run ended (`run-missing`), the newest run judged another working tree (`run-stale`: a file git counts changed after it started), it ran part of its files or was a walk (`run-partial`), or it left something red (its own failed findings, relayed as it printed them). A pass says that run judged exactly this tree and left nothing red; it does not say the change has a criterion of its own. Notes: `run-without-base`, `criteria-unchanged` (under `--base`, no criterion is new or changed), `working-tree-unknown` (outside git or before the first commit, where the verdict is the run's own). `--json` adds `judged` (`missing`, `stale`, `judged`, `unknown`), `working_tree`, `run_id`, `run_dir`, `run_working_tree`, and `
|
|
54
|
+
- `nuka verdict [--json] [--trailer]`: before you say a change is done. It reads the newest run that ended and never starts one, and exits 1 when no run ended (`run-missing`), the newest run judged another working tree (`run-stale`: a file git counts changed after it started), it ran part of its files or was a walk (`run-partial`), or it left something red (its own failed findings, relayed as it printed them). A pass says that run judged exactly this tree and left nothing red; it does not say the change has a criterion of its own. Notes: `run-without-base`, `criteria-unchanged` (under `--base`, no criterion is new or changed), `working-tree-unknown` (outside git or before the first commit, where the verdict is the run's own). `--json` adds `judged` (`missing`, `stale`, `judged`, `unknown`), `working_tree`, `run_id`, `run_dir`, `run_working_tree`, `base`, and `trailer`. `--trailer` prints only that trailer, one git trailer line that stamps a commit (`Nukadoko-Verdict: passed run <run_id> tree <tree id>`; `failed`, `stale`, `none` when no run ended, or `unknown` when git gave no tree id; the tree is the one the run recorded, so compare it with `git rev-parse <commit>^{tree}`), and exits 0 whatever it says: it observes, and the plain command blocks. `skills/nukadoko/scripts/claude-code-verdict-hook.mjs` is an opt-in Claude Code hook that asks for it at the end of a turn that changed the tree.
|
|
54
55
|
- `nuka judge <feature:line> [--run <run-id>] [--meets|--misses --by <name> --because <sentence>] [--json]`: when a run leaves a judgment `pending` or `stale`. A Then with a `judged-as` claim asks for a judgment no compare can give (whether a text reads as friendly); the run reads the value and judges nothing. Without a verdict flag it shows each value, the quality the sentence names, its digest, its step record, and the judged view. With `--meets` or `--misses`, `--by`, and `--because` it records one judgment per value in `judgments/<feature path>.json`, which you commit. The judge is not the agent that wrote the change. A row whose judgment is not `judged` fails the run (`judgment-pending`, `judgment-stale`, `judgment-misses`, `judgment-uncitable`); the verdict column is never changed by a judgment.
|
|
55
56
|
|
|
56
57
|
Exploring one step at a time, when the path is not known yet:
|
|
@@ -14,8 +14,11 @@ module Nukadoko
|
|
|
14
14
|
# no exit code to read. `input` (or `stdin`) is written to the program's
|
|
15
15
|
# stdin. `redact` names secrets the step holds itself, which the record
|
|
16
16
|
# writes as `{{secret.NAME}}` while the program still gets the real value.
|
|
17
|
-
# :
|
|
18
|
-
|
|
17
|
+
# `unbundled: true` runs the command with the environment from before
|
|
18
|
+
# Bundler set up nuka (no BUNDLE_GEMFILE, no -rbundler/setup in RUBYOPT),
|
|
19
|
+
# for a command in another Ruby project, which has a Gemfile of its own.
|
|
20
|
+
# : (String, ?Array[String], ?cwd: String, ?env: Hash[String | Symbol, String], ?input: String?, ?stdin: String?, ?timeout: Numeric?, ?redact: Hash[String | Symbol, String], ?files: bool, ?unbundled: bool) -> Hash[Symbol, untyped]
|
|
21
|
+
def self.run_command: (String, ?Array[String], ?cwd: String, ?env: Hash[String | Symbol, String], ?input: String?, ?stdin: String?, ?timeout: Numeric?, ?redact: Hash[String | Symbol, String], ?files: bool, ?unbundled: bool) -> Hash[Symbol, untyped]
|
|
19
22
|
|
|
20
23
|
module Engine
|
|
21
24
|
# The processes the running step started, kept per thread so a step
|
|
@@ -32,9 +35,15 @@ module Nukadoko
|
|
|
32
35
|
# : () -> bool
|
|
33
36
|
def self.groups?: () -> bool
|
|
34
37
|
|
|
38
|
+
# `env` on top of the environment Bundler found when it set up nuka:
|
|
39
|
+
# each variable Bundler added is unset and each one it changed is put
|
|
40
|
+
# back. Without Bundler loaded there is nothing to undo.
|
|
41
|
+
# : (Hash[String, String?]) -> Hash[String, String?]
|
|
42
|
+
def self.unbundled: (Hash[String, String?]) -> Hash[String, String?]
|
|
43
|
+
|
|
35
44
|
# Runs the command to its close, its stdin closed after `input`.
|
|
36
|
-
# : (Hash[String, String], Array[String], String, String?, Numeric?, group: bool) -> [String, String, Process::Status, bool?]
|
|
37
|
-
def self.spawn: (Hash[String, String], Array[String], String, String?, Numeric?, group: bool) -> [ String, String, Process::Status, bool? ]
|
|
45
|
+
# : (Hash[String, String?], Array[String], String, String?, Numeric?, group: bool) -> [String, String, Process::Status, bool?]
|
|
46
|
+
def self.spawn: (Hash[String, String?], Array[String], String, String?, Numeric?, group: bool) -> [ String, String, Process::Status, bool? ]
|
|
38
47
|
|
|
39
48
|
# `ended` when no process of the group still runs as the leader closed.
|
|
40
49
|
# : (Integer) -> String
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Generated from lib/nukadoko/error_frames.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
# Where a step's own code raised, as the project's own frames of the
|
|
4
|
+
# backtrace. A step record's error message says what went wrong but not
|
|
5
|
+
# where, so a reader had to call the step again outside nukadoko to find the
|
|
6
|
+
# line. The frames kept are the ones a reader can open and change: inside
|
|
7
|
+
# the project root, and outside the gem and any installed bundle, as the
|
|
8
|
+
# TypeScript engine leaves out node_modules.
|
|
9
|
+
module Nukadoko
|
|
10
|
+
module Engine
|
|
11
|
+
module ErrorFrames
|
|
12
|
+
# The first few frames are where the code was when it raised; the rest
|
|
13
|
+
# is the call chain a reader rarely needs.
|
|
14
|
+
MAX: ::Integer
|
|
15
|
+
|
|
16
|
+
GEM_ROOT: untyped
|
|
17
|
+
|
|
18
|
+
# Each frame as `path:line` relative to `root`, in backtrace order,
|
|
19
|
+
# without repeats.
|
|
20
|
+
# : (Exception, String) -> Array[String]
|
|
21
|
+
def self?.of: (Exception, String) -> Array[String]
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -31,8 +31,15 @@ module Nukadoko
|
|
|
31
31
|
class Request
|
|
32
32
|
attr_reader log: Array[Hash[Symbol, untyped]]
|
|
33
33
|
|
|
34
|
-
#
|
|
35
|
-
|
|
34
|
+
# `base_url` is the world's URL, which a path joins onto; a project with
|
|
35
|
+
# no program has none. An absolute URL, http or https, goes where it
|
|
36
|
+
# names, so a step can call a third-party API and still have its
|
|
37
|
+
# requests recorded.
|
|
38
|
+
# : (String?) -> void
|
|
39
|
+
def initialize: (String?) -> void
|
|
40
|
+
|
|
41
|
+
# : (String) -> URI::Generic
|
|
42
|
+
def target: (String) -> URI::Generic
|
|
36
43
|
|
|
37
44
|
BODY_TEXT: untyped
|
|
38
45
|
|
|
@@ -75,6 +82,9 @@ module Nukadoko
|
|
|
75
82
|
# : (untyped, String, Float, ?caret: String?, ?bounded: bool) -> bool
|
|
76
83
|
def masked_shot: (untyped, String, Float, ?caret: String?, ?bounded: bool) -> bool
|
|
77
84
|
|
|
85
|
+
# : () -> untyped
|
|
86
|
+
def launch: () -> untyped
|
|
87
|
+
|
|
78
88
|
# : (String, Array[Hash[Symbol, untyped]]) -> [untyped, ^() -> void]
|
|
79
89
|
def page_for: (String, Array[Hash[Symbol, untyped]]) -> [ untyped, ^() -> void ]
|
|
80
90
|
|
|
@@ -168,6 +178,32 @@ module Nukadoko
|
|
|
168
178
|
# : (?String?) -> Array[Hash[Symbol, untyped]]
|
|
169
179
|
def end_scenario: (?String?) -> Array[Hash[Symbol, untyped]]
|
|
170
180
|
|
|
181
|
+
CONTEXT_NAME: ::Regexp
|
|
182
|
+
|
|
183
|
+
# The page of a browser context of its own, named `name`, so a second
|
|
184
|
+
# person in the scenario has cookies and storage of their own. The
|
|
185
|
+
# context opens on the first call for the name in the scenario, with
|
|
186
|
+
# `options` over the world's base URL, and a later call gets the same
|
|
187
|
+
# page. Each step that calls it gets a trace chunk, trace.<name>.zip,
|
|
188
|
+
# and the page's requests go to the step's log with `as`.
|
|
189
|
+
# : (String, Hash[untyped, untyped]?, String, Array[Hash[Symbol, untyped]]) -> untyped
|
|
190
|
+
def page_as: (String, Hash[untyped, untyped]?, String, Array[Hash[Symbol, untyped]]) -> untyped
|
|
191
|
+
|
|
192
|
+
# Ends the step's chunk of each named context it reached, and names
|
|
193
|
+
# the files, in the order the contexts opened.
|
|
194
|
+
# : () -> Array[Hash[Symbol, String]]
|
|
195
|
+
def finish_named: () -> Array[Hash[Symbol, String]]
|
|
196
|
+
|
|
197
|
+
private
|
|
198
|
+
|
|
199
|
+
# : () -> Hash[String, Hash[Symbol, untyped]]
|
|
200
|
+
def named: () -> Hash[String, Hash[Symbol, untyped]]
|
|
201
|
+
|
|
202
|
+
# : () -> Hash[String, [String, untyped]]
|
|
203
|
+
def step_named: () -> Hash[String, [ String, untyped ]]
|
|
204
|
+
|
|
205
|
+
public
|
|
206
|
+
|
|
171
207
|
# : () -> void
|
|
172
208
|
def close: () -> void
|
|
173
209
|
end
|
|
@@ -34,6 +34,12 @@ module Nukadoko
|
|
|
34
34
|
# root and sorted. nil when git does not answer.
|
|
35
35
|
# : (String, String) -> Array[String]?
|
|
36
36
|
def self?.changed: (String, String) -> Array[String]?
|
|
37
|
+
|
|
38
|
+
# What `commit` holds as the judgments of a feature file: its
|
|
39
|
+
# entries, none when it holds no such file, or why the file did not
|
|
40
|
+
# parse. nil when git does not answer.
|
|
41
|
+
# : (String, String, String) -> Hash[Symbol, untyped]?
|
|
42
|
+
def self?.at_commit: (String, String, String) -> Hash[Symbol, untyped]?
|
|
37
43
|
end
|
|
38
44
|
end
|
|
39
45
|
end
|
|
@@ -89,6 +89,16 @@ module Nukadoko
|
|
|
89
89
|
# : (Array[Hash[Symbol, untyped]], Array[Hash[Symbol, untyped]], ^(String) -> Array[Hash[Symbol, untyped]]) -> Array[Hash[Symbol, untyped]]
|
|
90
90
|
def self?.with_judgments: (Array[Hash[Symbol, untyped]], Array[Hash[Symbol, untyped]], ^(String) -> Array[Hash[Symbol, untyped]]) -> Array[Hash[Symbol, untyped]]
|
|
91
91
|
|
|
92
|
+
# Under --base, each judgment a read cites gains `in_base`: true when
|
|
93
|
+
# the base's file already held that very judgment (the same claim,
|
|
94
|
+
# value, verdict, judge, reason, and time), false when the change
|
|
95
|
+
# brought it. A change cannot be trusted to judge its own output any
|
|
96
|
+
# more than to rewrite its own Thens, and the old world covers only
|
|
97
|
+
# the Thens. `base_entries_of` answers nil for a feature whose base
|
|
98
|
+
# file could not be read, and its reads stay unmarked.
|
|
99
|
+
# : (Array[Hash[Symbol, untyped]], ^(String) -> Array[Hash[Symbol, untyped]]?) -> Array[Hash[Symbol, untyped]]
|
|
100
|
+
def self?.with_base_judgments: (Array[Hash[Symbol, untyped]], ^(String) -> Array[Hash[Symbol, untyped]]?) -> Array[Hash[Symbol, untyped]]
|
|
101
|
+
|
|
92
102
|
# : (Array[Hash[Symbol, untyped]]) -> bool
|
|
93
103
|
def self?.open?: (Array[Hash[Symbol, untyped]]) -> bool
|
|
94
104
|
|
|
@@ -236,8 +236,8 @@ module Nukadoko
|
|
|
236
236
|
|
|
237
237
|
# A project fixture is built the first time a step of its scope names
|
|
238
238
|
# it, directly or through another fixture, and kept until the scope ends.
|
|
239
|
-
# : (Symbol, World, Array[Symbol]) -> untyped
|
|
240
|
-
def project_fixture: (Symbol, World, Array[Symbol]) -> untyped
|
|
239
|
+
# : (Symbol, World, Array[Symbol], ?(^(Symbol) -> untyped)?) -> untyped
|
|
240
|
+
def project_fixture: (Symbol, World, Array[Symbol], ?(^(Symbol) -> untyped)?) -> untyped
|
|
241
241
|
|
|
242
242
|
# Each project fixture a step's bag touched, once, as the step record
|
|
243
243
|
# lists it: built here with its setup time, or reused from its scope.
|
|
@@ -258,8 +258,29 @@ module Nukadoko
|
|
|
258
258
|
# : (Environment) -> void
|
|
259
259
|
def read_env: (Environment) -> void
|
|
260
260
|
|
|
261
|
-
|
|
262
|
-
|
|
261
|
+
BUILTINS: untyped
|
|
262
|
+
|
|
263
|
+
# The snake_case spelling of each builtin a Ruby step may name instead,
|
|
264
|
+
# so a body passes RuboCop's naming cops. Both reach the same fixture.
|
|
265
|
+
ALIASES: untyped
|
|
266
|
+
|
|
267
|
+
# : (singleton(Step), String, Array[Hash[Symbol, untyped]], World, Hash[Symbol, untyped], Array[untyped]) -> [Hash[Symbol, untyped], (^() -> void)?]
|
|
268
|
+
def build_fixtures: (singleton(Step), String, Array[Hash[Symbol, untyped]], World, Hash[Symbol, untyped], Array[untyped]) -> [ Hash[Symbol, untyped], (^() -> void)? ]
|
|
269
|
+
|
|
270
|
+
# requireEnv: the env fixture's value for a key, or a raise that names
|
|
271
|
+
# only the key. An empty value counts as missing, since a step that
|
|
272
|
+
# requires it is broken either way. Every name asked for is kept, in
|
|
273
|
+
# the order asked, whether the read found a value or not.
|
|
274
|
+
# : (World, Hash[Symbol, untyped]) -> ^(String | Symbol) -> String
|
|
275
|
+
def require_env: (World, Hash[Symbol, untyped]) -> ^(String | Symbol) -> String
|
|
276
|
+
|
|
277
|
+
# resultOf: the result an earlier step of the scenario last gave when
|
|
278
|
+
# it passed, or nil when it has not. A claim step takes an earlier
|
|
279
|
+
# value through `from` alone, so its record names where the value
|
|
280
|
+
# came from. A read that found a result names its step in `used`, as
|
|
281
|
+
# a from key does.
|
|
282
|
+
# : (singleton(Step), Array[untyped], Hash[Symbol, untyped]) -> ^(untyped) -> untyped
|
|
283
|
+
def result_of: (singleton(Step), Array[untyped], Hash[Symbol, untyped]) -> ^(untyped) -> untyped
|
|
263
284
|
|
|
264
285
|
# : (String) -> String
|
|
265
286
|
def new_id: (String) -> String
|