tork 18.2.4 → 19.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/HISTORY.markdown +65 -0
  2. data/README.markdown +60 -298
  3. data/bin/tork +99 -62
  4. data/bin/tork-driver +124 -25
  5. data/bin/tork-engine +45 -23
  6. data/bin/tork-herald +5 -5
  7. data/bin/tork-master +79 -32
  8. data/bin/tork-notify +70 -0
  9. data/bin/tork-remote +80 -0
  10. data/lib/tork/cliapp.rb +73 -0
  11. data/lib/tork/config.rb +14 -97
  12. data/lib/tork/config/coverage/master.rb +29 -0
  13. data/lib/tork/config/coverage/worker.rb +1 -0
  14. data/lib/tork/config/cucumber/driver.rb +11 -0
  15. data/lib/tork/config/cucumber/worker.rb +14 -0
  16. data/lib/tork/config/default/config.rb +5 -0
  17. data/lib/tork/config/dotlog/onfork.rb +2 -0
  18. data/lib/tork/config/factory_girl/onfork.rb +2 -0
  19. data/lib/tork/config/factory_girl/worker.rb +1 -0
  20. data/lib/tork/config/logdir/onfork.rb +4 -0
  21. data/lib/tork/config/parallel_tests/worker.rb +4 -0
  22. data/lib/tork/config/rails/driver.rb +15 -0
  23. data/lib/tork/config/rails/master.rb +12 -0
  24. data/lib/tork/config/rails/worker.rb +21 -0
  25. data/lib/tork/config/spec/driver.rb +17 -0
  26. data/lib/tork/config/spec/master.rb +3 -0
  27. data/lib/tork/config/spec/worker.rb +3 -0
  28. data/lib/tork/config/test/driver.rb +17 -0
  29. data/lib/tork/config/test/master.rb +3 -0
  30. data/lib/tork/config/test/worker.rb +23 -0
  31. data/lib/tork/driver.rb +68 -36
  32. data/lib/tork/engine.rb +57 -44
  33. data/lib/tork/master.rb +34 -34
  34. data/lib/tork/server.rb +118 -17
  35. data/lib/tork/version.rb +1 -1
  36. data/man/man1/tork-driver.1 +165 -37
  37. data/man/man1/tork-engine.1 +50 -32
  38. data/man/man1/tork-herald.1 +5 -8
  39. data/man/man1/tork-master.1 +95 -42
  40. data/man/man1/tork-notify.1 +27 -0
  41. data/man/man1/tork-remote.1 +38 -0
  42. data/man/man1/tork.1 +116 -8
  43. data/tork.gemspec +3 -3
  44. metadata +36 -25
  45. data/lib/tork/client.rb +0 -53
  46. data/lib/tork/config/coverage.rb +0 -40
  47. data/lib/tork/config/cucumber.rb +0 -32
  48. data/lib/tork/config/dotlog.rb +0 -8
  49. data/lib/tork/config/factory_girl.rb +0 -10
  50. data/lib/tork/config/logdir.rb +0 -10
  51. data/lib/tork/config/notify.rb +0 -34
  52. data/lib/tork/config/parallel_tests.rb +0 -9
  53. data/lib/tork/config/rails.rb +0 -39
