selective-ruby-rspec 0.1.5 → 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
|
@@ -6,17 +6,20 @@ module Selective
|
|
6
6
|
|
7
7
|
def initialize(...); end
|
8
8
|
|
9
|
-
def self.
|
10
|
-
@
|
9
|
+
def self.runner_wrapper=(runner_wrapper)
|
10
|
+
@runner_wrapper = runner_wrapper
|
11
11
|
end
|
12
12
|
|
13
|
-
def self.
|
14
|
-
@
|
13
|
+
def self.runner_wrapper
|
14
|
+
@runner_wrapper
|
15
15
|
end
|
16
16
|
|
17
17
|
%i(example_passed example_failed example_pending).each do |method|
|
18
18
|
define_method(method) do |notification|
|
19
|
-
self.class.
|
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)
|
20
23
|
end
|
21
24
|
end
|
22
25
|
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)
|
@@ -23,29 +23,12 @@ module Selective
|
|
23
23
|
config.options[:files_or_directories_to_run] = [DEFAULT_SPEC_PATH]
|
24
24
|
end
|
25
25
|
|
26
|
-
Formatter.
|
26
|
+
Formatter.runner_wrapper = self
|
27
27
|
|
28
28
|
@rspec_runner = ::RSpec::Core::Runner.new(@config)
|
29
29
|
@rspec_runner.setup($stderr, $stdout)
|
30
30
|
end
|
31
31
|
|
32
|
-
def parse_args(args)
|
33
|
-
supported_wrapper_args = %w[--require-each-hooks]
|
34
|
-
wrapper_args, rspec_args = args.partition do |arg|
|
35
|
-
supported_wrapper_args.any? do |p|
|
36
|
-
arg.start_with?(p)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
wrapper_config_hash = wrapper_args.each_with_object({}) do |arg, hash|
|
41
|
-
key = arg.sub('--', '').tr('-', '_').to_sym
|
42
|
-
hash[key] = true
|
43
|
-
end
|
44
|
-
|
45
|
-
rspec_args << "--format=progress" unless args.any? { |e| e.start_with?("--format") }
|
46
|
-
[rspec_args, wrapper_config_hash]
|
47
|
-
end
|
48
|
-
|
49
32
|
def manifest
|
50
33
|
output = nil
|
51
34
|
Tempfile.create("selective-rspec-dry-run") do |f|
|
@@ -63,28 +46,16 @@ module Selective
|
|
63
46
|
end
|
64
47
|
|
65
48
|
def run_test_cases(test_case_ids)
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
::RSpec.configuration.reset_filters
|
70
|
-
::RSpec.world.prepare_example_filtering
|
71
|
-
config.options[:files_or_directories_to_run] = test_case_ids
|
72
|
-
ensure_formatter
|
73
|
-
|
74
|
-
rspec_runner.setup($stderr, $stdout)
|
75
|
-
|
76
|
-
example_groups = test_case_ids.each_with_object(Set.new) do |test_case_id, set|
|
77
|
-
set << ::RSpec.world.example_map[test_case_id]
|
78
|
-
end
|
79
|
-
|
80
|
-
rspec_runner.run_specs(example_groups.to_a)
|
49
|
+
ensure_test_phase
|
50
|
+
configure(test_case_ids)
|
51
|
+
rspec_runner.run_specs(optimize_test_filtering(test_case_ids).to_a)
|
81
52
|
end
|
82
53
|
|
83
54
|
def exec
|
84
55
|
rspec_runner.run($stderr, $stdout)
|
85
56
|
end
|
86
57
|
|
87
|
-
def
|
58
|
+
def remove_test_case_result(test_case_id)
|
88
59
|
failure = ::RSpec.world.reporter.failed_examples.detect { |e| e.id == test_case_id }
|
89
60
|
if (failed_example_index = ::RSpec.world.reporter.failed_examples.index(failure))
|
90
61
|
::RSpec.world.reporter.failed_examples.delete_at(failed_example_index)
|
@@ -119,8 +90,29 @@ module Selective
|
|
119
90
|
RSpec::VERSION
|
120
91
|
end
|
121
92
|
|
93
|
+
def report_example(example)
|
94
|
+
example_callback.call(format_example(example))
|
95
|
+
end
|
96
|
+
|
122
97
|
private
|
123
98
|
|
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
|
106
|
+
|
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]
|
114
|
+
end
|
115
|
+
|
124
116
|
def get_example_from_reporter(test_case_id)
|
125
117
|
::RSpec.world.reporter.examples.detect { |e| e.id == test_case_id }
|
126
118
|
end
|
@@ -152,10 +144,6 @@ module Selective
|
|
152
144
|
}
|
153
145
|
end
|
154
146
|
|
155
|
-
def report_example(example)
|
156
|
-
example_callback.call(format_example(example))
|
157
|
-
end
|
158
|
-
|
159
147
|
def apply_rspec_configuration
|
160
148
|
::RSpec.configure do |config|
|
161
149
|
config.backtrace_exclusion_patterns = config.backtrace_exclusion_patterns | [/lib\/selective/]
|
@@ -167,11 +155,40 @@ module Selective
|
|
167
155
|
raise TestManifestError.new("Selective could not generate a test manifest. The output was:\n#{output}")
|
168
156
|
end
|
169
157
|
|
170
|
-
def
|
171
|
-
|
172
|
-
|
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
|
173
189
|
|
174
|
-
|
190
|
+
def apply_formatter
|
191
|
+
config.options[:formatters] << [Selective::Ruby::RSpec::Formatter.to_s]
|
175
192
|
end
|
176
193
|
end
|
177
194
|
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: 0.2.
|
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: 0.2.
|
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
|