turbo_tests 2.2.3 → 2.2.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: 8839d105f1c8a6011d5d9796b22d39c56ec2a419afadde707bd4efa01892e2c3
4
- data.tar.gz: 861501c3f6f15e7d1baa0ad823a0602d99eb46ff5ec577ef3cd39b9ed1fe3657
3
+ metadata.gz: c6c93d9468c7edb30f698655b33f8d79a67a6561a84f2ac5aa935a9fb4fb4c0e
4
+ data.tar.gz: 421398111d97f7ec5f79e2023578c60de599375dcd2822d0b3684c0a867f4ef8
5
5
  SHA512:
6
- metadata.gz: 02d41594c07d5e6aeb35d7eddabacb1052a1677d17e41ee86a092c7226f411ca59cce785efc0321073140940390458976fd3231e83de4ff6ed35b25561358639
7
- data.tar.gz: 5404af69067ca602dad75aece1d1b4476ecc72a3b380e37df79ed91dce8a8968fee76d41a347fca7de8a839f5db438790010b5fee2a0b493f653c256da3dd793
6
+ metadata.gz: c1eb1e2bff07a8cce05938622050a1e2679a8fbce587387f79735b8fbdd9d16ef85ccc02866492257df6a67334e03f83a569a4adb1c5608d0233e4ffc327c08e
7
+ data.tar.gz: 9fda5b61ac9386a0489f68197b088294428b34312e33fff5a5cb5cea9dfa34b367a7af9ff9e6ccd6d3c746591690dd5082bd39afeb7676b1bcacf3624b8e98dd
@@ -20,7 +20,7 @@ jobs:
20
20
  packages: write
21
21
 
22
22
  steps:
23
- - uses: actions/checkout@v3
23
+ - uses: actions/checkout@v4
24
24
  - name: Set up Ruby 2.7
25
25
  uses: ruby/setup-ruby@v1
26
26
  with:
@@ -33,7 +33,7 @@ jobs:
33
33
  bundle install
34
34
  bundle exec turbo_tests
35
35
 
36
- - uses: actions/upload-artifact@v3
36
+ - uses: actions/upload-artifact@v4
37
37
  with:
38
38
  name: "ruby-gem"
39
39
  path: "pkg/*.gem"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- turbo_tests (2.2.3)
4
+ turbo_tests (2.2.5)
5
5
  parallel_tests (>= 3.3.0, < 5)
6
6
  rspec (>= 3.10)
7
7
 
@@ -0,0 +1,3 @@
1
+ RSpec.describe "NoMethodError spec" do
2
+ it("fails") { expect(nil[:key]).to eql("value") }
3
+ end
@@ -98,7 +98,7 @@ module TurboTests
98
98
  end
99
99
  end
100
100
 