data/HISTORY.markdown CHANGED
@@ -1,3 +1,68 @@
1
+ ## Version 19.0.0 (2012-10-17)
2
+
3
+ Major:
4
+
5
+ * The `.tork.rb` configuration file has been replaced by the `.tork/`
6
+ directory, which contains specially-named Ruby scripts. Refer to the
7
+ `TORK_CONFIGS` environment variable in tork(1) for more information.
8
+
9
+ * The `Tork::Config` object has been replaced by various data structures in
10
+ the `Tork::` namespace. See the "FILES" sections in the manual pages of
11
+ tork programs for information on the data structures that replaced it.
12
+
13
+ * `Tork::Config.test_event_hooks` has been removed. Instead, you must now
14
+ monitor the STDOUT of tork-master(1) or tork-engine(1) either directly
15
+ or indirectly, via tork-remote(1), and react to their status messages.
16
+ See the tork-notify(1) program for an example of how to implement this.
17
+
18
+ * tork(1): 't' now runs a specified test, whereas 'a' runs all tests.
19
+
20
+ * tork-engine(1): the `run_test_file` command now takes line numbers as a
21
+ variable-length list of arguments (varargs) rather than as an array.
22
+
23
+ * tork-engine(1): the `run_test_file` command now runs an entire test file
24
+ when zero is given as one of the line numbers to be run.
25
+
26
+ * tork-master(1): the `load` command is no longer accepted. Instead, you
27
+ must specify load paths and overhead files in the `.tork/master.rb` file.
28
+
29
+ * The `TORK_CONFIGS` env-var is now a colon delimited list of directories.
30
+
31
+ * The `tork/client` library has been removed. The threaded IO and popen()
32
+ wrappers that it provided have been replaced by the powerful IO.select().
33
+
34
+ Minor:
35
+
36
+ * tork(1): allow user to specify arguments after command key
37
+
38
+ * tork(1): add 'k' to stop all currently running tests with SIGKILL
39
+
40
+ * add tork-remote(1) to remotely control any tork program. This feature is
41
+ made possible by the awesome power of IO.select() and UNIX domain sockets.
42
+
43
+ * add tork-notify(1) as example of using tork-remote(1) and tork-engine(1)
44
+
45
+ * tork-engine(1): add `["run_test_files"]` command to run multiple files
46
+
47
+ * tork-engine(1): emit edge-triggered `pass_now_fail` and `fail_now_pass`
48
+ events to notify you about changes in a test file's pass/fail status.
49
+
50
+ * typing Control-D now breaks tork programs out of `Tork::Server#loop()`
51
+
52
+ Patch:
53
+
54
+ * tork-master(1): stop workers with SIGKILL when quitting
55
+
56
+ Other:
57
+
58
+ * tork(1): document parameters for `t` and `s` commands
59
+
60
+ * README: add tip about rlwrap for better interactive
61
+
62
+ * README: simplify watch command using pgrep & xargs
63
+
64
+ * README: use standard bundle exec; no `--binstubs`
65
+
1
66
  ## Version 18.2.4 (2012-10-10)
2
67
 
3
68
  Other:
data/README.markdown CHANGED
@@ -17,7 +17,7 @@ Tork runs your tests as they change, in parallel:
17
17
 
18
18
  ## Features
19
19
 
20
- * No configuration needed: run `tork` for Ruby, `tork rails` for Rails.
20
+ * No configuration necessary: simply run `tork` to start testing *now!*
21
21
 
22
22
  * Runs test files in parallel using fork for multi-core/CPU utilization.
23
23
 
@@ -25,22 +25,21 @@ Tork runs your tests as they change, in parallel:
25
25
  unchanged test files and (2) unchanged tests inside changed test files.
26
26
 
27
27
  * Supports MiniTest, Test::Unit, RSpec, and *any testing framework* that (1)
28
- exits with a nonzero status to indicate test failures (2) is loaded by
28
+ exits with a nonzero status to indicate test failures and (2) is loaded by
29
29
  your application's `test/test_helper.rb` or `spec/spec_helper.rb` file.
30
30
 
31
31
  * Logs the output from your tests into separate files: one log per test.
32
- The path of a log file is simply the path of its test file plus ".log".
33
32
 
34
- * Configurable through a Ruby script in your current working directory.
33
+ * Configurable through Ruby scripts in your current working directory.
35
34
 
36
35
  * You can override the modular `tork*` programs with your own in $PATH.
37
36
 
38
- * Its core is written in about 420 lines (SLOC) of pure Ruby code! :-)
37
+ * You can remotely control other `tork*` programs using `tork-remote`.
39
38
 
40
39
  ### Architecture
41
40
 
