turbo_tests 2.2.2 → 2.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ee7cf1d2645f6c5d1ab7088ad50f239269c302d05adf783640976389c7366ad
4
- data.tar.gz: 5e8e203558a4a6d04fa16f3335114fe626df75bc21cd4c92d9a7e7e9fca53e04
3
+ metadata.gz: 0ce3db5b3cf918f8152cd3986f44505ab55127fcdba96194cfb5479416182b20
4
+ data.tar.gz: ae140be91a1b0db66f272fc7cc16bcc0d74d8ddc5d769ead501d8e3c5aa41aea
5
5
  SHA512:
6
- metadata.gz: 65511e7eae9bf5a2dc40be0c39f7d0f970a40196f2c52791d0a87231606e078cc922d51b83285c50e7f7fedafb95a05a613ee6691f927dcf9c3756dd00009685
7
- data.tar.gz: c6cc417e63a8385d7f25e245e9a923a16588b3d8099645f049de905041e61f43fe96d0f58145a81e1d357038dbaa3fe72d5622451720a997e1c2027162387491
6
+ metadata.gz: 9e80161b5d0ed9b656a59efc2c341a71e3bbc299bcedcfcf284f695aee5c34ba275c2c4b75cea33255db7f5c9c98a242048a72cd1d07534329bf3160f3766a04
7
+ data.tar.gz: 261e0183d586a59076db43f1b378ca6425b6bb79cadfca050b705c2fcde4cd847f26201d57716305d42add671c94421ab5e7b671f0324c0c3dacd2921b0114a9
data/Gemfile.lock CHANGED
@@ -1,8 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- turbo_tests (2.2.2)
5
- json (~> 2.3)
4
+ turbo_tests (2.2.4)
6
5
  parallel_tests (>= 3.3.0, < 5)
7
6
  rspec (>= 3.10)
8
7
 
@@ -11,7 +10,6 @@ GEM
11
10
  specs:
12
11
  coderay (1.1.3)
13
12
  diff-lcs (1.5.0)
14
- json (2.7.2)
15
13
  method_source (1.0.0)
16
14
  parallel (1.22.1)
17
15
  parallel_tests (4.2.0)
@@ -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 = []
@@ -87,26 +87,25 @@ module TurboTests
87
87
  setup_tmp_dir
88
88
 
89
89
  subprocess_opts = {
90
- record_runtime: use_runtime_info
90
+ record_runtime: use_runtime_info,
91
91
  }
92
92
 
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
93
+ @reporter.report(tests_in_groups) do |reporter|
94
+ wait_threads = tests_in_groups.map.with_index do |tests, process_id|
95
+ start_regular_subprocess(tests, process_id + 1, **subprocess_opts)
96
+ end
104
97
 
105
- @reporter.seed_notification(@seed, @seed_used)
98
+ handle_messages
106
99
 
107
- @threads.each(&:join)
100
+ @threads.each(&:join)
108
101
 
109
- @reporter.failed_examples.empty? && wait_threads.map(&:value).all?(&:success?)
102
+ if @reporter.failed_examples.empty? && wait_threads.map(&:value).all?(&:success?)
103
+ 0
104
+ else
105
+ # From https://github.com/serpapi/turbo_tests/pull/20/
106
+ wait_threads.map { |thread| thread.value.exitstatus }.max
107
+ end
108
+ end
110
109
  end
111
110
 
112
111
  private
@@ -157,12 +156,18 @@ module TurboTests
157
156
  []
158
157
  end
159
158
 
159
+ seed_option = if @seed_used
160
+ [
161
+ "--seed", @seed,
162
+ ]
163
+ else
164
+ []
165
+ end
166
+
160
167
  command = [
161
168
  *command_name,
162
169
  *extra_args,
163
- "--seed", rand(0xFFFF).to_s,
164
- "--format", "ParallelTests::RSpec::RuntimeLogger",
165
- "--out", @runtime_log,
170
+ *seed_option,
166
171
  "--format", "TurboTests::JsonRowsFormatter",
167
172
  *record_runtime_options,
168
173
  *tests,
@@ -254,12 +259,17 @@ module TurboTests
254
259
  break
255
260
  end
256
261
  when "message"
257
- @reporter.message(message[:message])
262
+ if message[:message].include?("An error occurred") || message[:message].include?("occurred outside of examples")
263
+ @reporter.error_outside_of_examples(message[:message])
264
+ @error = true
265
+ else
266
+ @reporter.message(message[:message])
267
+ end
258
268
  when "seed"
259
269
  when "close"
260
270
  when "error"
261
- @reporter.error_outside_of_examples
262
- @error = true
271
+ # Do nothing
272
+ nil
263
273
  when "exit"
264
274
  exited += 1
265
275
  if exited == @num_processes
@@ -277,15 +287,5 @@ module TurboTests
277
287
  def fail_fast_met
278
288
  !@fail_fast.nil? && @failure_count >= @fail_fast
279
289
  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
290
  end
291
291
  end
@@ -1,3 +1,3 @@
1
1
  module TurboTests
2
- VERSION = "2.2.2"
2
+ VERSION = "2.2.4"
3
3
  end
@@ -4,4 +4,4 @@ module CoreExtensions
4
4
  Struct.new(*self.keys).new(*self.values.map { |value| value.is_a?(Hash) ? value.to_struct : value })
5
5
  end
6
6
  end
7
- end
7
+ end
data/turbo_tests.gemspec CHANGED
@@ -21,7 +21,6 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.add_dependency "rspec", ">= 3.10"
23
23
  spec.add_dependency "parallel_tests", ">= 3.3.0", "< 5"
24
- spec.add_dependency "json", "~> 2.3"
25
24
 
26
25
  spec.add_development_dependency "pry", "~> 0.14"
27
26
 
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.2
4
+ version: 2.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Illia Zub
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-16 00:00:00.000000000 Z
11
+ date: 2024-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -44,20 +44,6 @@ dependencies:
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '5'
47
- - !ruby/object:Gem::Dependency
48
- name: json
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: '2.3'
54
- type: :runtime
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - "~>"
59
- - !ruby/object:Gem::Version
60
- version: '2.3'
61
47
  - !ruby/object:Gem::Dependency
62
48
  name: pry
63
49
  requirement: !ruby/object:Gem::Requirement
@@ -80,7 +66,6 @@ executables:
80
66
  extensions: []
81
67
  extra_rdoc_files: []
82
68
  files:
83
- - ".github/workflows/snyk_ruby-analysis.yml"
84
69
  - ".github/workflows/tag_and_release.yml"
85
70
  - ".github/workflows/tests.yml"
86
71
  - ".gitignore"
@@ -94,6 +79,7 @@ files:
94
79
  - bin/turbo_tests
95
80
  - fixtures/rspec/errors_outside_of_examples_spec.rb
96
81
  - fixtures/rspec/failing_spec.rb
82
+ - fixtures/rspec/no_method_error_spec.rb
97
83
  - fixtures/rspec/pending_exceptions_spec.rb
98
84
  - lib/turbo_tests.rb
99
85
  - lib/turbo_tests/cli.rb
@@ -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 }}