101
- success = TurboTests::Runner.run(
101
+ exitstatus = TurboTests::Runner.run(
102
102
  formatters: formatters,
103
103
  tags: tags,
104
104
  files: @argv.empty? ? ["spec"] : @argv,
@@ -109,11 +109,8 @@ module TurboTests
109
109
  seed: seed
110
110
  )
111
111
 
112
- if success
113
- exit 0
114
- else
115
- exit 1
116
- end
112
+ # From https://github.com/serpapi/turbo_tests/pull/20/
113
+ exit exitstatus
117
114
  end
118
115
  end
119
116
  end
@@ -4,8 +4,8 @@ module TurboTests
4
4
  class Reporter
5
5
  attr_writer :load_time
6
6
 
7
- def self.from_config(formatter_config, start_time)
8
- reporter = new(start_time)
7
+ def self.from_config(formatter_config, start_time, seed, seed_used)
8
+ reporter = new(start_time, seed, seed_used)
9
9
 
10
10
  formatter_config.each do |config|
11
11
  name, outputs = config.values_at(:name, :outputs)
@@ -23,13 +23,15 @@ module TurboTests
23
23
  attr_reader :pending_examples
24
24
  attr_reader :failed_examples
25
25
 
26
- def initialize(start_time)
26
+ def initialize(start_time, seed, seed_used)
27
27
  @formatters = []
28
28
  @pending_examples = []
29
29
  @failed_examples = []
30
30
  @all_examples = []
31
31
  @messages = []
32
32
  @start_time = start_time
33
+ @seed = seed
34
+ @seed_used = seed_used
33
35
  @load_time = 0
34
36
  @errors_outside_of_examples_count = 0
35
37
  end
@@ -50,6 +52,38 @@ module TurboTests
50
52
  end
51
53
  end
52
54
 
55
+ # Borrowed from RSpec::Core::Reporter
56
+ # https://github.com/rspec/rspec-core/blob/5699fcdc4723087ff6139af55bd155ad9ad61a7b/lib/rspec/core/reporter.rb#L71
57
+ def report(example_groups)
58
+ start(example_groups)
59
+ begin
60
+ yield self
61
+ ensure
62
+ finish
63
+ end
64
+ end
65
+
66
+ def start(example_groups, time=RSpec::Core::Time.now)
67
+ @start = time
68
+ @load_time = (@start - @start_time).to_f
69
+
70
+ report_number_of_tests(example_groups)
71
+ expected_example_count = example_groups.flatten(1).count
72
+
73
+ delegate_to_formatters(:seed, RSpec::Core::Notifications::SeedNotification.new(@seed, @seed_used))
74
+ delegate_to_formatters(:start, RSpec::Core::Notifications::StartNotification.new(expected_example_count, @load_time))
75
+ end
76
+
77
+ def report_number_of_tests(groups)
78
+ name = ParallelTests::RSpec::Runner.test_file_name
79
+
80
+ num_processes = groups.size
81
+ num_tests = groups.map(&:size).sum
82
+ tests_per_process = (num_processes == 0 ? 0 : num_tests.to_f / num_processes).round
83
+
84
+ puts "#{num_processes} processes for #{num_tests} #{name}s, ~ #{tests_per_process} #{name}s per process"
85
+ end
86
+
53
87
  def group_started(notification)
54
88
  delegate_to_formatters(:example_group_started, notification)
55
89
  end
@@ -83,16 +117,18 @@ module TurboTests
83
117
  @messages << message
84
118
  end
85
119
 
86
- def error_outside_of_examples
120
+ def error_outside_of_examples(error_message)
87
121
  @errors_outside_of_examples_count += 1
122
+ message error_message
88
123
  end
89
124
 
90
125
  def finish
91
- # SEE: https://bit.ly/2NP87Cz
92
- end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
126
+ end_time = RSpec::Core::Time.now
127
+
128
+ @duration = end_time - @start_time
129
+ delegate_to_formatters :stop, RSpec::Core::Notifications::ExamplesNotification.new(self)
93
130
 
94
- delegate_to_formatters(:start_dump,
95
- RSpec::Core::Notifications::NullNotification)
131
+ delegate_to_formatters :start_dump, RSpec::Core::Notifications::NullNotification
96
132
  delegate_to_formatters(:dump_pending,
97
133
  RSpec::Core::Notifications::ExamplesNotification.new(
98
134
  self
@@ -110,13 +146,13 @@ module TurboTests
110
146
  @load_time,
111
147
  @errors_outside_of_examples_count
112
148
  ))
113
- delegate_to_formatters(:close,
114
- RSpec::Core::Notifications::NullNotification)
115
- end
116
-
117
- def seed_notification(seed, seed_used)
118
- puts RSpec::Core::Notifications::SeedNotification.new(seed, seed_used).fully_formatted
119
- puts
149
+ delegate_to_formatters(:seed,
150
+ RSpec::Core::Notifications::SeedNotification.new(
151
+ @seed,
152
+ @seed_used,
153
+ ))
154
+ ensure
155
+ delegate_to_formatters :close, RSpec::Core::Notifications::NullNotification
120
156
  end
121
157
 
122
158
  protected
@@ -14,20 +14,19 @@ module TurboTests
14
14
  formatters = opts[:formatters]
15
15
  tags = opts[:tags]
16
16
 
17
- # SEE: https://bit.ly/2NP87Cz
18
- start_time = opts.fetch(:start_time) { Process.clock_gettime(Process::CLOCK_MONOTONIC) }
17
+ start_time = opts.fetch(:start_time) { RSpec::Core::Time.now }
19
18
  runtime_log = opts.fetch(:runtime_log, nil)
20
19
  verbose = opts.fetch(:verbose, false)
21
20
  fail_fast = opts.fetch(:fail_fast, nil)
22
21
  count = opts.fetch(:count, nil)
23
- seed = opts.fetch(:seed) || rand(0xFFFF).to_s
24
- seed_used = !opts[:seed].nil?
22
+ seed = opts.fetch(:seed)
23
+ seed_used = !seed.nil?
25
24
 
26
25
  if verbose
27
26
  warn "VERBOSE"
28
27
  end
29
28
 
30
- reporter = Reporter.from_config(formatters, start_time)
29
+ reporter = Reporter.from_config(formatters, start_time, seed, seed_used)
31
30
 
32
31
  new(
33
32
  reporter: reporter,
@@ -38,7 +37,7 @@ module TurboTests
38
37
  fail_fast: fail_fast,
39
38
  count: count,
40
39
  seed: seed,
41
- seed_used: seed_used
40
+ seed_used: seed_used,
42
41
  ).run
43
42
  end
44
43
 
@@ -50,11 +49,12 @@ module TurboTests
50
49
  @verbose = opts[:verbose]
51
50
  @fail_fast = opts[:fail_fast]
52
51
  @count = opts[:count]
52
+ @seed = opts[:seed]
53
+ @seed_used = opts[:seed_used]
54
+
53
55
  @load_time = 0
54
56
  @load_count = 0
55
57
  @failure_count = 0
56
- @seed = opts[:seed]
57
- @seed_used = opts[:seed_used]
58
58
 
59
59
  @messages = Thread::Queue.new
60
60
  @threads = []
@@ -84,42 +84,30 @@ module TurboTests
84
84
  **group_opts
85
85
  )
