rspec-tracer 1.1.0 → 1.1.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: b7f283b4a6ab3d0d2616f7dca4bac721906d36b4296ba1d64446937db1503dd5
4
- data.tar.gz: 2922f96420e344603a472b4e67bb5f2c58c16e8bf798e13098eec8f8096434c5
3
+ metadata.gz: 5e89ead4a61c2b6d881fe8ca3fbcfec3ab94e7d8b78f759de5fe64e4e22b693d
4
+ data.tar.gz: 8993bc089a6185bdd7f0e20f71ad69b13fbd96c679bf67878c69b4f52dacd12f
5
5
  SHA512:
6
- metadata.gz: 222031b5d7b0a6b01cad104fda83347a9e10af957c7a5d1dfede9f46cf8a275435c3e0c9dfb02ad7788b3dfc2d4c3b9513a60ee3ccf0d3bfd68a692758a38f1e
7
- data.tar.gz: f2828567b26b580ffc66568f8b14581cb160f4bdf14a61622b605b5832d5d3bc86cff211190628c5480604f0ec1c758609ec8aa490b357016e3565615c635be2
6
+ metadata.gz: 91dc8066a66b706cfc02e9cb1050c61fc2e6bfa15d7353d056b11edb854ac493a99770516ce57e9ef4649494a0d99573b9dc8e441ead128b9e28abce9e2e21c1
7
+ data.tar.gz: 21a2cceab3b2cd3f1c3051542a1267d03a7cb499417f9501502a8c1bac3ac62e96821a1c07ea977768adca4b806a1fffca13b0e2946db95f031e877bc5bc4ebd
data/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ ## [1.1.1] - 2026-04-23
2
+
3
+ ### Fixed
4
+
5
+ - **parallel_tests at-exit deadlock** — `parallel_tests_last_process?`
6
+ relied on a lock file written during `RSpecTracer.start` to identify
7
+ the last worker. If a fast worker reached `at_exit` before a slower
8
+ peer had loaded `spec_helper` and registered its `TEST_ENV_NUMBER`,
9
+ both workers could self-elect as the last process, both entered
10
+ `::ParallelTests.wait_for_other_processes_to_finish`, and deadlocked
11
+ on each other's pid. The elector now delegates to
12
+ `::ParallelTests.first_process?`, which reads immutable env vars set
13
+ by the parent at worker spawn. Exactly one worker is elected per run,
14
+ regardless of boot-time ordering or runner CPU count. No public-API
15
+ change — the `rspec_tracer.lock` file is still written and cleaned
16
+ up, just no longer consulted.
17
+
1
18
  ## [1.1.0] - 2026-04-20
2
19
 
3
20
  ### Added
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RSpecTracer
4
- VERSION = '1.1.0'
4
+ VERSION = '1.1.1'
5
5
  end
data/lib/rspec_tracer.rb CHANGED
@@ -416,18 +416,47 @@ module RSpecTracer
416
416
  true
417
417
  end
418
418
 
419
+ # Elects the worker that performs the per-run merge. Delegates to
420
+ # `::ParallelTests.first_process?`, which returns true iff
421
+ # `TEST_ENV_NUMBER.to_i <= 1` — i.e. for exactly one worker
422
+ # (TEST_ENV_NUMBER == '' or '1'), regardless of how many workers
423
+ # were actually spawned vs. how many CPUs the runner reports.
424
+ #
425
+ # Two previously attempted approaches do NOT work here:
426
+ #
427
+ # 1. The lock-file scheme below (each worker writing its
428
+ # TEST_ENV_NUMBER to `rspec_tracer.lock` via
429
+ # `track_parallel_tests_test_env_number`; last_process picked
430
+ # the max) deadlocked under slow CI: worker 1 could finish
431
+ # its examples before worker 2 even loaded spec_helper,
432
+ # observe itself as the max, and enter
433
+ # `::ParallelTests.wait_for_other_processes_to_finish`
434
+ # concurrently with worker 2's own self-election — both
435
+ # workers then spun on each other's pid.
436
+ #
437
+ # 2. `::ParallelTests.last_process?` compares TEST_ENV_NUMBER
438
+ # against PARALLEL_TEST_GROUPS, which parallel_rspec sets to
439
+ # the CPU-based *intended* process count — NOT the actual
440
+ # worker count. When spec files < CPU count (common), no
441
+ # TEST_ENV_NUMBER ever matches PARALLEL_TEST_GROUPS and the
442
+ # merge is silently skipped.
443
+ #
444
+ # `first_process?` avoids both: set by the parent at spawn,
445
+ # immutable thereafter, and identifies exactly one worker
446
+ # regardless of CPU count. The elected worker still calls
447
+ # `wait_for_other_processes_to_finish` before merging so peer
448
+ # caches are guaranteed on disk.
449
+ #
450
+ # `track_parallel_tests_test_env_number` and the lock-file
451
+ # cleanup in `at_exit_behavior` are retained for backward
452
+ # compatibility with users who observe `rspec_tracer.lock` /
453
+ # set `RSPEC_TRACER_LOCK_FILE`; the file is still written and
454
+ # removed but is no longer consulted.
419
455
  def parallel_tests_last_process?
420
456
  return false unless parallel_tests?
457
+ return false unless defined?(::ParallelTests)
421
458
 
422
- max_test_num = 0
423
-
424
- File.open(RSpecTracer.lock_file, 'r') do |f|
425
- f.flock(File::LOCK_SH)
426
-
427
- max_test_num = f.read.to_i
428
- end
429
-
430
- ENV['TEST_ENV_NUMBER'].to_i == max_test_num
459
+ ::ParallelTests.first_process?
431
460
  end
432
461
  end
433
462
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-tracer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abhimanyu Singh
@@ -111,7 +111,7 @@ licenses:
111
111
  - MIT
112
112
  metadata:
113
113
  homepage_uri: https://github.com/avmnu-sng/rspec-tracer
114
- source_code_uri: https://github.com/avmnu-sng/rspec-tracer/tree/v1.1.0
114
+ source_code_uri: https://github.com/avmnu-sng/rspec-tracer/tree/v1.1.1
115
115
  changelog_uri: https://github.com/avmnu-sng/rspec-tracer/blob/main/CHANGELOG.md
116
116
  bug_tracker_uri: https://github.com/avmnu-sng/rspec-tracer/issues
117
117
  rdoc_options: []