test-loop 10.0.1 → 11.0.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.
- data/README.md +12 -17
- data/lib/test/loop/notify.rb +1 -1
- data/lib/test/loop/support/minitest.rb +5 -0
- data/lib/test/loop/support/rails.rb +21 -0
- data/lib/test/loop/support/testunit.rb +7 -0
- data/lib/test/loop.rb +10 -4
- metadata +5 -3
- data/lib/test/loop/rails.rb +0 -10
data/README.md
CHANGED
@@ -30,7 +30,7 @@ Features
|
|
30
30
|
|
31
31
|
* Configurable through a `.test-loop` file in your current working directory.
|
32
32
|
|
33
|
-
* Implemented in less than
|
33
|
+
* Implemented in less than 250 lines (SLOC) of pure Ruby code! :-)
|
34
34
|
|
35
35
|
------------------------------------------------------------------------------
|
36
36
|
Installation
|
@@ -179,12 +179,13 @@ your configuration file:
|
|
179
179
|
}
|
180
180
|
|
181
181
|
For example, to see on-screen-display notifications only about test failures,
|
182
|
-
add the following to your configuration file
|
182
|
+
add the following to your configuration file (**NOTE:** the `test/loop/notify`
|
183
|
+
preset does this for you):
|
183
184
|
|
184
185
|
Test::Loop.after_each_test.push lambda {
|
185
186
|
|test_file, log_file, run_status, started_at, elapsed_time|
|
186
187
|
|
187
|
-
unless run_status.success?
|
188
|
+
unless run_status.success? or run_status.signaled?
|
188
189
|
title = 'FAIL at %s in %0.1fs' % [started_at.strftime('%r'), elapsed_time]
|
189
190
|
|
190
191
|
message = test_file
|
@@ -197,10 +198,6 @@ add the following to your configuration file:
|
|
197
198
|
end
|
198
199
|
}
|
199
200
|
|
200
|
-
Note that the above functionality is available as a configuration preset:
|
201
|
-
|
202
|
-
require 'test/loop/notify'
|
203
|
-
|
204
201
|
For example, to see on-screen-display notifications about completed test runs,
|
205
202
|
regardless of whether they passed or failed, add the following to your
|
206
203
|
configuration file:
|
@@ -230,26 +227,24 @@ The following sub-libraries provide "preset" configurations. To use them,
|
|
230
227
|
simply add the require() lines shown below to your `.test-loop` file or to
|
231
228
|
your application's `test/test_helper.rb` or `spec/spec_helper.rb` file.
|
232
229
|
|
233
|
-
|
234
|
-
|
235
|
-
require 'test/loop/rails'
|
236
|
-
|
237
|
-
* On-screen-display notifications for test failures:
|
230
|
+
### require 'test/loop/notify'
|
238
231
|
|
239
|
-
|
232
|
+
Shows on-screen-display notifications for test failures.
|
240
233
|
|
241
234
|
------------------------------------------------------------------------------
|
242
235
|
Known issues
|
243
236
|
------------------------------------------------------------------------------
|
244
237
|
|
245
|
-
|
238
|
+
### Ruby on Rails
|
246
239
|
|
247
|
-
* Ensure that your `config/environments/test.rb` file disables class caching
|
240
|
+
* Ensure that your `config/environments/test.rb` file disables class caching
|
241
|
+
as follows (**NOTE:** this is done automatically for you if you use Rails
|
242
|
+
3):
|
248
243
|
|
249
244
|
config.cache_classes = false
|
250
245
|
|
251
|
-
Otherwise, test-loop will appear to ignore
|
252
|
-
models, controllers, helpers,
|
246
|
+
Otherwise, test-loop will appear to ignore source-code changes in your
|
247
|
+
models, controllers, helpers, and other Ruby source files.
|
253
248
|
|
254
249
|
* SQLite3 [raises `SQLite3::BusyException: database is locked` errors](
|
255
250
|
https://github.com/sunaku/test-loop/issues/2 ) because test-loop runs your
|
data/lib/test/loop/notify.rb
CHANGED
@@ -2,7 +2,7 @@ require 'test/loop'
|
|
2
2
|
|
3
3
|
Test::Loop.after_each_test.push lambda {
|
4
4
|
|test_file, log_file, run_status, started_at, elapsed_time|
|
5
|
-
unless run_status.success?
|
5
|
+
unless run_status.success? or run_status.signaled?
|
6
6
|
title = 'FAIL at %s in %0.1fs' % [started_at.strftime('%r'), elapsed_time]
|
7
7
|
message = test_file
|
8
8
|
Thread.new do # run in background
|
@@ -0,0 +1,21 @@
|
|
1
|
+
if defined? Rails::VERSION
|
2
|
+
Test::Loop.reabsorb_file_globs.push(
|
3
|
+
'config/**/*.{rb,yml}',
|
4
|
+
'test/factories/*.rb',
|
5
|
+
'Gemfile.lock'
|
6
|
+
)
|
7
|
+
|
8
|
+
Test::Loop.test_file_matchers['app/**/*.rb'] =
|
9
|
+
Test::Loop.test_file_matchers['lib/**/*.rb']
|
10
|
+
|
11
|
+
class << Test::Loop
|
12
|
+
class Railtie < Rails::Railtie
|
13
|
+
config.before_initialize do |app|
|
14
|
+
if app.config.cache_classes
|
15
|
+
warn "test-loop: Setting #{app.class}.config.cache_classes = false"
|
16
|
+
app.config.cache_classes = false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/test/loop.rb
CHANGED
@@ -57,6 +57,7 @@ module Test
|
|
57
57
|
register_signals
|
58
58
|
load_user_config
|
59
59
|
absorb_overhead
|
60
|
+
load_lib_support
|
60
61
|
run_test_loop
|
61
62
|
|
62
63
|
rescue Interrupt
|
@@ -138,6 +139,10 @@ module Test
|
|
138
139
|
end
|
139
140
|
end
|
140
141
|
|
142
|
+
def load_lib_support
|
143
|
+
Dir[File.expand_path '../loop/support/*.rb', __FILE__].each {|f| load f }
|
144
|
+
end
|
145
|
+
|
141
146
|
def pause_momentarily
|
142
147
|
sleep 1
|
143
148
|
end
|
@@ -200,11 +205,12 @@ module Test
|
|
200
205
|
# workers can be killed by sending it to the entire process group
|
201
206
|
trap :TERM, :DEFAULT
|
202
207
|
|
208
|
+
# this signal is honored by master and ignored in workers
|
209
|
+
trap :INT, :IGNORE
|
210
|
+
|
203
211
|
# capture test output in log file because tests are run in parallel
|
204
212
|
# which makes it difficult to understand interleaved output thereof
|
205
|
-
$stdout.reopen
|
206
|
-
$stdout.sync = true
|
207
|
-
$stderr.reopen $stdout
|
213
|
+
$stderr.reopen($stdout.reopen(log_file, 'w')).sync = true
|
208
214
|
|
209
215
|
# determine which test blocks have changed inside the test file
|
210
216
|
test_names = Diff::LCS.diff(old_lines, new_lines).flatten.map do |change|
|
@@ -243,7 +249,7 @@ module Test
|
|
243
249
|
# report test results along with any failure logs
|
244
250
|
if run_status.success?
|
245
251
|
notify ANSI_GREEN % "PASS #{test_file}"
|
246
|
-
|
252
|
+
elsif run_status.exited?
|
247
253
|
notify ANSI_RED % "FAIL #{test_file}"
|
248
254
|
STDERR.print File.read(log_file)
|
249
255
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: test-loop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version:
|
5
|
+
version: 11.0.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Suraj N. Kurapati
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-04-
|
14
|
+
date: 2011-04-14 00:00:00 -07:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
@@ -37,8 +37,10 @@ files:
|
|
37
37
|
- README.md
|
38
38
|
- bin/test-loop
|
39
39
|
- lib/test/loop.rb
|
40
|
-
- lib/test/loop/rails.rb
|
41
40
|
- lib/test/loop/notify.rb
|
41
|
+
- lib/test/loop/support/rails.rb
|
42
|
+
- lib/test/loop/support/minitest.rb
|
43
|
+
- lib/test/loop/support/testunit.rb
|
42
44
|
has_rdoc: true
|
43
45
|
homepage: http://github.com/sunaku/test-loop
|
44
46
|
licenses: []
|
data/lib/test/loop/rails.rb
DELETED