86
86
 
87
- setup_tmp_dir
88
-
89
87
  subprocess_opts = {
90
- record_runtime: use_runtime_info
88
+ record_runtime: use_runtime_info,
91
89
  }
92
90
 
93
- report_number_of_tests(tests_in_groups)
94
-
95
- @reporter.seed_notification(@seed, @seed_used)
96
-
97
- wait_threads = tests_in_groups.map.with_index do |tests, process_id|
98
- start_regular_subprocess(tests, process_id + 1, **subprocess_opts)
99
- end
100
-
101
- handle_messages
102
-
103
- @reporter.finish
91
+ @reporter.report(tests_in_groups) do |reporter|
92
+ wait_threads = tests_in_groups.map.with_index do |tests, process_id|
93
+ start_regular_subprocess(tests, process_id + 1, **subprocess_opts)
94
+ end
104
95
 
105
- @reporter.seed_notification(@seed, @seed_used)
96
+ handle_messages
106
97
 
107
- @threads.each(&:join)
98
+ @threads.each(&:join)
108
99
 
109
- @reporter.failed_examples.empty? && wait_threads.map(&:value).all?(&:success?)
100
+ if @reporter.failed_examples.empty? && wait_threads.map(&:value).all?(&:success?)
101
+ 0
102
+ else
103
+ # From https://github.com/serpapi/turbo_tests/pull/20/
104
+ wait_threads.map { |thread| thread.value.exitstatus }.max
105
+ end
106
+ end
110
107
  end
111
108
 
112
109
  private
113
110
 
114
- def setup_tmp_dir
115
- begin
116
- FileUtils.rm_r("tmp/test-pipes")
117
- rescue Errno::ENOENT
118
- end
119
-
120
- FileUtils.mkdir_p("tmp/test-pipes/")
121
- end
122
-
123
111
  def start_regular_subprocess(tests, process_id, **opts)
