tork 17.0.1 → 17.1.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/HISTORY.markdown +22 -0
- data/LICENSE +1 -0
- data/README.markdown +58 -26
- data/bin/tork +1 -1
- data/bin/tork-driver +1 -1
- data/bin/tork-herald +1 -1
- data/bin/tork-master +1 -1
- data/lib/tork/config.rb +8 -4
- data/lib/tork/config/factory_girl.rb +10 -0
- data/lib/tork/config/notify.rb +34 -0
- data/lib/tork/driver.rb +4 -3
- data/lib/tork/master.rb +3 -1
- data/lib/tork/version.rb +1 -1
- data/man/man1/tork-driver.1 +1 -1
- data/man/man1/tork-herald.1 +1 -1
- data/man/man1/tork-master.1 +1 -1
- data/man/man1/tork.1 +1 -1
- metadata +16 -14
data/HISTORY.markdown
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
------------------------------------------------------------------------------
|
2
|
+
Version 17.1.0 (2012-01-30)
|
3
|
+
------------------------------------------------------------------------------
|
4
|
+
|
5
|
+
Improvements:
|
6
|
+
|
7
|
+
* Added `Tork::Config.test_event_hooks` configuration option.
|
8
|
+
|
9
|
+
* Added `tork/config/notify` configuration helper for receiving
|
10
|
+
edge-triggered notifications (via libnotify, growl, or
|
11
|
+
xmessage) about changes in test files' pass/fail status.
|
12
|
+
|
13
|
+
* Added `tork/config/factory_girl` configuration helper for properly
|
14
|
+
clearing factory definitions before forking and then finding them after
|
15
|
+
forking to avoid `FactoryGirl::DuplicateDefinitionError`. (Mark Hayes)
|
16
|
+
|
17
|
+
* Lambda functions in `Tork::Config.test_file_globbers` can now return
|
18
|
+
multiple globs in an array, in addition to just a single glob or `nil`.
|
19
|
+
|
20
|
+
* Added support for the MiniTest convention of naming test files as
|
21
|
+
`test/**/test_*.rb` and `spec/**/spec_*.rb`.
|
22
|
+
|
1
23
|
------------------------------------------------------------------------------
|
2
24
|
Version 17.0.1 (2012-01-29)
|
3
25
|
------------------------------------------------------------------------------
|
data/LICENSE
CHANGED
@@ -11,6 +11,7 @@ Thanks to 2012 Spencer Steffen <spencer@citrusme.com>
|
|
11
11
|
Thanks to 2012 Jesse Cooke <jesse@jc00ke.com>
|
12
12
|
Thanks to 2012 Benjamin Quorning <benjamin@quorning.net>
|
13
13
|
Thanks to 2012 Nicolas Fouché <nicolas.fouche@gmail.com>
|
14
|
+
Thanks to 2012 Mark Hayes <mark@deployfx.com>
|
14
15
|
|
15
16
|
Permission to use, copy, modify, and/or distribute this software for any
|
16
17
|
purpose with or without fee is hereby granted, provided that the above
|
data/README.markdown
CHANGED
@@ -39,7 +39,7 @@ Features
|
|
39
39
|
|
40
40
|
* You can override the modular `tork*` programs with your own in $PATH.
|
41
41
|
|
42
|
-
* Its core is written in
|
42
|
+
* Its core is written in about 370 lines (SLOC) of pure Ruby code! :-)
|
43
43
|
|
44
44
|
### Architecture
|
45
45
|
|
@@ -105,7 +105,7 @@ You can monitor your test processes from another terminal:
|
|
105
105
|
|
106
106
|
### With [Ruby on Rails]
|
107
107
|
|
108
|
-
For Rails 3 or newer, use the rails configuration helper
|
108
|
+
For Rails 3 or newer, use the `tork/config/rails` configuration helper.
|
109
109
|
Otherwise, ensure that your `config/environments/test.rb` file contains:
|
110
110
|
|
111
111
|
config.cache_classes = false
|
@@ -117,26 +117,6 @@ adapter][memory_test_fix]. Otherwise, you *might* face these errors:
|
|
117
117
|
|
118
118
|
> cannot start a transaction within a transaction
|
119
119
|
|
120
|
-
### With [factory_girl]
|
121
|
-
|
122
|
-
Do not load your factories into the master process as part of your test
|
123
|
-
execution overhead in your test/spec helper because that would necessitate
|
124
|
-
overhead reabsorption whenever you change or create factory definitions.
|
125
|
-
|
126
|
-
Instead, use `at_exit()` to wait until (1) after the master process has forked
|
127
|
-
a worker process and (2) just before that worker process runs its test suite
|
128
|
-
(whose execution is started by your test framework's own `at_exit()` handler):
|
129
|
-
|
130
|
-
# in your test/spec helper
|
131
|
-
require 'factory_girl'
|
132
|
-
at_exit { FactoryGirl.find_definitions unless $! }
|
133
|
-
|
134
|
-
This way, worker processes will pick up changes in your factories "for free"
|
135
|
-
whenever they (re)run your test files. Skip if Ruby is exiting because of a
|
136
|
-
raised exception (denoted by the `$!` global variable in the snippet above).
|
137
|
-
|
138
|
-
As a bonus, this arrangement also works when tests are run outside of Tork!
|
139
|
-
|
140
120
|
------------------------------------------------------------------------------
|
141
121
|
Configuration
|
142
122
|
------------------------------------------------------------------------------
|
@@ -172,6 +152,16 @@ Or in your configuration file:
|
|
172
152
|
|
173
153
|
require 'tork/config/cucumber'
|
174
154
|
|
155
|
+
### [factory_girl]
|
156
|
+
|
157
|
+
At the command line:
|
158
|
+
|
159
|
+
tork factory_girl
|
160
|
+
|
161
|
+
Or in your configuration file:
|
162
|
+
|
163
|
+
require 'tork/config/factory_girl'
|
164
|
+
|
175
165
|
### [parallel_tests]
|
176
166
|
|
177
167
|
At the command line:
|
@@ -202,6 +192,16 @@ Or in your configuration file:
|
|
202
192
|
|
203
193
|
require 'tork/config/logdir'
|
204
194
|
|
195
|
+
### Receive notifications via libnotify, growl, or xmessage(1)
|
196
|
+
|
197
|
+
At the command line:
|
198
|
+
|
199
|
+
tork notify
|
200
|
+
|
201
|
+
Or in your configuration file:
|
202
|
+
|
203
|
+
require 'tork/config/notify'
|
204
|
+
|
205
205
|
------------------------------------------------------------------------------
|
206
206
|
Configuration options
|
207
207
|
-----------------------------------------------------------------------------
|
@@ -235,8 +235,9 @@ your Ruby application.
|
|
235
235
|
|
236
236
|
Hash that maps (1) a regular expression describing a set of file paths to (2)
|
237
237
|
a lambda function that accepts the path to a changed file and a `MatchData`
|
238
|
-
object containing the results of the regular expression matching, and yields
|
239
|
-
file globbing
|
238
|
+
object containing the results of the regular expression matching, and yields
|
239
|
+
one or more file globbing patterns (a single string, or an array of strings)
|
240
|
+
that describe a set of test files that need to be run.
|
240
241
|
|
241
242
|
In other words, whenever the source files (the regular expression) change,
|
242
243
|
their associated test files (result of calling the lambda function) are run.
|
@@ -254,6 +255,23 @@ Then you would add the following to your configuration file:
|
|
254
255
|
"{test,spec}/**/#{name}_#{name.reverse}.rb"
|
255
256
|
end
|
256
257
|
|
258
|
+
Going further, if you suppose that test files could optionally have "test" or
|
259
|
+
"spec" prefixed or appended to their already peculiar names, like so:
|
260
|
+
|
261
|
+
* `lib/hello.rb` => `test/hello_olleh_test.rb`
|
262
|
+
* `lib/hello.rb` => `test/test_hello_olleh.rb`
|
263
|
+
* `app/world.rb` => `spec/world_ldrow_spec.rb`
|
264
|
+
* `app/world.rb` => `spec/spec_world_ldrow.rb`
|
265
|
+
|
266
|
+
Then you would add the following to your configuration file:
|
267
|
+
|
268
|
+
Tork::Config.test_file_globbers[%r<^(lib|app)/.+\.rb$>] = lambda do |path, matches|
|
269
|
+
name = File.basename(path, '.rb')
|
270
|
+
["{test,spec}/**/#{name}_#{name.reverse}.rb",
|
271
|
+
"{test,spec}/**/#{name}_#{name.reverse}_{test,spec}.rb",
|
272
|
+
"{test,spec}/**/{test,spec}_#{name}_#{name.reverse}.rb"]
|
273
|
+
end
|
274
|
+
|
257
275
|
In addition, these lambda functions can return `nil` if they do not wish for a
|
258
276
|
particular source file to be tested. For example, to ignore tests for all
|
259
277
|
source files except those within a `models/` directory, you would write:
|
@@ -261,12 +279,14 @@ source files except those within a `models/` directory, you would write:
|
|
261
279
|
Tork::Config.test_file_globbers[%r<^(lib|app)/.+\.rb$>] = lambda do |path, matches|
|
262
280
|
if path.include? '/models/'
|
263
281
|
"{test,spec}/**/#{File.basename(path)}"
|
282
|
+
#else # implied by the Ruby language
|
283
|
+
#nil # implied by the Ruby language
|
264
284
|
end
|
265
285
|
end
|
266
286
|
|
267
287
|
### Tork::Config.before_fork_hooks
|
268
288
|
|
269
|
-
Array of lambda functions that are
|
289
|
+
Array of lambda functions that are invoked inside `tork-master` before a
|
270
290
|
worker process is forked to run a test file. These functions are given:
|
271
291
|
|
272
292
|
1. The sequence number of the worker process that will be forked shortly.
|
@@ -293,7 +313,7 @@ For example, to see some real values:
|
|
293
313
|
|
294
314
|
### Tork::Config.after_fork_hooks
|
295
315
|
|
296
|
-
Array of lambda functions that are
|
316
|
+
Array of lambda functions that are invoked inside a worker process forked
|
297
317
|
by `tork-master`. These functions are given:
|
298
318
|
|
299
319
|
1. The sequence number of the worker process.
|
@@ -323,6 +343,18 @@ The first function in this array instructs Test::Unit and RSpec to only run
|
|
323
343
|
those tests that are defined on the given line numbers. This accelerates your
|
324
344
|
test-driven development cycle by only running tests you are currently editing.
|
325
345
|
|
346
|
+
### Tork::Config.test_event_hooks
|
347
|
+
|
348
|
+
Array of lambda functions that are invoked inside `tork-driver` whenever it
|
349
|
+
receives a status message (passed into those functions) from `tork-master`.
|
350
|
+
Run `tork-master --help` for more information about these status messages.
|
351
|
+
|
352
|
+
For example, to see some real values:
|
353
|
+
|
354
|
+
Tork::Config.test_event_hooks.push lambda {|message_from_tork_master|
|
355
|
+
p :test_event_hooks => message_from_tork_master
|
356
|
+
}
|
357
|
+
|
326
358
|
------------------------------------------------------------------------------
|
327
359
|
License
|
328
360
|
------------------------------------------------------------------------------
|
data/bin/tork
CHANGED
data/bin/tork-driver
CHANGED
data/bin/tork-herald
CHANGED
data/bin/tork-master
CHANGED
data/lib/tork/config.rb
CHANGED
@@ -22,19 +22,21 @@ module Tork
|
|
22
22
|
Config.overhead_file_globs = ['{test,spec}/{test,spec}_helper.rb']
|
23
23
|
|
24
24
|
Config.reabsorb_file_greps = [/^#{Regexp.quote(_user_config_file)}$/,
|
25
|
-
%r
|
25
|
+
%r<^(test|spec)/\1_helper\.rb$>]
|
26
26
|
|
27
|
-
Config.all_test_file_globs = ['{test,spec}/**/*_{test,spec}.rb'
|
27
|
+
Config.all_test_file_globs = ['{test,spec}/**/*_{test,spec}.rb',
|
28
|
+
'{test,spec}/**/{test,spec}_*.rb']
|
28
29
|
|
29
30
|
Config.test_file_globbers = {
|
30
31
|
# source files that correspond to test files
|
31
32
|
%r<^lib/.+\.rb$> => lambda do |path, matches|
|
32
33
|
base = File.basename(path, '.rb')
|
33
|
-
"{test,spec}/**/#{base}_{test,spec}.rb"
|
34
|
+
["{test,spec}/**/#{base}_{test,spec}.rb",
|
35
|
+
"{test,spec}/**/{test,spec}_#{base}.rb"]
|
34
36
|
end,
|
35
37
|
|
36
38
|
# the actual test files themselves
|
37
|
-
%r<^(test|spec)
|
39
|
+
%r<^(test|spec)/.*(\1_[^/]+|[^/]+_\1)\.rb$> => proc {|path| path }
|
38
40
|
}
|
39
41
|
|
40
42
|
Config.before_fork_hooks = []
|
@@ -74,6 +76,8 @@ module Tork
|
|
74
76
|
end
|
75
77
|
]
|
76
78
|
|
79
|
+
Config.test_event_hooks = []
|
80
|
+
|
77
81
|
#---------------------------------------------------------------------------
|
78
82
|
# overrides
|
79
83
|
#---------------------------------------------------------------------------
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'tork/config'
|
2
|
+
require 'set'
|
3
|
+
|
4
|
+
failed_test_files = Set.new
|
5
|
+
|
6
|
+
Tork::Config.test_event_hooks.push lambda {|message|
|
7
|
+
event, test_file, line_numbers, log_file, worker_number, exit_status = message
|
8
|
+
|
9
|
+
# make notifications edge-triggered: pass => fail or vice versa.
|
10
|
+
# we do not care about pass => pass or fail => fail transitions.
|
11
|
+
case event.to_sym
|
12
|
+
when :fail
|
13
|
+
if failed_test_files.add? test_file
|
14
|
+
icon = 'dialog-error'
|
15
|
+
end
|
16
|
+
when :pass
|
17
|
+
if line_numbers.empty? and failed_test_files.delete? test_file
|
18
|
+
icon = 'dialog-information'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
if icon
|
23
|
+
title = [event.upcase, test_file].join(' ')
|
24
|
+
|
25
|
+
statistics = File.readlines(log_file).grep(/^\d+ \w+,/).join.
|
26
|
+
gsub(/\e\[\d+(;\d+)?m/, '') # strip ANSI SGR escape codes
|
27
|
+
|
28
|
+
Thread.new do # run in background
|
29
|
+
system 'notify-send', '-i', icon, title, statistics or
|
30
|
+
system 'growlnotify', '-a', 'Xcode', '-m', statistics, title or
|
31
|
+
system 'xmessage', '-timeout', '5', '-title', title, statistics
|
32
|
+
end
|
33
|
+
end
|
34
|
+
}
|
data/lib/tork/driver.rb
CHANGED
@@ -53,7 +53,8 @@ module Driver
|
|
53
53
|
@passed_test_files.delete file
|
54
54
|
end
|
55
55
|
|
56
|
-
@client.send message
|
56
|
+
@client.send message # propagate output downstream
|
57
|
+
Config.test_event_hooks.each {|hook| hook.call message }
|
57
58
|
end
|
58
59
|
|
59
60
|
@master.send [:load, Config.overhead_load_paths,
|
@@ -72,8 +73,8 @@ module Driver
|
|
72
73
|
|
73
74
|
# find and run the tests that correspond to the changed file
|
74
75
|
Config.test_file_globbers.each do |regexp, globber|
|
75
|
-
if regexp =~ changed_file and
|
76
|
-
run_test_files Dir[
|
76
|
+
if regexp =~ changed_file and globs = globber.call(changed_file, $~)
|
77
|
+
run_test_files Dir[*globs]
|
77
78
|
end
|
78
79
|
end
|
79
80
|
|
data/lib/tork/master.rb
CHANGED
@@ -10,7 +10,7 @@ module Master
|
|
10
10
|
def load paths, files
|
11
11
|
$LOAD_PATH.unshift(*paths)
|
12
12
|
|
13
|
-
files.each do |file|
|
13
|
+
@overhead_files = files.each do |file|
|
14
14
|
branch, leaf = File.split(file)
|
15
15
|
file = leaf if paths.include? branch
|
16
16
|
require file.sub(/\.rb$/, '')
|
@@ -20,6 +20,8 @@ module Master
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def test test_file, line_numbers
|
23
|
+
return if @overhead_files.include? test_file
|
24
|
+
|
23
25
|
# throttle forking rate to meet the maximum concurrent workers limit
|
24
26
|
sleep 1 until @command_by_worker_pid.size < Config.max_forked_workers
|
25
27
|
|
data/lib/tork/version.rb
CHANGED
data/man/man1/tork-driver.1
CHANGED
data/man/man1/tork-herald.1
CHANGED
data/man/man1/tork-master.1
CHANGED
data/man/man1/tork.1
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 17.0
|
4
|
+
version: 17.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-01-
|
13
|
+
date: 2012-01-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: binman
|
17
|
-
requirement: &
|
17
|
+
requirement: &9258640 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '3'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *9258640
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: json
|
28
|
-
requirement: &
|
28
|
+
requirement: &9258120 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -36,10 +36,10 @@ dependencies:
|
|
36
36
|
version: '2'
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
|
-
version_requirements: *
|
39
|
+
version_requirements: *9258120
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: guard
|
42
|
-
requirement: &
|
42
|
+
requirement: &9257380 !ruby/object:Gem::Requirement
|
43
43
|
none: false
|
44
44
|
requirements:
|
45
45
|
- - ! '>='
|
@@ -50,10 +50,10 @@ dependencies:
|
|
50
50
|
version: '1'
|
51
51
|
type: :runtime
|
52
52
|
prerelease: false
|
53
|
-
version_requirements: *
|
53
|
+
version_requirements: *9257380
|
54
54
|
- !ruby/object:Gem::Dependency
|
55
55
|
name: diff-lcs
|
56
|
-
requirement: &
|
56
|
+
requirement: &9256640 !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
58
|
requirements:
|
59
59
|
- - ! '>='
|
@@ -64,10 +64,10 @@ dependencies:
|
|
64
64
|
version: '2'
|
65
65
|
type: :runtime
|
66
66
|
prerelease: false
|
67
|
-
version_requirements: *
|
67
|
+
version_requirements: *9256640
|
68
68
|
- !ruby/object:Gem::Dependency
|
69
69
|
name: md2man
|
70
|
-
requirement: &
|
70
|
+
requirement: &9255920 !ruby/object:Gem::Requirement
|
71
71
|
none: false
|
72
72
|
requirements:
|
73
73
|
- - ~>
|
@@ -75,10 +75,10 @@ dependencies:
|
|
75
75
|
version: '1'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
|
-
version_requirements: *
|
78
|
+
version_requirements: *9255920
|
79
79
|
- !ruby/object:Gem::Dependency
|
80
80
|
name: rake
|
81
|
-
requirement: &
|
81
|
+
requirement: &9255380 !ruby/object:Gem::Requirement
|
82
82
|
none: false
|
83
83
|
requirements:
|
84
84
|
- - ! '>='
|
@@ -89,7 +89,7 @@ dependencies:
|
|
89
89
|
version: '1'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
|
-
version_requirements: *
|
92
|
+
version_requirements: *9255380
|
93
93
|
description: Continuous testing tool for Ruby.
|
94
94
|
email:
|
95
95
|
- sunaku@gmail.com
|
@@ -116,7 +116,9 @@ files:
|
|
116
116
|
- lib/tork/config.rb
|
117
117
|
- lib/tork/config/cucumber.rb
|
118
118
|
- lib/tork/config/dotlog.rb
|
119
|
+
- lib/tork/config/factory_girl.rb
|
119
120
|
- lib/tork/config/logdir.rb
|
121
|
+
- lib/tork/config/notify.rb
|
120
122
|
- lib/tork/config/parallel_tests.rb
|
121
123
|
- lib/tork/config/rails.rb
|
122
124
|
- lib/tork/driver.rb
|