specbandit 0.13.0 → 0.13.1

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: 95622117125136b9368557368697eb0b9663983289dc7a5c53692a230ac4d7ef
4
- data.tar.gz: 5d74e976511d86b4c8da066cc782fc358af1c69e89ae02edcc3935b077ad473e
3
+ metadata.gz: 14a1d9a07eb3ab1b19c59c9e054aec4fb32e5da1ac3f33841feb1fb068085648
4
+ data.tar.gz: 756a15f2a9c7f9cce3db7fa06e499235fd18ec332a51d6db1900ee1a9a2d1fb8
5
5
  SHA512:
6
- metadata.gz: 19a2cff1aab50ad0412e515a2081b85dcd8f94addf96232bfb2be3694b02980410df1a8788d3451907a985b26fc6cfecb1dd7d45750ba108b63f84975ea36996
7
- data.tar.gz: 9af9ad631d684be5485a43620b76dcda02e7e223e50b6ecab47def52ee24fa4ab296dff43e5eea11c03acaea5146178da9cced4740ebb1036b41edef38ba0852
6
+ metadata.gz: 6bc49db9d7bd80540b17d19b15fb759a2ab0c1c867026f3234610074323237cf4cd5ee8d7e590c472b324dbc152b0db83d35fa05bbf443175efad1f5fc658c1c
7
+ data.tar.gz: '09cdd5433154bc6a35d13006beccdcba288d8538fc79585e79b8939edf1a0c2e1149d98d21cbdc8ee4eb7f756640d00575b4ebb3791217f5359c511a8ddea6a0'
data/README.md CHANGED
@@ -318,6 +318,8 @@ Specbandit detects the mode automatically based on the state of `--key-rerun`:
318
318
  | Yes | Empty | Yes | **Fail** | Exit 1 with error. Prevents silent false pass on stale re-runs. |
319
319
  | No | -- | Yes | **Error** | Validation error: `--rerun` requires `--key-rerun`. |
320
320
 
321
+ > **Empty key names count as "not provided".** A `--key-rerun` whose value is an empty string -- e.g. `--key-rerun "$VAR"` where `$VAR` is unset in CI -- is treated exactly like `--key-rerun` being absent (the **No** rows above), not as a configured-but-empty key. Combined with `--rerun`, that means an empty/unset name fails hard (exit 1) rather than silently steal-and-pass. The same applies to `--key-failed`: an empty/unset name is treated as "not configured" and no failed files are recorded.
322
+
321
323
  #### The `--rerun` safety flag
322
324
 
323
325
  Without `--rerun`, specbandit cannot distinguish a first run from a re-run when the rerun key is empty (e.g., TTL expired or Redis was flushed). In that case it silently falls back to Record mode, which may find an empty shared queue and exit 0 with zero tests -- a **silent false pass**.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Specbandit
4
- VERSION = '0.13.0'
4
+ VERSION = '0.13.1'
5
5
  end
@@ -57,21 +57,7 @@ module Specbandit
57
57
  @run_start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
58
58
  adapter.setup
59
59
 
60
- exit_code = if key_rerun
61
- rerun_files = queue.read_all(key_rerun)
62
- if rerun_files.any?
63
- run_replay(rerun_files)
64
- elsif rerun
65
- output.puts "[specbandit] ERROR: --rerun flag is set but rerun key '#{key_rerun}' is empty."
66
- output.puts '[specbandit] The rerun key may have expired (TTL) or Redis was flushed.'
67
- output.puts '[specbandit] Cannot replay — failing to prevent silent false pass.'
68
- 1
69
- else
70
- run_steal(record: true)
71
- end
72
- else
73
- run_steal(record: false)
74
- end
60
+ exit_code = determine_exit_code
75
61
 
76
62
  print_summary if @batch_results.any?
77
63
  merge_json_results
@@ -83,6 +69,43 @@ module Specbandit
83
69
 
84
70
  private
85
71
 
72
+ # Decide the operating mode and execute it, returning the exit code.
73
+ # - no usable rerun key → steal mode (or crash if --rerun was requested)
74
+ # - rerun key has data → replay mode
75
+ # - rerun key but empty → record mode (or crash if --rerun was requested)
76
+ def determine_exit_code
77
+ unless key_present?(key_rerun)
78
+ return fail_stale_rerun if rerun
79
+
80
+ return run_steal(record: false)
81
+ end
82
+
83
+ rerun_files = queue.read_all(key_rerun)
84
+ return run_replay(rerun_files) if rerun_files.any?
85
+ return fail_stale_rerun if rerun
86
+
87
+ run_steal(record: true)
88
+ end
89
+
90
+ # A Redis key name is usable only when it is a non-nil, non-empty string.
91
+ # Guards the Ruby gotcha where "" is truthy (e.g. --key-rerun "$UNSET_VAR"),
92
+ # which would otherwise read/write against an empty key name.
93
+ def key_present?(value)
94
+ !value.nil? && !value.empty?
95
+ end
96
+
97
+ # Emit the stale/missing-rerun error and return exit code 1.
98
+ def fail_stale_rerun
99
+ if key_present?(key_rerun)
100
+ output.puts "[specbandit] ERROR: --rerun flag is set but rerun key '#{key_rerun}' is empty."
101
+ else
102
+ output.puts '[specbandit] ERROR: --rerun flag is set but no rerun key is configured.'
103
+ end
104
+ output.puts '[specbandit] The rerun key may have expired (TTL) or Redis was flushed.'
105
+ output.puts '[specbandit] Cannot replay — failing to prevent silent false pass.'
106
+ 1
107
+ end
108
+
86
109
  # Replay mode: run a known list of files in local batches.
87
110
  # Used when re-running a failed CI job -- the rerun key already
88
111
  # contains the exact files this runner executed previously.
@@ -171,7 +194,7 @@ module Specbandit
171
194
  # paths are recorded (not the entire batch). For CLI adapter batches
172
195
  # (no per-file granularity), the whole batch is recorded as fallback.
173
196
  def record_failed_files(files, result)
174
- return unless key_failed
197
+ return unless key_present?(key_failed)
175
198
  return if result.exit_code.zero?
176
199
 
177
200
  failed_files = extract_failed_files(result) || files
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specbandit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ferran Basora
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  requirements: []
112
- rubygems_version: 4.0.6
112
+ rubygems_version: 4.0.10
113
113
  specification_version: 4
114
114
  summary: Distributed test runner using Redis as a work queue
115
115
  test_files: []