42
- Following UNIX philosophy, Tork is composed of simple text-based programs that
43
- *do one thing well*. As a result, you could even create your own Tork user
41
+ Following UNIX philosophy, tork is composed of simple text-based programs that
42
+ *do one thing well*. As a result, you could even create your own tork user
44
43
  interface by wrapping `tork-driver` appropriately!
45
44
 
46
45
  * `tork` is an interactive command-line user interface for `tork-driver`
@@ -48,16 +47,34 @@ interface by wrapping `tork-driver` appropriately!
48
47
  * `tork-driver` drives the engine according to the herald's observations
49
48
  * `tork-engine` tells master to run tests and keeps track of test results
50
49
  * `tork-master` absorbs test execution overhead and forks to run your tests
50
+ * `tork-remote` remotely controls any tork program running in the same `pwd`
51
+ * `tork-notify` shows how to receive and process messages from tork programs
51
52
 
52
53
  When the herald observes that files in or beneath the current directory have
53
54
  been written to, it tells the driver, which then commands the master to fork a
54
55
  worker process to run the tests affected by those changed files. This is all
55
- performed automatically. But what if you want to manually run a test file?
56
+ performed *automatically*. However, to run a test file *manually*, you can:
56
57
 
57
- You can (re)run any test file by simply saving it! When you do, Tork tries to
58
- figure out which tests inside your newly saved test file have changed (using
59
- diff and regexps) and then attempts to run just those. To make it run *all*
60
- tests in your saved file, simply save the file *again* without changing it.
58
+ 1. Simply save the file! When you do, tork tries to figure out which tests
59
+ inside your newly saved test file have changed (using diff and regexps)
60
+ and then attempts to run just those. To make it run *all* tests in your
61
+ saved file, simply save the file *again* without changing it.
62
+
63
+ 2. Type `t` followed by a space and the file you want to run into `tork`:
64
+
65
+ # run all of test/some_test.rb
66
+ t test/some_test.rb
67
+
68
+ # run lines 4, 33, and 21 of test/some_test.rb
69
+ t test/some_test.rb 4 33 21
70
+
71
+ 3. Send a `["run_test_file"]` message to `tork-engine` using `tork-remote`:
72
+
73
+ # run all of test/some_test.rb
74
+ echo run_test_file test/some_test.rb | tork-remote tork-engine
75
+
76
+ # run lines 4, 33, and 21 of test/some_test.rb
77
+ echo run_test_file test/some_test.rb 4 33 21 | tork-remote tork-engine
61
78
 
62
79
  ## Installation
63
80
 
@@ -72,6 +89,7 @@ tests in your saved file, simply save the file *again* without changing it.
72
89
 
73
90
  Process.respond_to? :fork # must be true
74
91
  Signal.list.key? 'TERM' # must be true
92
+ Signal.list.key? 'KILL' # must be true
75
93
 
76
94
  * To make the `tork-herald` program's filesystem monitoring more efficient:
77
95
 
@@ -82,9 +100,9 @@ tests in your saved file, simply save the file *again* without changing it.
82
100
 
83
101
  git clone git://github.com/sunaku/tork
84
102
  cd tork
85
- bundle install --binstubs=bundle_bin
86
- bundle_bin/tork --help # run it directly
87
- bundle_bin/rake --tasks # packaging tasks
103
+ bundle install
104
+ bundle exec tork --help # run it directly
105
+ bundle exec rake --tasks # packaging tasks
88
106
 
89
107
  ## Usage
90
108
 
@@ -92,9 +110,24 @@ tests in your saved file, simply save the file *again* without changing it.
92
110
 
93
111
  tork --help
94
112
 
113
+ You can add line editing, history, and filename completion:
114
+
115
+ rlwrap -c tork
116
+
117
+ You can control tork(1) interactively from another terminal:
118
+
119
+ tork-remote tork-engine
120
+ # type your commands here, one per line.
121
+ # press Control-D to exit tork-remote(1)
122
+
123
+ You can also do the same non-interactively using a pipeline:
124
+
125
+ # run lines 4, 33, and 21 of test/some_test.rb
126
+ echo run_test_file test/some_test.rb 4 33 21 | tork-remote tork-engine
127
+
95
128
  You can monitor your test processes from another terminal:
