specguard-ruby 0.3.33 → 0.3.34
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/README.md +23 -0
- data/lib/specguard/rspec/formatter.rb +65 -1
- data/lib/specguard/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 68ead3c5ec7600c6f7443687863287223702e80d321e75ca530b73962fbc6845
|
|
4
|
+
data.tar.gz: baf5152ce8cf58b6d34a2404c2f5c901804886475890f9ed47c90fdae8d0da4e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1e97bb03e49080fae408556ad78b8f41df57e4c502c9d29e082d27b9d484c5c8db7856e0b889dc13b278590b66f5552c0dbeaf74e4a5a84770de5c265f7ab788
|
|
7
|
+
data.tar.gz: af29badb353672a54662352ba3b7f6af3e612ccd31121154828e98bbaf29eafeb3b456f6db8a2cf72577390a5e58009195f37aab9568990ec79209d550a0e572
|
data/README.md
CHANGED
|
@@ -612,6 +612,29 @@ that runs `rspec --dry-run` to catch an unparseable spec file inherits the key
|
|
|
612
612
|
and would otherwise overwrite your suite's real duration and pass/fail picture
|
|
613
613
|
with zeroes and green.
|
|
614
614
|
|
|
615
|
+
**Errors outside examples are reported, and an aborted run is not delivered.**
|
|
616
|
+
RSpec counts failures that belong to no example — a spec file that raises while
|
|
617
|
+
loading, a raising `before(:context)` / `after(:context)` / `after(:suite)`
|
|
618
|
+
hook — in its own summary ("N errors occurred outside of examples") and exits 1,
|
|
619
|
+
but the example rows the formatter captures say nothing about them. When that
|
|
620
|
+
count is positive the formatter prints one `SpecGuard:` line to stderr:
|
|
621
|
+
|
|
622
|
+
```
|
|
623
|
+
SpecGuard: RSpec reported 1 error outside of examples (a spec file that failed
|
|
624
|
+
to load, or a failing context or suite hook), so the captured run may not be
|
|
625
|
+
the whole suite; look at the RSpec error blocks above.
|
|
626
|
+
```
|
|
627
|
+
|
|
628
|
+
If the run also captured **zero examples** — the usual result of a load error —
|
|
629
|
+
it is treated as aborted: nothing is POSTed and nothing is written to
|
|
630
|
+
`log/test_results.jsonl`, and the same line adds *No examples were captured, so
|
|
631
|
+
nothing was sent or written.* Delivering it would post an empty run, which the
|
|
632
|
+
platform accepts and shows as the repository's newest run in place of the last
|
|
633
|
+
real one. A run with errors outside examples **and** at least one captured
|
|
634
|
+
example (a hook that raises after the examples passed) is still delivered, with
|
|
635
|
+
the warning. A clean run prints nothing, a dry run keeps its own single line
|
|
636
|
+
above instead, and parallel shards each print their own.
|
|
637
|
+
|
|
615
638
|
It **never blocks CI.** RSpec does not sandbox formatters — an exception raised
|
|
616
639
|
in one escapes the runner and takes RSpec's own exit code with it — so every
|
|
617
640
|
hook rescues, warns once on stderr, and leaves the exit status to your suite
|
|
@@ -210,7 +210,7 @@ module SpecGuard
|
|
|
210
210
|
# that fallback would then print every message a *second* time alongside the
|
|
211
211
|
# formatter {#seed} restores. Listening here suppresses it and takes over its
|
|
212
212
|
# job — see {#message}, which is that same fallback under this class's roof.
|
|
213
|
-
::RSpec::Core::Formatters.register self, :example_finished, :stop, :close, :seed, :message
|
|
213
|
+
::RSpec::Core::Formatters.register self, :example_finished, :stop, :close, :seed, :message, :dump_summary
|
|
214
214
|
|
|
215
215
|
# Prefixed so it is obvious in a CI log which tool is talking, and worded so
|
|
216
216
|
# a reader knows immediately that it is not their tests that broke.
|
|
@@ -230,6 +230,17 @@ module SpecGuard
|
|
|
230
230
|
# looking for a bug that is not there.
|
|
231
231
|
DRY_RUN_WARNING_PREFIX = "SpecGuard: skipped test telemetry for a dry run"
|
|
232
232
|
|
|
233
|
+
# The fourth shape: RSpec itself said something went wrong *outside* any
|
|
234
|
+
# example — a spec file that raised while loading, or a raising
|
|
235
|
+
# `before(:context)` / `after(:context)` / `after(:suite)` hook — which
|
|
236
|
+
# `Reporter#notify_non_example_exception` counts into the summary but
|
|
237
|
+
# attributes to no example. Nothing about this formatter failed; the line
|
|
238
|
+
# exists because the captured run may then not be the whole suite, and
|
|
239
|
+
# because a load error leaves RSpec with zero examples, which the platform
|
|
240
|
+
# would otherwise record as the repository's newest (empty) run. See
|
|
241
|
+
# {#warn_errors_outside_examples}.
|
|
242
|
+
OUTSIDE_ERRORS_WARNING_PREFIX = "SpecGuard: RSpec reported"
|
|
243
|
+
|
|
233
244
|
# The refusal in full, as its own constant rather than a string built at the
|
|
234
245
|
# call site, because {#skip_dry_run} now needs it in two places: appended to
|
|
235
246
|
# with the coverage figures on the happy path, and emitted bare as the
|
|
@@ -347,6 +358,7 @@ module SpecGuard
|
|
|
347
358
|
@error_stream = error_stream
|
|
348
359
|
@annotations = annotations || SpecGuard::Client::AnnotationLookup.new(root: root)
|
|
349
360
|
@specs = []
|
|
361
|
+
@errors_outside_examples = 0
|
|
350
362
|
@warned = false
|
|
351
363
|
# Stamped here rather than from a `start` hook on purpose. `:start` is not
|
|
352
364
|
# in this formatter's own registered set — it arrives only because
|
|
@@ -523,6 +535,23 @@ module SpecGuard
|
|
|
523
535
|
never_fail_the_run { relay_message(notification) }
|
|
524
536
|
end
|
|
525
537
|
|
|
538
|
+
# RSpec's end-of-run summary. The only thing read from it is the count of
|
|
539
|
+
# errors RSpec reported outside any example (a spec file raising at load, a
|
|
540
|
+
# raising context or suite hook): `close` turns a positive count into one
|
|
541
|
+
# `SpecGuard:` line, and into a refusal to deliver when no example was
|
|
542
|
+
# captured. Deliberately a different hook from {#message}, whose relay of
|
|
543
|
+
# RSpec's own messages is left alone.
|
|
544
|
+
#
|
|
545
|
+
# `respond_to?`-guarded: an rspec-core whose summary lacks the count reads
|
|
546
|
+
# as "none reported", which is the pre-existing behaviour.
|
|
547
|
+
def dump_summary(notification)
|
|
548
|
+
never_fail_the_run do
|
|
549
|
+
if notification.respond_to?(:errors_outside_of_examples_count)
|
|
550
|
+
@errors_outside_examples = notification.errors_outside_of_examples_count.to_i
|
|
551
|
+
end
|
|
552
|
+
end
|
|
553
|
+
end
|
|
554
|
+
|
|
526
555
|
# One example finished — passed, failed or pending. Called for every
|
|
527
556
|
# example in the run, in the order they complete.
|
|
528
557
|
def example_finished(notification)
|
|
@@ -547,6 +576,7 @@ module SpecGuard
|
|
|
547
576
|
@duration_seconds ||= elapsed_since_start
|
|
548
577
|
deliver(payload)
|
|
549
578
|
end
|
|
579
|
+
never_fail_the_run { warn_errors_outside_examples }
|
|
550
580
|
never_fail_the_run { super(notification) }
|
|
551
581
|
end
|
|
552
582
|
|
|
@@ -748,6 +778,7 @@ module SpecGuard
|
|
|
748
778
|
# it. {#dry_run?} has the argument in full.
|
|
749
779
|
def deliver(data)
|
|
750
780
|
return skip_dry_run if dry_run?
|
|
781
|
+
return if aborted_run?
|
|
751
782
|
|
|
752
783
|
configuration = SpecGuard::RSpec.configuration
|
|
753
784
|
return append_local(data) if blank?(configuration.api_key)
|
|
@@ -761,6 +792,39 @@ module SpecGuard
|
|
|
761
792
|
fall_back(data, result.reason)
|
|
762
793
|
end
|
|
763
794
|
|
|
795
|
+
# A run that captured nothing while RSpec reported errors outside examples
|
|
796
|
+
# is a run that aborted — in practice a spec file that raised at load, so
|
|
797
|
+
# RSpec ran zero examples. Delivering it would post `specs: []`, which the
|
|
798
|
+
# platform accepts and records as the repository's newest run, replacing the
|
|
799
|
+
# last real one with an empty one. It goes to neither sink (nothing worth
|
|
800
|
+
# replaying: the next run will measure the suite properly). A run with the
|
|
801
|
+
# same errors but at least one captured example — a raising hook after
|
|
802
|
+
# passing examples — is real data and is delivered.
|
|
803
|
+
def aborted_run?
|
|
804
|
+
@errors_outside_examples.positive? && @specs.empty?
|
|
805
|
+
end
|
|
806
|
+
|
|
807
|
+
# The one `SpecGuard:` line for errors RSpec reported outside examples.
|
|
808
|
+
#
|
|
809
|
+
# It does not go through {#emit_warning}: it is not a telemetry failure and
|
|
810
|
+
# must not spend the budget a genuine delivery failure needs. A dry run
|
|
811
|
+
# says nothing here — {#skip_dry_run} already printed the run's one
|
|
812
|
+
# `SpecGuard:` line, and a second would only repeat or contradict it.
|
|
813
|
+
# Parallel shards each print their own line; there is nothing to coordinate.
|
|
814
|
+
def warn_errors_outside_examples
|
|
815
|
+
count = @errors_outside_examples
|
|
816
|
+
return unless count.positive?
|
|
817
|
+
return if dry_run?
|
|
818
|
+
|
|
819
|
+
line = "#{OUTSIDE_ERRORS_WARNING_PREFIX} #{count} #{pluralize(count, 'error')} outside of examples " \
|
|
820
|
+
"(a spec file that failed to load, or a failing context or suite hook), so the " \
|
|
821
|
+
"captured run may not be the whole suite; look at the RSpec error blocks above."
|
|
822
|
+
line += " No examples were captured, so nothing was sent or written." if aborted_run?
|
|
823
|
+
@error_stream.puts(line)
|
|
824
|
+
rescue ScriptError, StandardError
|
|
825
|
+
nil
|
|
826
|
+
end
|
|
827
|
+
|
|
764
828
|
# The checks worth doing *before* spending the run's wall clock on a request
|
|
765
829
|
# whose answer is already known.
|
|
766
830
|
#
|
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.34
|
|
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-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: json
|