crspec 0.1.3 → 0.1.5

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: 3fcb8bb24535f599678015c5468d0745300977ccc90fbd6a3231a17a10301247
4
- data.tar.gz: 5def220500d988066bca912c12c39d730b8c114aab8c296cc46f9453a347845f
3
+ metadata.gz: c0d7564354ce4a30b067d3786a53d52e414b0d6710e4e50c798bbf47c87309db
4
+ data.tar.gz: 68168ea426d446bcddd2fd4e148efe891cf266854b3d0136a91636d553a3fde0
5
5
  SHA512:
6
- metadata.gz: f2ff2613f438e6819e0a0045127ee79e9890e233f6cc4c77a0319d3076356aee27d6c603587ffd496125e0798caf0fafbd60d14b8eaedb362f5d2a95063a37f5
7
- data.tar.gz: 332947c34cdf729079fab7b006c80ffc63d1130886832571582e82b5e1f06e1d5a19a47577f911a159f57eb88593c37b6557f13944320a09e5ef08020289afe4
6
+ metadata.gz: b5dfb9faa9089603b0fbb618f24d535de6f618439a2f495579a23ba7eed182a7006072e153d88c95dbcd9a4102cdb09a19d909f5cd4314cc6fde7ed8b4ce0ca2
7
+ data.tar.gz: 70431def1aa0f7e85bc75c114408c3c73d4fbcebe0c3d795102b1007e0c565f8a1549517359d46ff95413a7a2bf3be74627bbd93793e14cf41f0cc933b804ed9
data/CHANGELOG.md CHANGED
@@ -4,7 +4,12 @@
4
4
 
5
5
  - **Fiber tier** (`--fibers M`, `config.fibers`): each worker thread runs up
6
6
  to M concurrent example-fibers on the Async reactor; IO-bound examples
7
- overlap within a thread. `async` is now a runtime dependency.
7
+ overlap within a thread. `async` is a soft dependency (add it to your
8
+ Gemfile on CRuby); without it `--fibers` falls back to 1.
9
+ - **JRuby support**: full test suite passes on JRuby 10; threads scale
10
+ across all cores (no GVL), so `-c N` is the multi-core tier there.
11
+ `--processes N` raises with guidance (no fork); `--processes auto`
12
+ gracefully falls back to threads.
8
13
  - **Process tier** (`--processes P`, `--processes auto` = physical cores):
9
14
  forks after spec loading (`Process.warmup`), shards examples by persisted
10
15
  timings (LPT bin-packing, round-robin on first run), streams marshalled
data/lib/crspec/cli.rb CHANGED
@@ -46,6 +46,18 @@ module Crspec
46
46
  persistence_path = Crspec.configuration.example_status_persistence_file_path ||
47
47
  File.join("tmp", "crspec_status.json")
48
48
  multi_process = @processes == :auto || (@processes.is_a?(Integer) && @processes > 1)
49
+ if multi_process && !ProcessRunner.fork_supported?
50
+ if @processes == :auto
51
+ # auto = "use the best multi-core strategy"; on engines without a
52
+ # GVL, threads already are that strategy.
53
+ puts "#{RUBY_ENGINE} has no fork; --processes auto falling back to #{concurrency} threads."
54
+ multi_process = false
55
+ else
56
+ warn "Error: --processes requires fork, which #{RUBY_ENGINE} does not support."
57
+ warn "On #{RUBY_ENGINE} threads use all cores; use -c/--concurrency instead."
58
+ return false
59
+ end
60
+ end
49
61
  runner = if multi_process
50
62
  ProcessRunner.new(processes: @processes, concurrency: concurrency,
51
63
  fibers: fibers, fail_fast: @fail_fast, seed: @seed,
@@ -17,8 +17,25 @@ module Crspec
17
17
 
18
18
  attr_reader :passed_examples, :failed_examples, :pending_examples, :total_duration
19
19
 
20
+ # Forking is only meaningful (and only available) on runtimes with a
21
+ # GVL, i.e. CRuby. On JRuby/TruffleRuby threads already use all cores,
22
+ # so `-c N` is the multi-core tier there.
23
+ def self.fork_supported?
24
+ Process.respond_to?(:fork) && !Process.method(:fork).nil? &&
25
+ RUBY_ENGINE == "ruby"
26
+ end
27
+
20
28
  def initialize(processes:, concurrency: Etc.nprocessors, fibers: 1, formatter: nil,
21
29
  fail_fast: false, seed: nil, only_failures: false, persistence_path: nil)
30
+ unless self.class.fork_supported?
31
+ raise Crspec::Error, <<~MSG
32
+ --processes requires fork, which #{RUBY_ENGINE} does not support.
33
+ On #{RUBY_ENGINE} threads are not limited by a GVL, so worker
34
+ threads already use all cores: use -c/--concurrency instead
35
+ (e.g. `crspec -c #{Etc.nprocessors}`).
36
+ MSG
37
+ end
38
+
22
39
  @processes = processes == :auto ? physical_core_count : processes
23
40
  @concurrency = concurrency
24
41
  @fibers = fibers
@@ -67,7 +84,6 @@ module Crspec
67
84
  until readers.empty?
68
85
  ready, = IO.select(readers.keys)
69
86
  ready.each do |io|
70
- child = readers[io]
71
87
  result = read_result(io)
72
88
  if result.nil?
73
89
  readers.delete(io)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Crspec
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.5"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aboobacker MK
@@ -10,20 +10,6 @@ bindir: exe
10
10
  cert_chain: []
11
11
  date: 2026-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: async
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '2.0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '2.0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: prism
29
15
  requirement: !ruby/object:Gem::Requirement