specguard-ruby 0.3.35 → 0.3.36
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/specguard/client/delivery_warning.rb +4 -2
- data/lib/specguard/client/sink_writer.rb +53 -0
- data/lib/specguard/minitest/reporter.rb +10 -13
- data/lib/specguard/rspec/formatter.rb +26 -43
- data/lib/specguard/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 991575484b52a572f28efefb1ec0c7410f050fd34e2b7b9cb651ba945897b926
|
|
4
|
+
data.tar.gz: ba8c38cc1541f1a32e15c546e4a264b4c03549c1ee147fb9e7468facb8fc10bd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 35bffa2fbd23ed02c04a4e3309d7139066dca7574e47965d5d099a5c714d9eb9747605a8f5c9048826c1021e6035d95b2cfbb89b122bf45d5ed66b83df98b976
|
|
7
|
+
data.tar.gz: 1f114f41b076bdc7fd3e9c28da71967964f6c26f7209d9ed8d5b091460554576cbf41fddb4825ef7e6f016eb8fe2846386165a3c63267d78dbe79a3b40b8db47
|
|
@@ -13,8 +13,10 @@ module SpecGuard
|
|
|
13
13
|
# wording change cannot reach one client and miss the other.
|
|
14
14
|
#
|
|
15
15
|
# What stays in each client: the prefix, the warning budget (`@warned`),
|
|
16
|
-
# and
|
|
17
|
-
#
|
|
16
|
+
# and what it does with the answer of the shared write ({SinkWriter}) —
|
|
17
|
+
# whether `error` is nil, and which sentence that earns. The write itself
|
|
18
|
+
# no longer differs between the clients; what each does with its answer
|
|
19
|
+
# does, by design. Only the clause text is shared here.
|
|
18
20
|
module DeliveryWarning
|
|
19
21
|
module_function
|
|
20
22
|
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
require "fileutils"
|
|
5
|
+
|
|
6
|
+
module SpecGuard
|
|
7
|
+
module Client
|
|
8
|
+
# The local JSON-line sink writer shared by the two framework clients'
|
|
9
|
+
# sinks: the RSpec formatter's replay queue and local development record,
|
|
10
|
+
# and the Minitest reporter's (see {Configuration#output_path} and
|
|
11
|
+
# {Configuration#local_output_path}). One definition here means the write
|
|
12
|
+
# — the guarded `mkdir_p`, the single append-mode write of the full line,
|
|
13
|
+
# the exception-as-value contract — cannot drift between the two clients,
|
|
14
|
+
# which hand-copied it until SPGD-2124 and had already been co-edited in
|
|
15
|
+
# separate commits (SPGD-1413).
|
|
16
|
+
#
|
|
17
|
+
# What stays in each client: which sink the run warrants (`#deliver`
|
|
18
|
+
# decides), and what each does with the write's answer — the formatter's
|
|
19
|
+
# fall-back folds it into the delivery line its budget is already spent
|
|
20
|
+
# on, the reporter's keyless branch names the configured path in its own
|
|
21
|
+
# line. The write itself is shared.
|
|
22
|
+
module SinkWriter
|
|
23
|
+
module_function
|
|
24
|
+
|
|
25
|
+
# Appends one line to `path`. Opened in append mode and written with a
|
|
26
|
+
# single call so that two suites sharing an output path (parallel CI
|
|
27
|
+
# shards, say) interleave whole runs rather than halves of one.
|
|
28
|
+
#
|
|
29
|
+
# `path` is passed in rather than read here, so the line a client's
|
|
30
|
+
# fall-back composes and the file it describes are provably the same
|
|
31
|
+
# string — a second read of a process-wide singleton could answer
|
|
32
|
+
# differently and name a path nothing was written to.
|
|
33
|
+
#
|
|
34
|
+
# Returns the exception the write died of, or `nil` when it landed,
|
|
35
|
+
# rather than warning itself or raising — the clients need the outcome
|
|
36
|
+
# *in* their own sentence, and a raise here could not be folded into
|
|
37
|
+
# one: it would fall through to a client's generic handler and spend
|
|
38
|
+
# the run's one warning budget on a sentence this module's answer was
|
|
39
|
+
# meant to replace (SPGD-1413). `Interrupt` stays deliberately outside
|
|
40
|
+
# the clause, as everywhere else in these files: Ctrl-C must stay
|
|
41
|
+
# Ctrl-C.
|
|
42
|
+
def append(data, path)
|
|
43
|
+
directory = File.dirname(path)
|
|
44
|
+
FileUtils.mkdir_p(directory) unless directory == "." || File.directory?(directory)
|
|
45
|
+
|
|
46
|
+
File.open(path, "a") { |file| file.write("#{JSON.generate(data)}\n") }
|
|
47
|
+
nil
|
|
48
|
+
rescue ScriptError, StandardError => e
|
|
49
|
+
e
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "json"
|
|
4
|
-
require "fileutils"
|
|
5
|
-
|
|
6
3
|
# Configuration and Transport are the framework-free halves of the client
|
|
7
4
|
# (env resolution, wire delivery, the never-raise contract), under
|
|
8
5
|
# `SpecGuard::Client`. Required here rather than assumed because nothing else
|
|
@@ -10,6 +7,7 @@ require "fileutils"
|
|
|
10
7
|
require_relative "../client"
|
|
11
8
|
require_relative "../client/configuration"
|
|
12
9
|
require_relative "../client/delivery_warning"
|
|
10
|
+
require_relative "../client/sink_writer"
|
|
13
11
|
|
|
14
12
|
# The annotation lookup is the third framework-free half: what counts as a
|
|
15
13
|
# test's annotation is a property of the source line, not of the framework
|
|
@@ -350,21 +348,20 @@ module SpecGuard
|
|
|
350
348
|
# One JSON run per line, to whichever file this delivery's outcome
|
|
351
349
|
# warrants (see `#deliver` for which and why).
|
|
352
350
|
#
|
|
353
|
-
#
|
|
354
|
-
#
|
|
355
|
-
#
|
|
351
|
+
# A one-line delegation to {SpecGuard::Client::SinkWriter.append}, the
|
|
352
|
+
# write both clients share (this reporter carried a hand-copy of it, and
|
|
353
|
+
# the RSpec formatter the second, until SPGD-2124). It returns the
|
|
354
|
+
# exception the write died of, or `nil` when it landed, rather than
|
|
355
|
+
# warning itself. Both call sites need the outcome *in* their own
|
|
356
|
+
# sentence — the keyless branch has no preceding line and says so
|
|
356
357
|
# directly, the fall-back folds it into the delivery line it is already
|
|
357
358
|
# spending the run's one warning on — and a warning here would reach
|
|
358
359
|
# `warn_once` first on the fall-back path and spend that budget on the
|
|
359
360
|
# generic write message, losing the HTTP status the operator needs
|
|
360
|
-
# (SPGD-1413). `Interrupt` stays outside the clause, as
|
|
361
|
-
# in this class.
|
|
361
|
+
# (SPGD-1413). `Interrupt` stays outside the writer's clause, as
|
|
362
|
+
# everywhere else in this class.
|
|
362
363
|
def append(data, path)
|
|
363
|
-
|
|
364
|
-
File.open(path, "a") { |f| f.puts(JSON.generate(data)) }
|
|
365
|
-
nil
|
|
366
|
-
rescue ScriptError, StandardError => e
|
|
367
|
-
e
|
|
364
|
+
SpecGuard::Client::SinkWriter.append(data, path)
|
|
368
365
|
end
|
|
369
366
|
|
|
370
367
|
# The keyless branch's write, and its own warning. Nothing preceded it on
|
|
@@ -37,8 +37,6 @@
|
|
|
37
37
|
# directions.
|
|
38
38
|
require "rspec/core"
|
|
39
39
|
require "rspec/core/formatters/base_formatter"
|
|
40
|
-
require "json"
|
|
41
|
-
require "fileutils"
|
|
42
40
|
|
|
43
41
|
# `specguard/rspec` is what defines `SpecGuard::RSpec` — the namespace whose
|
|
44
42
|
# existence is the shadowing hazard documented below, and the home of the
|
|
@@ -49,6 +47,7 @@ require_relative "../rspec"
|
|
|
49
47
|
require_relative "../client/configuration"
|
|
50
48
|
require_relative "../client/transport"
|
|
51
49
|
require_relative "../client/delivery_warning"
|
|
50
|
+
require_relative "../client/sink_writer"
|
|
52
51
|
require_relative "../client/path_root"
|
|
53
52
|
require_relative "../client/root_binding"
|
|
54
53
|
# Brings the linter's discovery chain with it (Scanner, Finding, Schema). That
|
|
@@ -742,12 +741,14 @@ module SpecGuard
|
|
|
742
741
|
# Called from inside {#never_fail_the_run}, so a raise below it cannot
|
|
743
742
|
# fail the run — but neither arm leaves its failure to that generic
|
|
744
743
|
# envelope, because each spends the run's one warning on a line that has
|
|
745
|
-
# to say what actually happened. {#append}
|
|
746
|
-
#
|
|
747
|
-
#
|
|
748
|
-
#
|
|
749
|
-
#
|
|
750
|
-
#
|
|
744
|
+
# to say what actually happened. {#append} hands the sink's outcome back
|
|
745
|
+
# as a value — the write and its rescue live in {Client::SinkWriter},
|
|
746
|
+
# shared with the Minitest reporter (SPGD-2124) — so the one line
|
|
747
|
+
# {#fall_back} is spending can report whether the queue took the run
|
|
748
|
+
# rather than promise it (SPGD-1413); the keyless {#append_local} does
|
|
749
|
+
# the same and names the configured sink path in the line it emits, the
|
|
750
|
+
# way the Minitest twin does (SPGD-1400). Nothing raises out of either
|
|
751
|
+
# way.
|
|
751
752
|
#
|
|
752
753
|
# == Why a failure writes the file rather than shrugging
|
|
753
754
|
#
|
|
@@ -866,7 +867,7 @@ module SpecGuard
|
|
|
866
867
|
# whose accessors are `commit_sha`, `branch`, `run_id`, `shard_id`,
|
|
867
868
|
# `output_path`, `endpoint`, `api_key` and `timeout`, and which has no
|
|
868
869
|
# `dry_run?`. Note that four methods here — {#payload}, {#deliver},
|
|
869
|
-
# {#
|
|
870
|
+
# {#fall_back} and {#append_local} — legitimately call
|
|
870
871
|
# `SpecGuard::RSpec.configuration` for this gem's own settings, so both
|
|
871
872
|
# spellings appear in this file and mean different things.
|
|
872
873
|
#
|
|
@@ -1188,26 +1189,15 @@ module SpecGuard
|
|
|
1188
1189
|
"#{relative_path(rerun)}#{id[rerun.length..]}"
|
|
1189
1190
|
end
|
|
1190
1191
|
|
|
1191
|
-
# Appends one line to the replay queue
|
|
1192
|
-
#
|
|
1193
|
-
#
|
|
1194
|
-
#
|
|
1195
|
-
# `
|
|
1196
|
-
#
|
|
1197
|
-
#
|
|
1198
|
-
# a path nothing was written to.
|
|
1199
|
-
#
|
|
1200
|
-
# Returns the exception the write died of, or `nil` when it landed — the
|
|
1201
|
-
# fall-back's one line is composed from that answer (see {#fall_back}), and
|
|
1202
|
-
# a raise here could not be, because `close`'s {#never_fail_the_run} would
|
|
1203
|
-
# only reach a warning budget the delivery message has already spent.
|
|
1204
|
-
# `Interrupt` is deliberately outside the clause, as everywhere else in this
|
|
1205
|
-
# file: Ctrl-C must stay Ctrl-C.
|
|
1192
|
+
# Appends one line to the replay queue — a one-line delegation to
|
|
1193
|
+
# {Client::SinkWriter.append}, the write both clients share (the
|
|
1194
|
+
# formatter carried a hand-copy of it until SPGD-2124, and the Minitest
|
|
1195
|
+
# reporter carried the second one). The return contract — the exception
|
|
1196
|
+
# as a value, `nil` on success, `Interrupt` outside the clause — lives on
|
|
1197
|
+
# the module now; what stays here is what this client does with the
|
|
1198
|
+
# answer, folding it into the fall-back's one line (see {#fall_back}).
|
|
1206
1199
|
def append(data, path)
|
|
1207
|
-
|
|
1208
|
-
nil
|
|
1209
|
-
rescue ScriptError, StandardError => e
|
|
1210
|
-
e
|
|
1200
|
+
Client::SinkWriter.append(data, path)
|
|
1211
1201
|
end
|
|
1212
1202
|
|
|
1213
1203
|
# The keyless branch's sink: `local_output_path`, a local development
|
|
@@ -1216,14 +1206,14 @@ module SpecGuard
|
|
|
1216
1206
|
# failed deliveries. See {Configuration#local_output_path}.
|
|
1217
1207
|
#
|
|
1218
1208
|
# Its failure is its own line rather than {#never_fail_the_run}'s generic
|
|
1219
|
-
# substitute: the path is knowable here — read once into a local,
|
|
1220
|
-
#
|
|
1221
|
-
# same input (SPGD-1400), as does this file's delivery arm
|
|
1222
|
-
# {#sink_clause} (SPGD-1413). The write goes through {#append} so
|
|
1223
|
-
# exception comes back as a value to compose the line from; left to
|
|
1224
|
-
# it would fall through to {#never_fail_the_run} and spend the
|
|
1225
|
-
# warning on the one sentence this exists to replace.
|
|
1226
|
-
# outside, as everywhere else in this file.
|
|
1209
|
+
# substitute: the path is knowable here — read once into a local, so the
|
|
1210
|
+
# line names exactly the file the write attempted — and the Minitest twin
|
|
1211
|
+
# names it on the same input (SPGD-1400), as does this file's delivery arm
|
|
1212
|
+
# through {#sink_clause} (SPGD-1413). The write goes through {#append} so
|
|
1213
|
+
# the exception comes back as a value to compose the line from; left to
|
|
1214
|
+
# raise, it would fall through to {#never_fail_the_run} and spend the
|
|
1215
|
+
# run's one warning on the one sentence this exists to replace.
|
|
1216
|
+
# `Interrupt` stays outside, as everywhere else in this file.
|
|
1227
1217
|
def append_local(data)
|
|
1228
1218
|
path = SpecGuard::RSpec.configuration.local_output_path
|
|
1229
1219
|
error = append(data, path)
|
|
@@ -1233,13 +1223,6 @@ module SpecGuard
|
|
|
1233
1223
|
"(#{error.class}: #{error.message}). The test run is unaffected.")
|
|
1234
1224
|
end
|
|
1235
1225
|
|
|
1236
|
-
def append_to(data, path)
|
|
1237
|
-
directory = File.dirname(path)
|
|
1238
|
-
FileUtils.mkdir_p(directory) unless directory == "." || File.directory?(directory)
|
|
1239
|
-
|
|
1240
|
-
File.open(path, "a") { |file| file.write("#{JSON.generate(data)}\n") }
|
|
1241
|
-
end
|
|
1242
|
-
|
|
1243
1226
|
# `Errno::*` and `IOError` — the sink's failure modes — are both
|
|
1244
1227
|
# `StandardError` descendants, so they need no separate clause; they are
|
|
1245
1228
|
# named in the ticket because they are the *reason* this rescue is here, not
|
data/lib/specguard/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: specguard-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.36
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- specguard Agent
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: json
|
|
@@ -64,6 +64,7 @@ files:
|
|
|
64
64
|
- lib/specguard/client/root_binding.rb
|
|
65
65
|
- lib/specguard/client/scanner.rb
|
|
66
66
|
- lib/specguard/client/schemas/open-test-intent.v1.json
|
|
67
|
+
- lib/specguard/client/sink_writer.rb
|
|
67
68
|
- lib/specguard/client/transport.rb
|
|
68
69
|
- lib/specguard/client/validator_backend.rb
|
|
69
70
|
- lib/specguard/minitest/reporter.rb
|