124
112
  start_subprocess(
125
113
  {"TEST_ENV_NUMBER" => process_id.to_s},
@@ -141,7 +129,9 @@ module TurboTests
141
129
  env["RUBYOPT"] = ["-I#{File.expand_path("..", __dir__)}", ENV["RUBYOPT"]].compact.join(" ")
142
130
  env["RSPEC_SILENCE_FILTER_ANNOUNCEMENTS"] = "1"
143
131
 
144
- if ENV["BUNDLE_BIN_PATH"]
132
+ if ENV["RSPEC_EXECUTABLE"]
133
+ command_name = ENV["RSPEC_EXECUTABLE"].split
134
+ elsif ENV["BUNDLE_BIN_PATH"]
145
135
  command_name = [ENV["BUNDLE_BIN_PATH"], "exec", "rspec"]
146
136
  else
147
137
  command_name = "rspec"
@@ -157,12 +147,18 @@ module TurboTests
157
147
  []
158
148
  end
159
149
 
150
+ seed_option = if @seed_used
151
+ [
152
+ "--seed", @seed,
153
+ ]
154
+ else
155
+ []
156
+ end
157
+
160
158
  command = [
161
159
  *command_name,
162
160
  *extra_args,
163
- "--seed", rand(0xFFFF).to_s,
164
- "--format", "ParallelTests::RSpec::RuntimeLogger",
165
- "--out", @runtime_log,
161
+ *seed_option,
166
162
  "--format", "TurboTests::JsonRowsFormatter",
167
163
  *record_runtime_options,
168
164
  *tests,
@@ -254,12 +250,17 @@ module TurboTests
254
250
  break
255
251
  end
256
252
  when "message"
257
- @reporter.message(message[:message])
253
+ if message[:message].include?("An error occurred") || message[:message].include?("occurred outside of examples")
254
+ @reporter.error_outside_of_examples(message[:message])
255
+ @error = true
256
+ else
257
+ @reporter.message(message[:message])
258
+ end
258
259
  when "seed"
259
260
  when "close"
260
261
  when "error"
261
- @reporter.error_outside_of_examples
262
- @error = true
262
+ # Do nothing
263
+ nil
263
264
  when "exit"
264
265
  exited += 1
265
266
  if exited == @num_processes
@@ -277,15 +278,5 @@ module TurboTests
277
278
  def fail_fast_met
278
279
  !@fail_fast.nil? && @failure_count >= @fail_fast
279
280
  end
280
-
281
- def report_number_of_tests(groups)
282
- name = ParallelTests::RSpec::Runner.test_file_name
283
-
284
- num_processes = groups.size
285
- num_tests = groups.map(&:size).sum
286
- tests_per_process = (num_processes == 0 ? 0 : num_tests.to_f / num_processes).round
287
-
288
- puts "#{num_processes} processes for #{num_tests} #{name}s, ~ #{tests_per_process} #{name}s per process"
289
- end
290
281
  end
291
282
  end
@@ -1,3 +1,3 @@
1
1
  module TurboTests
2
- VERSION = "2.2.3"
2
+ VERSION = "2.2.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbo_tests
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3
4
+ version: 2.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Illia Zub
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-16 00:00:00.000000000 Z
11
+ date: 2025-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -58,7 +58,7 @@ dependencies:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
60
  version: '0.14'
61
- description:
61
+ description:
62
62
  email:
63
63
  - ilya@serpapi.com
64
64
  executables:
@@ -66,7 +66,6 @@ executables:
66
66
  extensions: []
67
67
  extra_rdoc_files: []
68
68
  files:
69
- - ".github/workflows/snyk_ruby-analysis.yml"
70
69
  - ".github/workflows/tag_and_release.yml"
71
70
  - ".github/workflows/tests.yml"
72
71
  - ".gitignore"
@@ -80,6 +79,7 @@ files:
80
79
  - bin/turbo_tests
81
80
  - fixtures/rspec/errors_outside_of_examples_spec.rb
82
81
  - fixtures/rspec/failing_spec.rb
82
+ - fixtures/rspec/no_method_error_spec.rb
83
83
  - fixtures/rspec/pending_exceptions_spec.rb
84
84
  - lib/turbo_tests.rb
85
85
  - lib/turbo_tests/cli.rb
@@ -96,7 +96,7 @@ metadata:
96
96
  homepage_uri: https://github.com/serpapi/turbo_tests
97
97
  source_code_uri: https://github.com/serpapi/turbo_tests
98
98
  changelog_uri: https://github.com/serpapi/turbo_tests/releases
99
- post_install_message:
99
+ post_install_message:
100
100
  rdoc_options: []
101
101
  require_paths:
102
102
  - lib
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  version: '0'
113
113
  requirements: []
114
114
  rubygems_version: 3.1.6
115
- signing_key:
115
+ signing_key:
116
116
  specification_version: 4
117
117
  summary: "`turbo_tests` is a drop-in replacement for `grosser/parallel_tests` with
118
118
  incremental summarized output. Source code of `turbo_test` gem is based on Discourse
@@ -1,33 +0,0 @@
1
- # A sample workflow which checks out your Infrastructure as Code Configuration files,
2
- # such as Kubernetes, Helm & Terraform and scans them for any security issues.
3
- # The results are then uploaded to GitHub Security Code Scanning
4
- #
5
- # For more examples, including how to limit scans to only high-severity issues
6
- # and fail PR checks, see https://github.com/snyk/actions/
7
-
8
- name: Snyk Ruby
9
-
10
- on:
11
- push:
12
- branches: [ master ]
13
- pull_request:
14
- # The branches below must be a subset of the branches above
15
- branches: [ master ]
16
- schedule:
17
- - cron: '0 0 * * 0'
18
-
19
- jobs:
20
- snyk:
21
- runs-on: ubuntu-latest
22
- steps:
23
- - uses: actions/checkout@v3
24
- - name: Run Snyk to check configuration files for security issues
25
- # Snyk can be used to break the build when it detects security issues.
26
- # In this case we want to upload the issues to GitHub Code Scanning
27
- continue-on-error: true
28
- uses: snyk/actions/ruby@master
29
- env:
30
- # In order to use the Snyk Action you will need to have a Snyk API token.
31
- # More details in https://github.com/snyk/actions#getting-your-snyk-token
32
- # or you can signup for free at https://snyk.io/login
33
- SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}