96
129
 
97
- watch 'ps xuw | sed -n "1p; /tor[k]/p" | fgrep -v sed'
130
+ watch 'pgrep -f ^tork | xargs -r ps u'
98
131
 
99
132
  ### With RSpec
100
133
 
@@ -106,8 +139,11 @@ https://github.com/rspec/rspec-core/pull/569/files ) fixes the problem.
106
139
 
107
140
  ### With [Ruby on Rails]
108
141
 
109
- For Rails 3 or newer, use the `tork/config/rails` configuration helper.
110
- Otherwise, ensure that your `config/environments/test.rb` file contains:
142
+ For Rails 3 or newer, use the `rails` configuration helper *before* the `test`
143
+ or `spec` helpers. Otherwise your test helper will load Rails *before* the
144
+ specified `rails` configuration helper has a chance to disable class caching!
145
+
146
+ For older Rails, make sure your `config/environments/test.rb` file contains:
111
147
 
112
148
  config.cache_classes = false
113
149
 
@@ -120,287 +156,13 @@ adapter][memory_test_fix]. Otherwise, you *might* face these errors:
120
156
 
121
157
  ## Configuration
122
158
 
123
- Tork looks for a configuration file named `.tork.rb` in its current working
124
- directory. The configuration file is a normal Ruby script, inside which you
125
- can query and modify the `Tork::Config` object, which is a kind of `Struct`.
126
-
127
- Note that Tork *does not* automatically reload changes in your configuration
128
- file. So you must restart Tork accordingly if your configuration changes.
129
-
130
- ## Configuration helpers
131
-
132
- In case you did not read the `tork --help` manual page, please note that you
133
- can pass *multiple* configuration helpers to tork(1) at the command line!
134
-
135
- ### Code coverage (Ruby 1.9)
136
-
137
- At the command line:
138
-
139
- tork coverage
140
-
141
- Or in your configuration file:
142
-
143
- require 'tork/config/coverage'
144
-
145
- This configuration helper prints a coverage report at the end of your log file
146
- in YAML format. The report is a hash containing the following information per
147
- each loaded Ruby file that exist in or beneath the current working directory:
148
-
149
- * :grade - percentage of C0 code coverage for source lines of code
150
- * :nsloc - total number of source lines of code in the file
151
- * :holes - line numbers of source lines that were not covered
152
-
153
- ### [Ruby on Rails]
154
-
155
- At the command line:
156
-
157
- tork rails
158
-
159
- Or in your configuration file:
160
-
161
- require 'tork/config/rails'
162
-
163
- ### [Cucumber]
164
-
165
- At the command line:
166
-
167
- tork cucumber
168
-
169
- Or in your configuration file:
170
-
171
- require 'tork/config/cucumber'
172
-
173
- ### [factory_girl]
174
-
175
- At the command line:
176
-
177
- tork factory_girl
178
-
179
- Or in your configuration file:
180
-
181
- require 'tork/config/factory_girl'
182
-
183
- ### [parallel_tests]
184
-
185
- At the command line:
186
-
187
- tork parallel_tests
188
-
189
- Or in your configuration file:
190
-
191
- require 'tork/config/parallel_tests'
192
-
193
- ### Hide log files by prefixing their names with a dot
194
-
195
- At the command line:
196
-
197
- tork dotlog
198
-
199
- Or in your configuration file:
200
-
201
- require 'tork/config/dotlog'
202
-
203
- ### Isolate log files into a separate `log/` directory
204
-
205
- At the command line:
206
-
207
- tork logdir
208
-
209
- Or in your configuration file:
210
-
211
- require 'tork/config/logdir'
212
-
213
- ### Receive notifications via libnotify, growl, or xmessage
214
-
215
- At the command line:
216
-
217
- tork notify
218
-
219
- Or in your configuration file:
220
-
221
- require 'tork/config/notify'
222
-
223
- ## Configuration options
224
-
225
- This table shows which configuration options affect which Tork components:
226
-
227
- | Affects `tork-driver` | Affects `tork-engine` | Affects `tork-master` |
228
- | --------------------- | --------------------- | --------------------- |
229
- | overhead_load_paths | test_event_hooks | max_forked_workers |
230
- | overhead_file_globs | | before_fork_hooks |
231
- | reabsorb_file_greps | | after_fork_hooks |
232
- | all_test_file_globs | | |
233
- | test_file_globbers | | |
234
-
235
- ### Tork::Config.max_forked_workers
236
-
237
- Maximum number of worker processes at any given time. The default value is
238
- the number of processors detected on your system, or 1 if detection fails.
239
-
240
- ### Tork::Config.overhead_load_paths
241
-
242
- Array of paths that are prepended to Ruby's `$LOAD_PATH` before the
243
- test execution overhead is loaded into `tork-master`.
244
-
245
- ### Tork::Config.overhead_file_globs
246
-
247
- Array of file globbing patterns that describe a set of Ruby scripts that are
248
- loaded into `tork-master` as test execution overhead.
249
-
250
- ### Tork::Config.reabsorb_file_greps
251
-
252
- Array of regular expressions that describe a set of file paths that cause the
253
- test execution overhead to be reabsorbed in `tork-master` when they change.
254
-
255
- ### Tork::Config.all_test_file_globs
256
-
257
- Array of file globbing patterns that describe the set of all test files in
258
- your Ruby application.
259
-
260
- ### Tork::Config.test_file_globbers
261
-
262
- Hash that maps (1) a regular expression describing a set of file paths to (2)
263
- a lambda function that accepts a `MatchData` object containing the results of
264
- the regular expression matching against the path of a changed file, and yields
265
- one or more file globbing patterns (a single string, or an array of strings)
266
- that describe a set of test files that need to be run.
267
-
268
- The results of these functions are recursively expanded (fed back into them)
269
- to construct an entire dependency tree of test files that need to be run. For
270
- instance, if one function returns a glob that yields files matched by another
271
- function, then that second function will be called to glob more test files.
272
- This process repeats until all dependent test files have been accounted for.
273
-
274
- #### Single glob expansion
275
-
276
- For example, if test files had the same names as their source files followed by an
277
- underscore and the file name in reverse like this:
278
-
279
- * `lib/hello.rb` => `test/hello_olleh.rb`
280
- * `app/world.rb` => `spec/world_ldrow.rb`
281
-
282
- Then you would add the following to your configuration file:
283
-
284
- Tork::Config.test_file_globbers[%r<^(lib|app)/.*?([^/]+?)\.rb$>] = lambda do |matches|
285
- name = matches[2]
286
- "{test,spec}/**/#{name}_#{name.reverse}.rb"
287
- end
288
-
289
- #### Multi-glob expansion
290
-
291
- For example, if test files could optionally have "test" or "spec" prefixed or
292
- appended to their already peculiar names, like so:
293
-
294
- * `lib/hello.rb` => `test/hello_olleh_test.rb`
295
- * `lib/hello.rb` => `test/test_hello_olleh.rb`
296
- * `app/world.rb` => `spec/world_ldrow_spec.rb`
297
- * `app/world.rb` => `spec/spec_world_ldrow.rb`
298
-
299
- Then you would add the following to your configuration file:
300
-
301
- Tork::Config.test_file_globbers[%r<^(lib|app)/.*?([^/]+?)\.rb$>] = lambda do |matches|
302
- name = matches[2]
303
- ["{test,spec}/**/#{name}_#{name.reverse}.rb",
304
- "{test,spec}/**/#{name}_#{name.reverse}_{test,spec}.rb",
305
- "{test,spec}/**/{test,spec}_#{name}_#{name.reverse}.rb"]
306
- end
307
-
308
- #### Recursive expansion
309
-
310
- For example, if you wanted to run test files associated with `lib/hello.rb`
311
- whenever the `app/world.rb` file changed, then you would write:
312
-
313
- Tork::Config.test_file_globbers[%r<^app/world\.rb$>] = lambda do |matches|
314
- 'lib/hello.rb'
315
- end
316
-
317
- This effectively aliases one file onto another, but not in both directions.
318
-
319
- #### Suppressing expansion
320
-
321
- These lambda functions can return `nil` if they do not wish for a particular
322
- source file to be tested. For example, to ignore tests for all source files
323
- except those within a `models/` directory, you would write:
324
-
325
- Tork::Config.test_file_globbers[%r<^(lib|app)(/.*?)([^/]+?)\.rb$>] = lambda do |matches|
326
- if matches[2].include? '/models/'
327
- ["{test,spec}/**/#{matches[3]}_{test,spec}.rb",
328
- "{test,spec}/**/{test,spec}_#{matches[3]}.rb"]
329
- #else # implied by the Ruby language
330
- #nil # implied by the Ruby language
331
- end
332
- end
333
-
334
- ### Tork::Config.before_fork_hooks
335
-
336
- Array of lambda functions that are invoked inside `tork-master` before a
337
- worker process is forked to run a test file. These functions are given:
338
-
339
- 1. The path of the test file that will be run by the worker process.
340
-
341
- 2. An array of line numbers in the test file to run. If this array is empty,
342
- then the entire test file will be run.
343
-
344
- 3. The path of the log file containing the live output of the worker process.
345
-
346
- 4. The sequence number of the worker process that will be forked shortly.
347
-
348
- For example, to see some real values:
349
-
350
- Tork::Config.before_fork_hooks.push lambda {
351
- |test_file, line_numbers, log_file, worker_number|
352
-
353
- p :before_fork_hooks => {
354
- :test_file => test_file,
355
- :line_numbers => line_numbers,
356
- :log_file => log_file,
357
- :worker_number => worker_number,
358
- }
359
- }
360
-
361
- ### Tork::Config.after_fork_hooks
362
-
363
- Array of lambda functions that are invoked inside a worker process forked
364
- by `tork-master`. These functions are given:
365
-
366
- 1. The path of the test file that will be run by the worker process.
367
-
368
- 2. An array of line numbers in the test file to run. If this array is empty,
369
- then the entire test file will be run.
370
-
371
- 3. The path of the log file containing the live output of the worker process.
372
-
373
- 4. The sequence number of the worker process.
374
-
375
- For example, to see some real values, including the worker process' PID:
376
-
377
- Tork::Config.after_fork_hooks.push lambda {
378
- |test_file, line_numbers, log_file, worker_number|
379
-
380
- p :after_fork_hooks => {
381
- :test_file => test_file,
382
- :line_numbers => line_numbers,
383
- :log_file => log_file,
384
- :worker_number => worker_number,
385
- :worker_pid => $$,
386
- }
387
- }
388
-
389
- The first function in this array instructs Test::Unit and RSpec to only run
390
- those tests that are defined on the given line numbers. This accelerates your
391
- test-driven development cycle by only running tests you are currently editing.
392
-
393
- ### Tork::Config.test_event_hooks
394
-
395
- Array of lambda functions that are invoked inside `tork-engine` whenever it
396
- receives a status message (passed into those functions) from `tork-master`.
397
- Run `tork-master --help` for more information about these status messages.
398
-
399
- For example, to see some real values:
159
+ Tork looks for a configuration directory named `.tork/` inside its working
160
+ directory. The configuration directory contains specially-named Ruby scripts,
161
+ within which you can query and modify the settings for various tork programs.
162
+ See the "FILES" sections in the manual pages of tork programs for details.
400
163
 
401
- Tork::Config.test_event_hooks.push lambda {|message_from_tork_master|
402
- p :test_event_hooks => message_from_tork_master
403
- }
164
+ Note that tork *does not* automatically reload changes from your configuration
165
+ directory. Consequently, you must restart tork if your configuration changes.
404
166
 
405
167
  ## License
406
168