rspec-core 3.2.3 → 3.3.0
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/Changelog.md +75 -0
- data/README.md +137 -20
- data/lib/rspec/autorun.rb +1 -0
- data/lib/rspec/core.rb +8 -16
- data/lib/rspec/core/backtrace_formatter.rb +1 -3
- data/lib/rspec/core/bisect/coordinator.rb +66 -0
- data/lib/rspec/core/bisect/example_minimizer.rb +130 -0
- data/lib/rspec/core/bisect/runner.rb +139 -0
- data/lib/rspec/core/bisect/server.rb +61 -0
- data/lib/rspec/core/bisect/subset_enumerator.rb +39 -0
- data/lib/rspec/core/configuration.rb +134 -5
- data/lib/rspec/core/configuration_options.rb +21 -10
- data/lib/rspec/core/example.rb +84 -50
- data/lib/rspec/core/example_group.rb +46 -18
- data/lib/rspec/core/example_status_persister.rb +235 -0
- data/lib/rspec/core/filter_manager.rb +43 -28
- data/lib/rspec/core/flat_map.rb +2 -0
- data/lib/rspec/core/formatters.rb +30 -20
- data/lib/rspec/core/formatters/base_text_formatter.rb +1 -0
- data/lib/rspec/core/formatters/bisect_formatter.rb +68 -0
- data/lib/rspec/core/formatters/bisect_progress_formatter.rb +115 -0
- data/lib/rspec/core/formatters/deprecation_formatter.rb +0 -1
- data/lib/rspec/core/formatters/documentation_formatter.rb +0 -4
- data/lib/rspec/core/formatters/exception_presenter.rb +389 -0
- data/lib/rspec/core/formatters/fallback_message_formatter.rb +28 -0
- data/lib/rspec/core/formatters/helpers.rb +22 -2
- data/lib/rspec/core/formatters/html_formatter.rb +1 -4
- data/lib/rspec/core/formatters/html_printer.rb +2 -6
- data/lib/rspec/core/formatters/json_formatter.rb +6 -4
- data/lib/rspec/core/formatters/snippet_extractor.rb +12 -7
- data/lib/rspec/core/hooks.rb +8 -2
- data/lib/rspec/core/memoized_helpers.rb +77 -17
- data/lib/rspec/core/metadata.rb +24 -10
- data/lib/rspec/core/metadata_filter.rb +16 -3
- data/lib/rspec/core/mutex.rb +63 -0
- data/lib/rspec/core/notifications.rb +84 -189
- data/lib/rspec/core/option_parser.rb +105 -32
- data/lib/rspec/core/ordering.rb +28 -25
- data/lib/rspec/core/profiler.rb +32 -0
- data/lib/rspec/core/project_initializer/spec/spec_helper.rb +6 -1
- data/lib/rspec/core/rake_task.rb +6 -20
- data/lib/rspec/core/reentrant_mutex.rb +52 -0
- data/lib/rspec/core/reporter.rb +65 -17
- data/lib/rspec/core/runner.rb +38 -14
- data/lib/rspec/core/set.rb +49 -0
- data/lib/rspec/core/shared_example_group.rb +3 -1
- data/lib/rspec/core/shell_escape.rb +49 -0
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/world.rb +31 -20
- metadata +35 -7
- metadata.gz.sig +0 -0
- data/lib/rspec/core/backport_random.rb +0 -339
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a92217ba6e7e8646843f147e18e37e7e0ae135c4
|
4
|
+
data.tar.gz: e4570a04042e8062b594b4fa4ced79df03b7f620
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94d1f44cd702b90bd31088dbc28908732b1ab07a92865c1673d3fd2fcc29839794e661bb4dccdcf58bafb17e18129765e036e4df33f7da1de3b7a79208743b84
|
7
|
+
data.tar.gz: 4822312a6d75661ca374adf584af31f940415524bc787a93cd7f5ce99c24400f61f6f096f920f84ca83bbec2800cca45d5b466cf0135baa053b79a2792f7761d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/Changelog.md
CHANGED
@@ -1,3 +1,78 @@
|
|
1
|
+
### 3.3.0 / 2015-06-12
|
2
|
+
[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.2.3...v3.3.0)
|
3
|
+
|
4
|
+
Enhancements:
|
5
|
+
|
6
|
+
* Expose the reporter used to run examples via `RSpec::Core::Example#reporter`.
|
7
|
+
(Jon Rowe, #1866)
|
8
|
+
* Make `RSpec::Core::Reporter#message` a public supported API. (Jon Rowe, #1866)
|
9
|
+
* Allow custom formatter events to be published via
|
10
|
+
`RSpec::Core::Reporter#publish(event_name, hash_of_attributes)`. (Jon Rowe, #1869)
|
11
|
+
* Remove dependency on the standard library `Set` and replace with `RSpec::Core::Set`.
|
12
|
+
(Jon Rowe, #1870)
|
13
|
+
* Assign a unique id to each example and group so that they can be
|
14
|
+
uniquely identified, even for shared examples (and similar situations)
|
15
|
+
where the location isn't unique. (Myron Marston, #1884)
|
16
|
+
* Use the example id in the rerun command printed for failed examples
|
17
|
+
when the location is not unique. (Myron Marston, #1884)
|
18
|
+
* Add `config.example_status_persistence_file_path` option, which is
|
19
|
+
used to persist the last run status of each example. (Myron Marston, #1888)
|
20
|
+
* Add `:last_run_status` metadata to each example, which indicates what
|
21
|
+
happened the last time an example ran. (Myron Marston, #1888)
|
22
|
+
* Add `--only-failures` CLI option which filters to only the examples
|
23
|
+
that failed the last time they ran. (Myron Marston, #1888)
|
24
|
+
* Add `--next-failure` CLI option which allows you to repeatedly focus
|
25
|
+
on just one of the currently failing examples, then move on to the
|
26
|
+
next failure, etc. (Myron Marston, #1888)
|
27
|
+
* Make `--order random` ordering stable, so that when you rerun a
|
28
|
+
subset with a given seed, the examples will be order consistently
|
29
|
+
relative to each other. (Myron Marston, #1908)
|
30
|
+
* Set example group constant earlier so errors when evaluating the context
|
31
|
+
include the example group name (Myron Marson, #1911)
|
32
|
+
* Make `let` and `subject` threadsafe. (Josh Cheek, #1858)
|
33
|
+
* Add version information into the JSON formatter. (Mark Swinson, #1883)
|
34
|
+
* Add `--bisect` CLI option, which will repeatedly run your suite in
|
35
|
+
order to isolate the failures to the smallest reproducible case.
|
36
|
+
(Myron Marston, #1917)
|
37
|
+
* For `config.include`, `config.extend` and `config.prepend`, apply the
|
38
|
+
module to previously defined matching example groups. (Eugene Kenny, #1935)
|
39
|
+
* When invalid options are parsed, notify users where they came from
|
40
|
+
(e.g. `.rspec` or `~/.rspec` or `ENV['SPEC_OPTS']`) so they can
|
41
|
+
easily find the source of the problem. (Myron Marston, #1940)
|
42
|
+
* Add pending message contents to the json formatter output. (Jon Rowe, #1949)
|
43
|
+
* Add shared group backtrace to the output displayed by the built-in
|
44
|
+
formatters for pending examples that have been fixed. (Myron Marston, #1946)
|
45
|
+
* Add support for `:aggregate_failures` metadata. Tag an example or
|
46
|
+
group with this metadata and it'll use rspec-expectations'
|
47
|
+
`aggregate_failures` feature to allow multiple failures in an example
|
48
|
+
and list them all, rather than aborting on the first failure. (Myron
|
49
|
+
Marston, #1946)
|
50
|
+
* When no formatter implements #message add a fallback to prevent those
|
51
|
+
messages being lost. (Jon Rowe, #1980)
|
52
|
+
* Profiling examples now takes into account time spent in `before(:context)`
|
53
|
+
hooks. (Denis Laliberté, Jon Rowe, #1971)
|
54
|
+
* Improve failure output when an example has multiple exceptions, such
|
55
|
+
as one from an `it` block and one from an `after` block. (Myron Marston, #1985)
|
56
|
+
|
57
|
+
Bug Fixes:
|
58
|
+
|
59
|
+
* Handle invalid UTF-8 strings within exception methods. (Benjamin Fleischer, #1760)
|
60
|
+
* Fix Rake Task quoting of file names with quotes to work properly on
|
61
|
+
Windows. (Myron Marston, #1887)
|
62
|
+
* Fix `RSpec::Core::RakeTask#failure_message` so that it gets printed
|
63
|
+
when the task failed. (Myron Marston, #1905)
|
64
|
+
* Make `let` work properly when defined in a shared context that is applied
|
65
|
+
to an individual example via metadata. (Myron Marston, #1912)
|
66
|
+
* Ensure `rspec/autorun` respects configuration defaults. (Jon Rowe, #1933)
|
67
|
+
* Prevent modules overriding example group defined methods when included,
|
68
|
+
prepended or extended by config defined after an example group. (Eugene Kenny, #1935)
|
69
|
+
* Fix regression which caused shared examples to be mistakenly run when specs
|
70
|
+
where filtered to a particular location. (Ben Axnick, #1963)
|
71
|
+
* Fix time formatting logic so that it displays 70 seconds as "1 minute,
|
72
|
+
10 seconds" rather than "1 minute, 1 second". (Paul Brennan, #1984)
|
73
|
+
* Fix regression where the formatter loader would allow duplicate formatters.
|
74
|
+
(Jon Rowe, #1990)
|
75
|
+
|
1
76
|
### 3.2.3 / 2015-04-06
|
2
77
|
[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.2.2...v3.2.3)
|
3
78
|
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@ rspec-core provides the structure for writing executable examples of how your
|
|
4
4
|
code should behave, and an `rspec` command with tools to constrain which
|
5
5
|
examples get run and tailor the output.
|
6
6
|
|
7
|
-
##
|
7
|
+
## Install
|
8
8
|
|
9
9
|
gem install rspec # for rspec-core, rspec-expectations, rspec-mocks
|
10
10
|
gem install rspec-core # for rspec-core only
|
@@ -14,12 +14,12 @@ Want to run against the `master` branch? You'll need to include the dependent
|
|
14
14
|
RSpec repos as well. Add the following to your `Gemfile`:
|
15
15
|
|
16
16
|
```ruby
|
17
|
-
%w[rspec-core rspec-expectations rspec-mocks rspec-support].each do |lib|
|
17
|
+
%w[rspec rspec-core rspec-expectations rspec-mocks rspec-support].each do |lib|
|
18
18
|
gem lib, :git => "git://github.com/rspec/#{lib}.git", :branch => 'master'
|
19
19
|
end
|
20
20
|
```
|
21
21
|
|
22
|
-
##
|
22
|
+
## Basic Structure
|
23
23
|
|
24
24
|
RSpec uses the words "describe" and "it" so we can express concepts like a conversation:
|
25
25
|
|
@@ -30,6 +30,7 @@ RSpec uses the words "describe" and "it" so we can express concepts like a conve
|
|
30
30
|
RSpec.describe Order do
|
31
31
|
it "sums the prices of its line items" do
|
32
32
|
order = Order.new
|
33
|
+
|
33
34
|
order.add_entry(LineItem.new(:item => Item.new(
|
34
35
|
:price => Money.new(1.11, :USD)
|
35
36
|
)))
|
@@ -37,6 +38,7 @@ RSpec.describe Order do
|
|
37
38
|
:price => Money.new(2.22, :USD),
|
38
39
|
:quantity => 2
|
39
40
|
)))
|
41
|
+
|
40
42
|
expect(order.total).to eq(Money.new(5.55, :USD))
|
41
43
|
end
|
42
44
|
end
|
@@ -49,7 +51,7 @@ Under the hood, an example group is a class in which the block passed to
|
|
49
51
|
`describe` is evaluated. The blocks passed to `it` are evaluated in the
|
50
52
|
context of an _instance_ of that class.
|
51
53
|
|
52
|
-
##
|
54
|
+
## Nested Groups
|
53
55
|
|
54
56
|
You can also declare nested nested groups using the `describe` or `context`
|
55
57
|
methods:
|
@@ -70,7 +72,10 @@ RSpec.describe Order do
|
|
70
72
|
end
|
71
73
|
```
|
72
74
|
|
73
|
-
|
75
|
+
Nested groups are subclasses of the outer example group class, providing
|
76
|
+
the inheritance semantics you'd want for free.
|
77
|
+
|
78
|
+
## Aliases
|
74
79
|
|
75
80
|
You can declare example groups using either `describe` or `context`.
|
76
81
|
For a top level example group, `describe` and `context` are available
|
@@ -81,7 +86,7 @@ patching.
|
|
81
86
|
You can declare examples within a group using any of `it`, `specify`, or
|
82
87
|
`example`.
|
83
88
|
|
84
|
-
##
|
89
|
+
## Shared Examples and Contexts
|
85
90
|
|
86
91
|
Declare a shared example group using `shared_examples`, and then include it
|
87
92
|
in any group using `include_examples`.
|
@@ -111,7 +116,7 @@ pretty much the same as `shared_examples` and `include_examples`, providing
|
|
111
116
|
more accurate naming when you share hooks, `let` declarations, helper methods,
|
112
117
|
etc, but no examples.
|
113
118
|
|
114
|
-
##
|
119
|
+
## Metadata
|
115
120
|
|
116
121
|
rspec-core stores a metadata hash with every example and group, which
|
117
122
|
contains their descriptions, the locations at which they were
|
@@ -123,7 +128,7 @@ Although you probably won't ever need this unless you are writing an
|
|
123
128
|
extension, you can access it from an example like this:
|
124
129
|
|
125
130
|
```ruby
|
126
|
-
it "does something" do
|
131
|
+
it "does something" do |example|
|
127
132
|
expect(example.metadata[:description]).to eq("does something")
|
128
133
|
end
|
129
134
|
```
|
@@ -162,26 +167,106 @@ RSpec.describe Hash do
|
|
162
167
|
end
|
163
168
|
```
|
164
169
|
|
165
|
-
##
|
170
|
+
## A Word on Scope
|
171
|
+
|
172
|
+
RSpec has two scopes:
|
173
|
+
|
174
|
+
* **Example Group**: Example groups are defined by a `describe` or
|
175
|
+
`context` block, which is eagerly evaluated when the spec file is
|
176
|
+
loaded. The block is evaluated in the context of a subclass of
|
177
|
+
`RSpec::Core::ExampleGroup`, or a subclass of the parent example group
|
178
|
+
when you're nesting them.
|
179
|
+
* **Example**: Examples -- typically defined by an `it` block -- and any other
|
180
|
+
blocks with per-example semantics -- such as a `before(:example)` hook -- are
|
181
|
+
evaluated in the context of
|
182
|
+
an _instance_ of the example group class to which the example belongs.
|
183
|
+
Examples are _not_ executed when the spec file is loaded; instead,
|
184
|
+
RSpec waits to run any examples until all spec files have been loaded,
|
185
|
+
at which point it can apply filtering, randomization, etc.
|
186
|
+
|
187
|
+
To make this more concrete, consider this code snippet:
|
188
|
+
|
189
|
+
``` ruby
|
190
|
+
RSpec.describe "Using an array as a stack" do
|
191
|
+
def build_stack
|
192
|
+
[]
|
193
|
+
end
|
194
|
+
|
195
|
+
before(:example) do
|
196
|
+
@stack = build_stack
|
197
|
+
end
|
198
|
+
|
199
|
+
it 'is initially empty' do
|
200
|
+
expect(@stack).to be_empty
|
201
|
+
end
|
202
|
+
|
203
|
+
context "after an item has been pushed" do
|
204
|
+
before(:example) do
|
205
|
+
@stack.push :item
|
206
|
+
end
|
207
|
+
|
208
|
+
it 'allows the pushed item to be popped' do
|
209
|
+
expect(@stack.pop).to eq(:item)
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
```
|
214
|
+
|
215
|
+
Under the covers, this is (roughly) equivalent to:
|
216
|
+
|
217
|
+
``` ruby
|
218
|
+
class UsingAnArrayAsAStack < RSpec::Core::ExampleGroup
|
219
|
+
def build_stack
|
220
|
+
[]
|
221
|
+
end
|
222
|
+
|
223
|
+
def before_example_1
|
224
|
+
@stack = build_stack
|
225
|
+
end
|
226
|
+
|
227
|
+
def it_is_initially_empty
|
228
|
+
expect(@stack).to be_empty
|
229
|
+
end
|
230
|
+
|
231
|
+
class AfterAnItemHasBeenPushed < self
|
232
|
+
def before_example_2
|
233
|
+
@stack.push :item
|
234
|
+
end
|
235
|
+
|
236
|
+
def it_allows_the_pushed_item_to_be_popped
|
237
|
+
expect(@stack.pop).to eq(:item)
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
```
|
242
|
+
|
243
|
+
To run these examples, RSpec would (roughly) do the following:
|
244
|
+
|
245
|
+
``` ruby
|
246
|
+
example_1 = UsingAnArrayAsAStack.new
|
247
|
+
example_1.before_example_1
|
248
|
+
example_1.it_is_initially_empty
|
249
|
+
|
250
|
+
example_2 = UsingAnArrayAsAStack::AfterAnItemHasBeenPushed.new
|
251
|
+
example_2.before_example_1
|
252
|
+
example_2.before_example_2
|
253
|
+
example_2.it_allows_the_pushed_item_to_be_popped
|
254
|
+
```
|
255
|
+
|
256
|
+
## The `rspec` Command
|
166
257
|
|
167
258
|
When you install the rspec-core gem, it installs the `rspec` executable,
|
168
259
|
which you'll use to run rspec. The `rspec` command comes with many useful
|
169
260
|
options.
|
170
261
|
Run `rspec --help` to see the complete list.
|
171
262
|
|
172
|
-
##
|
263
|
+
## Store Command Line Options `.rspec`
|
173
264
|
|
174
265
|
You can store command line options in a `.rspec` file in the project's root
|
175
266
|
directory, and the `rspec` command will read them as though you typed them on
|
176
267
|
the command line.
|
177
268
|
|
178
|
-
##
|
179
|
-
|
180
|
-
rspec-core no longer ships with an Autotest extension, if you require Autotest
|
181
|
-
integration, please use the `rspec-autotest` gem and see [rspec/rspec-autotest](https://github.com/rspec/rspec-autotest)
|
182
|
-
for details
|
183
|
-
|
184
|
-
## get started
|
269
|
+
## Get Started
|
185
270
|
|
186
271
|
Start with a simple example of behavior you expect from your system. Do
|
187
272
|
this before you write any implementation code:
|
@@ -204,13 +289,12 @@ $ rspec spec/calculator_spec.rb
|
|
204
289
|
./spec/calculator_spec.rb:1: uninitialized constant Calculator
|
205
290
|
```
|
206
291
|
|
207
|
-
|
292
|
+
Address the failure by defining a skeleton of the `Calculator` class:
|
208
293
|
|
209
294
|
```ruby
|
210
295
|
# in lib/calculator.rb
|
211
296
|
class Calculator
|
212
|
-
def add(a,b)
|
213
|
-
a + b
|
297
|
+
def add(a, b)
|
214
298
|
end
|
215
299
|
end
|
216
300
|
```
|
@@ -223,6 +307,39 @@ Be sure to require the implementation file in the spec:
|
|
223
307
|
require "calculator"
|
224
308
|
```
|
225
309
|
|
310
|
+
Now run the spec again, and watch the expectation fail:
|
311
|
+
|
312
|
+
```
|
313
|
+
$ rspec spec/calculator_spec.rb
|
314
|
+
F
|
315
|
+
|
316
|
+
Failures:
|
317
|
+
|
318
|
+
1) Calculator#add returns the sum of its arguments
|
319
|
+
Failure/Error: expect(Calculator.new.add(1, 2)).to eq(3)
|
320
|
+
|
321
|
+
expected: 3
|
322
|
+
got: nil
|
323
|
+
|
324
|
+
(compared using ==)
|
325
|
+
# ./spec/calcalator_spec.rb:6:in `block (3 levels) in <top (required)>'
|
326
|
+
|
327
|
+
Finished in 0.00131 seconds (files took 0.10968 seconds to load)
|
328
|
+
1 example, 1 failure
|
329
|
+
|
330
|
+
Failed examples:
|
331
|
+
|
332
|
+
rspec ./spec/calcalator_spec.rb:5 # Calculator#add returns the sum of its arguments
|
333
|
+
```
|
334
|
+
|
335
|
+
Implement the simplest solution, by changing the definition of `Calculator#add` to:
|
336
|
+
|
337
|
+
```ruby
|
338
|
+
def add(a, b)
|
339
|
+
a + b
|
340
|
+
end
|
341
|
+
```
|
342
|
+
|
226
343
|
Now run the spec again, and watch it pass:
|
227
344
|
|
228
345
|
```
|
data/lib/rspec/autorun.rb
CHANGED
data/lib/rspec/core.rb
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
$_rspec_core_load_started_at = Time.now
|
3
3
|
# rubocop:enable Style/GlobalVars
|
4
4
|
|
5
|
-
require 'rbconfig'
|
6
|
-
|
7
5
|
require "rspec/support"
|
8
6
|
RSpec::Support.require_rspec_support "caller_filter"
|
9
7
|
|
@@ -13,6 +11,7 @@ RSpec::Support.define_optimized_require_for_rspec(:core) { |f| require_relative
|
|
13
11
|
version
|
14
12
|
warnings
|
15
13
|
|
14
|
+
set
|
16
15
|
flat_map
|
17
16
|
filter_manager
|
18
17
|
dsl
|
@@ -82,12 +81,9 @@ module RSpec
|
|
82
81
|
# @see RSpec.configure
|
83
82
|
# @see Core::Configuration
|
84
83
|
def self.configuration
|
85
|
-
@configuration ||=
|
86
|
-
config = RSpec::Core::Configuration.new
|
87
|
-
config.expose_dsl_globally = true
|
88
|
-
config
|
89
|
-
end
|
84
|
+
@configuration ||= RSpec::Core::Configuration.new
|
90
85
|
end
|
86
|
+
configuration.expose_dsl_globally = true
|
91
87
|
|
92
88
|
# Yields the global configuration to a block.
|
93
89
|
# @yield [Configuration] global configuration
|
@@ -123,20 +119,13 @@ module RSpec
|
|
123
119
|
# end
|
124
120
|
#
|
125
121
|
def self.current_example
|
126
|
-
|
122
|
+
RSpec::Support.thread_local_data[:current_example]
|
127
123
|
end
|
128
124
|
|
129
125
|
# Set the current example being executed.
|
130
126
|
# @api private
|
131
127
|
def self.current_example=(example)
|
132
|
-
|
133
|
-
end
|
134
|
-
|
135
|
-
# @private
|
136
|
-
# A single thread local variable so we don't excessively pollute that
|
137
|
-
# namespace.
|
138
|
-
def self.thread_local_metadata
|
139
|
-
Thread.current[:_rspec] ||= { :shared_example_group_inclusions => [] }
|
128
|
+
RSpec::Support.thread_local_data[:current_example] = example
|
140
129
|
end
|
141
130
|
|
142
131
|
# @private
|
@@ -147,6 +136,9 @@ module RSpec
|
|
147
136
|
|
148
137
|
# Namespace for the rspec-core code.
|
149
138
|
module Core
|
139
|
+
autoload :ExampleStatusPersister, "rspec/core/example_status_persister"
|
140
|
+
autoload :Profiler, "rspec/core/profiler"
|
141
|
+
|
150
142
|
# @private
|
151
143
|
# This avoids issues with reporting time caused by examples that
|
152
144
|
# change the value/meaning of Time.now without properly restoring
|
@@ -31,7 +31,7 @@ module RSpec
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def format_backtrace(backtrace, options={})
|
34
|
-
return backtrace if options[:full_backtrace]
|
34
|
+
return backtrace if options[:full_backtrace] || backtrace.empty?
|
35
35
|
|
36
36
|
backtrace.map { |l| backtrace_line(l) }.compact.
|
37
37
|
tap do |filtered|
|
@@ -47,8 +47,6 @@ module RSpec
|
|
47
47
|
|
48
48
|
def backtrace_line(line)
|
49
49
|
Metadata.relative_path(line) unless exclude?(line)
|
50
|
-
rescue SecurityError
|
51
|
-
nil
|
52
50
|
end
|
53
51
|
|
54
52
|
def exclude?(line)
|
@@ -0,0 +1,66 @@
|
|
1
|
+
RSpec::Support.require_rspec_core "bisect/server"
|
2
|
+
RSpec::Support.require_rspec_core "bisect/runner"
|
3
|
+
RSpec::Support.require_rspec_core "bisect/example_minimizer"
|
4
|
+
RSpec::Support.require_rspec_core "formatters/bisect_progress_formatter"
|
5
|
+
|
6
|
+
module RSpec
|
7
|
+
module Core
|
8
|
+
module Bisect
|
9
|
+
# @private
|
10
|
+
# The main entry point into the bisect logic. Coordinates among:
|
11
|
+
# - Bisect::Server: Receives suite results.
|
12
|
+
# - Bisect::Runner: Runs a set of examples and directs the results
|
13
|
+
# to the server.
|
14
|
+
# - Bisect::ExampleMinimizer: Contains the core bisect logic.
|
15
|
+
# - Formatters::BisectProgressFormatter: provides progress updates
|
16
|
+
# to the user.
|
17
|
+
class Coordinator
|
18
|
+
def self.bisect_with(original_cli_args, configuration, formatter)
|
19
|
+
new(original_cli_args, configuration, formatter).bisect
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize(original_cli_args, configuration, formatter)
|
23
|
+
@original_cli_args = original_cli_args
|
24
|
+
@configuration = configuration
|
25
|
+
@formatter = formatter
|
26
|
+
end
|
27
|
+
|
28
|
+
def bisect
|
29
|
+
@configuration.add_formatter @formatter
|
30
|
+
|
31
|
+
reporter.close_after do
|
32
|
+
repro = Server.run do |server|
|
33
|
+
runner = Runner.new(server, @original_cli_args)
|
34
|
+
minimizer = ExampleMinimizer.new(runner, reporter)
|
35
|
+
|
36
|
+
gracefully_abort_on_sigint(minimizer)
|
37
|
+
minimizer.find_minimal_repro
|
38
|
+
minimizer.repro_command_for_currently_needed_ids
|
39
|
+
end
|
40
|
+
|
41
|
+
reporter.publish(:bisect_repro_command, :repro => repro)
|
42
|
+
end
|
43
|
+
|
44
|
+
true
|
45
|
+
rescue BisectFailedError => e
|
46
|
+
reporter.publish(:bisect_failed, :failure_explanation => e.message)
|
47
|
+
false
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def reporter
|
53
|
+
@configuration.reporter
|
54
|
+
end
|
55
|
+
|
56
|
+
def gracefully_abort_on_sigint(minimizer)
|
57
|
+
trap('INT') do
|
58
|
+
repro = minimizer.repro_command_for_currently_needed_ids
|
59
|
+
reporter.publish(:bisect_aborted, :repro => repro)
|
60
|
+
exit(1)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|