test-loop 9.0.1 → 9.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md +8 -18
  2. data/bin/test-loop +17 -10
  3. metadata +18 -3
data/README.md CHANGED
@@ -53,7 +53,8 @@ As a Ruby gem:
53
53
 
54
54
  As a Git clone:
55
55
 
56
- gem install diff-lcs
56
+ gem install diff-lcs -v '>= 1.1.2'
57
+ gem install ansi -v '>= 1.2.2'
57
58
  git clone git://github.com/sunaku/test-loop
58
59
 
59
60
 
@@ -155,19 +156,15 @@ you can query and modify the `Test::Loop` OpenStruct configuration as follows:
155
156
  execution began, and (5) how many seconds it took for the overall test
156
157
  execution to complete.
157
158
 
158
- For example, to see on-screen-display notifications about test failures only
159
- (not successes) and also see their corresponding failure logs in your
160
- terminal, add the following to your configuration file:
159
+ For example, to see on-screen-display notifications only about test
160
+ failures, add the following to your configuration file:
161
161
 
162
162
  Test::Loop.after_each_test = lambda do |test_file, log_file, run_status, started_at, elapsed_time|
163
163
  unless run_status.success?
164
- # display the failure log
165
- divider = '#' * 80
166
- STDERR.print [divider, File.read(log_file), divider, nil].join("\n")
167
-
168
- # notify user about failure
169
164
  title = 'FAIL at %s in %0.1fs' % [started_at.strftime('%r'), elapsed_time]
165
+
170
166
  message = test_file
167
+
171
168
  Thread.new do # run in background
172
169
  system 'notify-send', '-i', 'dialog-error', title, message or
173
170
  system 'growlnotify', '-a', 'Xcode', '-m', message, title or
@@ -177,19 +174,12 @@ you can query and modify the `Test::Loop` OpenStruct configuration as follows:
177
174
  end
178
175
 
179
176
  For example, to see on-screen-display notifications about completed test
180
- runs (both successes and failures) and also see failure logs for failed test
181
- runs in your terminal, add the following to your configuration file:
177
+ runs, regardless of whether they passed or failed, add the following to your
178
+ configuration file:
182
179
 
183
180
  Test::Loop.after_each_test = lambda do |test_file, log_file, run_status, started_at, elapsed_time|
184
181
  success = run_status.success?
185
182
 
186
- # display the failure log
187
- unless success
188
- divider = '#' * 80
189
- STDERR.print [divider, File.read(log_file), divider, nil].join("\n")
190
- end
191
-
192
- # notify the user about test completion
193
183
  title = '%s at %s in %0.1fs' %
194
184
  [success ? 'PASS' : 'FAIL', started_at.strftime('%X'), elapsed_time]
195
185
 
data/bin/test-loop CHANGED
@@ -24,6 +24,7 @@
24
24
 
25
25
  require 'ostruct'
26
26
  require 'diff/lcs'
27
+ require 'ansi'
27
28
 
28
29
  module Test
29
30
  Loop = OpenStruct.new
@@ -37,8 +38,8 @@ module Test
37
38
  # source files that correspond to test files
38
39
  '{lib,app}/**/*.rb' => lambda do |path|
39
40
  extn = File.extname(path)
40
- name = File.basename(path, extn)
41
- "{test,spec}/**/#{name}_{test,spec}#{extn}"
41
+ base = File.basename(path, extn)
42
+ "{test,spec}/**/#{base}_{test,spec}#{extn}"
42
43
  end,
43
44
 
44
45
  # the actual test files themselves
@@ -55,7 +56,7 @@ module Test
55
56
  Loop.before_each_test = lambda do |test_file, log_file, test_names|
56
57
  unless test_names.empty?
57
58
  test_name_pattern = test_names.map do |name|
58
- # sanitize string interpolation and non-method-name characters
59
+ # sanitize string interpolations and invalid method name characters
59
60
  name.gsub(/\#\{.*?\}/, ' ').strip.gsub(/\W+/, '.*')
60
61
  end.join('|')
61
62
 
@@ -208,15 +209,21 @@ module Test
208
209
  notify "TEST #{test_file}"
209
210
 
210
211
  # wait for worker to finish
211
- begin
212
- Process.waitpid worker_pid
213
- rescue Errno::ECHILD
214
- # worker finished and the OS has forgotten about it already
215
- end
212
+ Process.waitpid worker_pid
213
+ run_status = $?
216
214
  elapsed_time = Time.now - @last_ran_at
217
215
 
218
- notify "#{$?.success? && :PASS || :FAIL} #{test_file}"
219
- after_each_test.call test_file, log_file, $?, @last_ran_at, elapsed_time
216
+ # report test results along with any failure logs
217
+ if run_status.success?
218
+ notify ANSI::Code.green("PASS #{test_file}")
219
+ else
220
+ notify ANSI::Code.red("FAIL #{test_file}")
221
+ STDERR.print File.read(log_file)
222
+ end
223
+
224
+ after_each_test.call \
225
+ test_file, log_file, run_status, @last_ran_at, elapsed_time
226
+
220
227
  @running_files_lock.synchronize { @running_files.delete test_file }
221
228
  end
222
229
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 9
7
- - 0
8
7
  - 1
9
- version: 9.0.1
8
+ - 0
9
+ version: 9.1.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Suraj N. Kurapati
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-02-18 00:00:00 -08:00
17
+ date: 2011-02-23 00:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -32,6 +32,21 @@ dependencies:
32
32
  version: 1.1.2
33
33
  type: :runtime
34
34
  version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: ansi
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 1
45
+ - 2
46
+ - 2
47
+ version: 1.2.2
48
+ type: :runtime
49
+ version_requirements: *id002
35
50
  description:
36
51
  email:
37
52
  executables: