selective-ruby-rspec 0.1.4 → 0.1.6
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab16214c977e214c1768f9151be4d4eb3f89f4400279c1e269947b353792981d
|
4
|
+
data.tar.gz: b19ed802819f65223e9ef8a2f262a1fd7c0d3baa70329d6e1de8fe9d5f3b7981
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4ba21e4eee2ded289e1d2448401b8078c10eddecb4fa6acaf489954becd0a0166d17be966dce11d96489d63fb8da890c99e1fdb961d2b18853801d536167b02
|
7
|
+
data.tar.gz: 4f585e62586e20423913e0ad0940dc8c13901de771876de44766b9eb705c58e193ad87083d4df5c56be90bc6814722d6337860c99e20d46e58fa74ebc978d45e
|
@@ -0,0 +1,19 @@
|
|
1
|
+
version: v1.0
|
2
|
+
name: Ruby
|
3
|
+
agent:
|
4
|
+
machine:
|
5
|
+
type: e1-standard-2
|
6
|
+
os_image: ubuntu2004
|
7
|
+
blocks:
|
8
|
+
- name: Run RSpec tests
|
9
|
+
task:
|
10
|
+
jobs:
|
11
|
+
- name: Run RSpec tests
|
12
|
+
parallelism: 2
|
13
|
+
commands:
|
14
|
+
- sem-version ruby 3.3.0
|
15
|
+
- checkout
|
16
|
+
- bundle install
|
17
|
+
- bundle exec selective rspec
|
18
|
+
secrets:
|
19
|
+
- name: Selective
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Selective
|
2
|
+
module Ruby
|
3
|
+
module RSpec
|
4
|
+
class Formatter
|
5
|
+
::RSpec::Core::Formatters.register self, :example_passed, :example_failed, :example_pending
|
6
|
+
|
7
|
+
def initialize(...); end
|
8
|
+
|
9
|
+
def self.runner_wrapper=(runner_wrapper)
|
10
|
+
@runner_wrapper = runner_wrapper
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.runner_wrapper
|
14
|
+
@runner_wrapper
|
15
|
+
end
|
16
|
+
|
17
|
+
%i(example_passed example_failed example_pending).each do |method|
|
18
|
+
define_method(method) do |notification|
|
19
|
+
self.class.runner_wrapper.report_example(notification.example)
|
20
|
+
rescue Selective::Ruby::Core::ConnectionLostError
|
21
|
+
::RSpec.world.wants_to_quit = true
|
22
|
+
self.class.runner_wrapper.remove_test_case_result(notification.example.id)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -97,6 +97,16 @@ module Selective
|
|
97
97
|
super
|
98
98
|
@example_map = {}
|
99
99
|
end
|
100
|
+
|
101
|
+
def prepare_example_filtering
|
102
|
+
@filtered_examples = Hash.new do |hash, group|
|
103
|
+
hash[group] = if ::RSpec.configuration.dry_run?
|
104
|
+
filter_manager.prune(group.examples)
|
105
|
+
else
|
106
|
+
[]
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
100
110
|
end
|
101
111
|
|
102
112
|
module Runner
|
@@ -106,7 +116,7 @@ module Selective
|
|
106
116
|
module Example
|
107
117
|
def initialize(*args)
|
108
118
|
super
|
109
|
-
::RSpec.world.example_map[id] =
|
119
|
+
::RSpec.world.example_map[id] = self
|
110
120
|
end
|
111
121
|
|
112
122
|
def run(*args)
|
@@ -7,12 +7,13 @@ module Selective
|
|
7
7
|
class RunnerWrapper
|
8
8
|
class TestManifestError < StandardError; end
|
9
9
|
|
10
|
-
attr_reader :rspec_runner, :config
|
10
|
+
attr_reader :rspec_runner, :config, :example_callback
|
11
11
|
|
12
12
|
FRAMEWORK = "rspec"
|
13
13
|
DEFAULT_SPEC_PATH = "./spec"
|
14
14
|
|
15
|
-
def initialize(args)
|
15
|
+
def initialize(args, example_callback)
|
16
|
+
@example_callback = example_callback
|
16
17
|
rspec_args, wrapper_config_hash = parse_args(args)
|
17
18
|
Selective::Ruby::RSpec::Monkeypatches.apply(wrapper_config_hash)
|
18
19
|
apply_rspec_configuration
|
@@ -22,27 +23,12 @@ module Selective
|
|
22
23
|
config.options[:files_or_directories_to_run] = [DEFAULT_SPEC_PATH]
|
23
24
|
end
|
24
25
|
|
26
|
+
Formatter.runner_wrapper = self
|
27
|
+
|
25
28
|
@rspec_runner = ::RSpec::Core::Runner.new(@config)
|
26
29
|
@rspec_runner.setup($stderr, $stdout)
|
27
30
|
end
|
28
31
|
|
29
|
-
def parse_args(args)
|
30
|
-
supported_wrapper_args = %w[--require-each-hooks]
|
31
|
-
wrapper_args, rspec_args = args.partition do |arg|
|
32
|
-
supported_wrapper_args.any? do |p|
|
33
|
-
arg.start_with?(p)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
wrapper_config_hash = wrapper_args.each_with_object({}) do |arg, hash|
|
38
|
-
key = arg.sub('--', '').tr('-', '_').to_sym
|
39
|
-
hash[key] = true
|
40
|
-
end
|
41
|
-
|
42
|
-
rspec_args << "--format=progress" unless args.any? { |e| e.start_with?("--format") }
|
43
|
-
[rspec_args, wrapper_config_hash]
|
44
|
-
end
|
45
|
-
|
46
32
|
def manifest
|
47
33
|
output = nil
|
48
34
|
Tempfile.create("selective-rspec-dry-run") do |f|
|
@@ -59,19 +45,17 @@ module Selective
|
|
59
45
|
raise_test_manifest_error(e.message)
|
60
46
|
end
|
61
47
|
|
62
|
-
def run_test_cases(test_case_ids
|
63
|
-
|
64
|
-
|
65
|
-
test_case_ids.
|
66
|
-
run_test_case(test_case_id, callback)
|
67
|
-
end
|
48
|
+
def run_test_cases(test_case_ids)
|
49
|
+
ensure_test_phase
|
50
|
+
configure(test_case_ids)
|
51
|
+
rspec_runner.run_specs(optimize_test_filtering(test_case_ids).to_a)
|
68
52
|
end
|
69
53
|
|
70
54
|
def exec
|
71
55
|
rspec_runner.run($stderr, $stdout)
|
72
56
|
end
|
73
57
|
|
74
|
-
def
|
58
|
+
def remove_test_case_result(test_case_id)
|
75
59
|
failure = ::RSpec.world.reporter.failed_examples.detect { |e| e.id == test_case_id }
|
76
60
|
if (failed_example_index = ::RSpec.world.reporter.failed_examples.index(failure))
|
77
61
|
::RSpec.world.reporter.failed_examples.delete_at(failed_example_index)
|
@@ -106,18 +90,27 @@ module Selective
|
|
106
90
|
RSpec::VERSION
|
107
91
|
end
|
108
92
|
|
93
|
+
def report_example(example)
|
94
|
+
example_callback.call(format_example(example))
|
95
|
+
end
|
96
|
+
|
109
97
|
private
|
110
98
|
|
111
|
-
def
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
99
|
+
def parse_args(args)
|
100
|
+
supported_wrapper_args = %w[--require-each-hooks]
|
101
|
+
wrapper_args, rspec_args = args.partition do |arg|
|
102
|
+
supported_wrapper_args.any? do |p|
|
103
|
+
arg.start_with?(p)
|
104
|
+
end
|
105
|
+
end
|
117
106
|
|
118
|
-
|
119
|
-
|
120
|
-
|
107
|
+
wrapper_config_hash = wrapper_args.each_with_object({}) do |arg, hash|
|
108
|
+
key = arg.sub('--', '').tr('-', '_').to_sym
|
109
|
+
hash[key] = true
|
110
|
+
end
|
111
|
+
|
112
|
+
rspec_args << "--format=progress" unless args.any? { |e| e.start_with?("--format") }
|
113
|
+
[rspec_args, wrapper_config_hash]
|
121
114
|
end
|
122
115
|
|
123
116
|
def get_example_from_reporter(test_case_id)
|
@@ -161,6 +154,42 @@ module Selective
|
|
161
154
|
def raise_test_manifest_error(output)
|
162
155
|
raise TestManifestError.new("Selective could not generate a test manifest. The output was:\n#{output}")
|
163
156
|
end
|
157
|
+
|
158
|
+
def configure(test_case_ids)
|
159
|
+
::RSpec.world.wants_to_quit = false
|
160
|
+
::RSpec.configuration.reset_filters
|
161
|
+
::RSpec.world.filtered_examples.clear
|
162
|
+
|
163
|
+
config.options[:files_or_directories_to_run] = test_case_ids
|
164
|
+
rspec_runner.configure($stderr, $stdout)
|
165
|
+
::RSpec.configuration.load_spec_files
|
166
|
+
end
|
167
|
+
|
168
|
+
def optimize_test_filtering(test_case_ids)
|
169
|
+
# The following is an optimization to avoid RSpec's usual filtering mechanism
|
170
|
+
# which has a significant performance overhead.
|
171
|
+
test_case_ids.each_with_object(Set.new) do |test_case_id, set|
|
172
|
+
example = ::RSpec.world.example_map[test_case_id]
|
173
|
+
if ::RSpec.world.filtered_examples.key?(example.example_group)
|
174
|
+
::RSpec.world.filtered_examples[example.example_group] << example
|
175
|
+
else
|
176
|
+
::RSpec.world.filtered_examples[example.example_group] = [example]
|
177
|
+
end
|
178
|
+
set << example.example_group.parent_groups.last
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
def ensure_test_phase
|
183
|
+
@test_phase_initialized ||= begin
|
184
|
+
::RSpec.world.reporter.send(:start, nil)
|
185
|
+
Selective::Ruby::Core::Controller.suppress_reporting!
|
186
|
+
apply_formatter
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
def apply_formatter
|
191
|
+
config.options[:formatters] << [Selective::Ruby::RSpec::Formatter.to_s]
|
192
|
+
end
|
164
193
|
end
|
165
194
|
end
|
166
195
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: selective-ruby-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Wood
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-02-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: zeitwerk
|
@@ -31,14 +31,14 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
version: 0.2.3
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
41
|
+
version: 0.2.3
|
42
42
|
description: Selective is an intelligent test runner for your current CI provider.
|
43
43
|
Get real-time test results, intelligent ordering based on code changes, shorter
|
44
44
|
run times, automatic flake detection, the ability to re-enqueue failed tests, and
|
@@ -50,9 +50,11 @@ executables: []
|
|
50
50
|
extensions: []
|
51
51
|
extra_rdoc_files: []
|
52
52
|
files:
|
53
|
+
- ".semaphore/semaphore.yml"
|
53
54
|
- LICENSE
|
54
55
|
- Rakefile
|
55
56
|
- lib/selective-ruby-rspec.rb
|
57
|
+
- lib/selective/ruby/rspec/formatter.rb
|
56
58
|
- lib/selective/ruby/rspec/monkeypatches.rb
|
57
59
|
- lib/selective/ruby/rspec/runner_wrapper.rb
|
58
60
|
- lib/selective/ruby/rspec/version.rb
|