tork 17.1.0 → 18.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -12,6 +12,7 @@ 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
14
  Thanks to 2012 Mark Hayes <mark@deployfx.com>
15
+ Thanks to 2012 Gumaro Melendez <cloudernew@gmail.com>
15
16
 
16
17
  Permission to use, copy, modify, and/or distribute this software for any
17
18
  purpose with or without fee is hereby granted, provided that the above
data/README.markdown CHANGED
@@ -5,21 +5,17 @@
5
5
  \__/\____/_/ /_/|_\
6
6
  >>>------>
7
7
 
8
- _Test with fork_
9
- ==============================================================================
8
+ # _Test with fork_
10
9
 
11
- Tork is a continuous testing tool for Ruby that automatically detects and
12
- tests changes in your Ruby application or test suite in an efficient manner:
10
+ Tork runs your tests as they change, in parallel:
13
11
 
14
- 1. Absorbs your test execution overhead into a master process.
12
+ 1. Absorbs test execution overhead into a master process.
15
13
 
16
- 2. Forks to run your test files in parallel; overhead inherited.
14
+ 2. Forks to inherit overhead and run test files in parallel.
17
15
 
18
16
  3. Avoids running unchanged tests inside changed test files.
19
17
 
20
- ------------------------------------------------------------------------------
21
- Features
22
- ------------------------------------------------------------------------------
18
+ ## Features
23
19
 
24
20
  * No configuration needed: run `tork` for Ruby, `tork rails` for Rails.
25
21
 
@@ -39,16 +35,18 @@ Features
39
35
 
40
36
  * You can override the modular `tork*` programs with your own in $PATH.
41
37
 
42
- * Its core is written in about 370 lines (SLOC) of pure Ruby code! :-)
38
+ * Its core is written in about 410 lines (SLOC) of pure Ruby code! :-)
43
39
 
44
40
  ### Architecture
45
41
 
46
- Following UNIX philosophy, Tork is composed of simple text-based programs: so
47
- you can build your own custom Tork user interface by wrapping `tork-driver`!
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
44
+ interface by wrapping `tork-driver` appropriately!
48
45
 
49
- * `tork` is an interactive command-line user interface (CLI) for driver
46
+ * `tork` is an interactive command-line user interface for `tork-driver`
50
47
  * `tork-herald` monitors current directory tree and reports changed files
51
- * `tork-driver` tells master to run tests and keeps track of test results
48
+ * `tork-driver` drives the engine according to the herald's observations
49
+ * `tork-engine` tells master to run tests and keeps track of test results
52
50
  * `tork-master` absorbs test execution overhead and forks to run your tests
53
51
 
54
52
  When the herald observes that files in or beneath the current directory have
@@ -61,9 +59,7 @@ figure out which tests inside your newly saved test file have changed (using
61
59
  diff and regexps) and then attempts to run just those. To make it run *all*
62
60
  tests in your saved file, simply save the file *again* without changing it.
63
61
 
64
- ------------------------------------------------------------------------------
65
- Installation
66
- ------------------------------------------------------------------------------
62
+ ## Installation
67
63
 
68
64
  gem install tork
69
65
 
@@ -91,9 +87,7 @@ Installation
91
87
  bundle_bin/tork --help # run it directly
92
88
  bundle exec rake -T # packaging tasks
93
89
 
94
- ------------------------------------------------------------------------------
95
- Usage
96
- ------------------------------------------------------------------------------
90
+ ## Usage
97
91
 
98
92
  ### At the command line
99
93
 
@@ -103,6 +97,14 @@ You can monitor your test processes from another terminal:
103
97
 
104
98
  watch 'ps xuw | sed -n "1p; /tor[k]/p" | fgrep -v sed'
105
99
 
100
+ ### With RSpec
101
+
102
+ RSpec 2.8.0 and older contain [a bug](
103
+ https://github.com/sunaku/tork/issues/31 ) where a nonzero exit status (caused
104
+ by an uncaught exception) is overridden by RSpec's `Kernel#at_exit` handler to
105
+ be zero, thereby falsely indicating that a spec had passed. [This patch](
106
+ https://github.com/rspec/rspec-core/pull/569/files ) fixes the problem.
107
+
106
108
  ### With [Ruby on Rails]
107
109
 
108
110
  For Rails 3 or newer, use the `tork/config/rails` configuration helper.
@@ -117,17 +119,16 @@ adapter][memory_test_fix]. Otherwise, you *might* face these errors:
117
119
 
118
120
  > cannot start a transaction within a transaction
119
121
 
120
- ------------------------------------------------------------------------------
121
- Configuration
122
- ------------------------------------------------------------------------------
122
+ ## Configuration
123
123
 
124
124
  Tork looks for a configuration file named `.tork.rb` in its current working
125
125
  directory. The configuration file is a normal Ruby script, inside which you
126
- can query and modify the `Tork::Config` object: an instance of OpenStruct.
126
+ can query and modify the `Tork::Config` object, which is a kind of `Struct`.
127
+
128
+ Note that Tork *does not* automatically reload changes in your configuration
129
+ file. So you must restart Tork accordingly if your configuration changes.
127
130
 
128
- ------------------------------------------------------------------------------
129
- Configuration helpers
130
- ------------------------------------------------------------------------------
131
+ ## Configuration helpers
131
132
 
132
133
  In case you did not read the `tork --help` manual page, please note that you
133
134
  can pass *multiple* configuration helpers to tork(1) at the command line!
@@ -192,7 +193,7 @@ Or in your configuration file:
192
193
 
193
194
  require 'tork/config/logdir'
194
195
 
195
- ### Receive notifications via libnotify, growl, or xmessage(1)
196
+ ### Receive notifications via libnotify, growl, or xmessage
196
197
 
197
198
  At the command line:
198
199
 
@@ -202,9 +203,17 @@ Or in your configuration file:
202
203
 
203
204
  require 'tork/config/notify'
204
205
 
205
- ------------------------------------------------------------------------------
206
- Configuration options
207
- -----------------------------------------------------------------------------
206
+ ## Configuration options
207
+
208
+ This table shows which configuration options affect which Tork components:
209
+
210
+ | Affects `tork-driver` | Affects `tork-engine` | Affects `tork-master` |
211
+ | --------------------- | --------------------- | --------------------- |
212
+ | overhead_load_paths | test_event_hooks | max_forked_workers |
213
+ | overhead_file_globs | | before_fork_hooks |
214
+ | reabsorb_file_greps | | after_fork_hooks |
215
+ | all_test_file_globs | | |
216
+ | test_file_globbers | | |
208
217
 
209
218
  ### Tork::Config.max_forked_workers
210
219
 
@@ -234,29 +243,36 @@ your Ruby application.
234
243
  ### Tork::Config.test_file_globbers
235
244
 
236
245
  Hash that maps (1) a regular expression describing a set of file paths to (2)
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
246
+ a lambda function that accepts a `MatchData` object containing the results of
247
+ the regular expression matching against the path of a changed file, and yields
239
248
  one or more file globbing patterns (a single string, or an array of strings)
240
249
  that describe a set of test files that need to be run.
241
250
 
242
- In other words, whenever the source files (the regular expression) change,
243
- their associated test files (result of calling the lambda function) are run.
251
+ The results of these functions are recursively expanded (fed back into them)
252
+ to construct an entire dependency tree of test files that need to be run. For
253
+ instance, if one function returns a glob that yields files matched by another
254
+ function, then that second function will be called to glob more test files.
255
+ This process repeats until all dependent test files have been accounted for.
244
256
 
245
- For example, if test files had the same names as their source files followed
246
- by an underscore and the file name in reverse like this:
257
+ #### Single glob expansion
258
+
259
+ For example, if test files had the same names as their source files followed by an
260
+ underscore and the file name in reverse like this:
247
261
 
248
262
  * `lib/hello.rb` => `test/hello_olleh.rb`
249
263
  * `app/world.rb` => `spec/world_ldrow.rb`
250
264
 
251
265
  Then you would add the following to your configuration file:
252
266
 
253
- Tork::Config.test_file_globbers[%r<^(lib|app)/.+\.rb$>] = lambda do |path, matches|
254
- name = File.basename(path, '.rb')
267
+ Tork::Config.test_file_globbers[%r<^(lib|app)/.*?([^/]+?)\.rb$>] = lambda do |matches|
268
+ name = matches[2]
255
269
  "{test,spec}/**/#{name}_#{name.reverse}.rb"
256
270
  end
257
271
 
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:
272
+ #### Multi-glob expansion
273
+
274
+ For example, if test files could optionally have "test" or "spec" prefixed or
275
+ appended to their already peculiar names, like so:
260
276
 
261
277
  * `lib/hello.rb` => `test/hello_olleh_test.rb`
262
278
  * `lib/hello.rb` => `test/test_hello_olleh.rb`
@@ -265,20 +281,34 @@ Going further, if you suppose that test files could optionally have "test" or
265
281
 
266
282
  Then you would add the following to your configuration file:
267
283
 
268
- Tork::Config.test_file_globbers[%r<^(lib|app)/.+\.rb$>] = lambda do |path, matches|
269
- name = File.basename(path, '.rb')
284
+ Tork::Config.test_file_globbers[%r<^(lib|app)/.*?([^/]+?)\.rb$>] = lambda do |matches|
285
+ name = matches[2]
270
286
  ["{test,spec}/**/#{name}_#{name.reverse}.rb",
271
287
  "{test,spec}/**/#{name}_#{name.reverse}_{test,spec}.rb",
272
288
  "{test,spec}/**/{test,spec}_#{name}_#{name.reverse}.rb"]
273
289
  end
274
290
 
275
- In addition, these lambda functions can return `nil` if they do not wish for a
276
- particular source file to be tested. For example, to ignore tests for all
277
- source files except those within a `models/` directory, you would write:
291
+ #### Recursive expansion
278
292
 
279
- Tork::Config.test_file_globbers[%r<^(lib|app)/.+\.rb$>] = lambda do |path, matches|
280
- if path.include? '/models/'
281
- "{test,spec}/**/#{File.basename(path)}"
293
+ For example, if you wanted to run test files associated with `lib/hello.rb`
294
+ whenever the `app/world.rb` file changed, then you would write:
295
+
296
+ Tork::Config.test_file_globbers[%r<^app/world\.rb$>] = lambda do |matches|
297
+ 'lib/hello.rb'
298
+ end
299
+
300
+ This effectively aliases one file onto another, but not in both directions.
301
+
302
+ #### Suppressing expansion
303
+
304
+ These lambda functions can return `nil` if they do not wish for a particular
305
+ source file to be tested. For example, to ignore tests for all source files
306
+ except those within a `models/` directory, you would write:
307
+
308
+ Tork::Config.test_file_globbers[%r<^(lib|app)(/.*?)([^/]+?)\.rb$>] = lambda do |matches|
309
+ if matches[2].include? '/models/'
310
+ ["{test,spec}/**/#{matches[3]}_{test,spec}.rb",
311
+ "{test,spec}/**/{test,spec}_#{matches[3]}.rb"]
282
312
  #else # implied by the Ruby language
283
313
  #nil # implied by the Ruby language
284
314
  end
@@ -289,14 +319,14 @@ source files except those within a `models/` directory, you would write:
289
319
  Array of lambda functions that are invoked inside `tork-master` before a
290
320
  worker process is forked to run a test file. These functions are given:
291
321
 
292
- 1. The sequence number of the worker process that will be forked shortly.
322
+ 1. The path of the test file that will be run by the worker process.
293
323
 
294
- 2. The path of the log file containing the live output of the worker process.
324
+ 2. An array of line numbers in the test file to run. If this array is empty,
325
+ then the entire test file will be run.
295
326
 
296
- 3. The path of the test file that will be run by the worker process.
327
+ 3. The path of the log file containing the live output of the worker process.
297
328
 
298
- 4. An array of line numbers in the test file to run. If this array is empty,
299
- then the entire test file will be run.
329
+ 4. The sequence number of the worker process that will be forked shortly.
300
330
 
301
331
  For example, to see some real values:
302
332
 
@@ -316,14 +346,14 @@ For example, to see some real values:
316
346
  Array of lambda functions that are invoked inside a worker process forked
317
347
  by `tork-master`. These functions are given:
318
348
 
319
- 1. The sequence number of the worker process.
349
+ 1. The path of the test file that will be run by the worker process.
320
350
 
321
- 2. The path of the log file containing the live output of the worker process.
351
+ 2. An array of line numbers in the test file to run. If this array is empty,
352
+ then the entire test file will be run.
322
353
 
323
- 3. The path of the test file that will be run by the worker process.
354
+ 3. The path of the log file containing the live output of the worker process.
324
355
 
325
- 4. An array of line numbers in the test file to run. If this array is empty,
326
- then the entire test file will be run.
356
+ 4. The sequence number of the worker process.
327
357
 
328
358
  For example, to see some real values, including the worker process' PID:
329
359
 
@@ -345,7 +375,7 @@ test-driven development cycle by only running tests you are currently editing.
345
375
 
346
376
  ### Tork::Config.test_event_hooks
347
377
 
348
- Array of lambda functions that are invoked inside `tork-driver` whenever it
378
+ Array of lambda functions that are invoked inside `tork-engine` whenever it
349
379
  receives a status message (passed into those functions) from `tork-master`.
350
380
  Run `tork-master --help` for more information about these status messages.
351
381
 
@@ -355,9 +385,7 @@ For example, to see some real values:
355
385
  p :test_event_hooks => message_from_tork_master
356
386
  }
357
387
 
358
- ------------------------------------------------------------------------------
359
- License
360
- ------------------------------------------------------------------------------
388
+ ## License
361
389
 
362
390
  Released under the ISC license. See the LICENSE file for details.
363
391
 
data/bin/tork CHANGED
@@ -1,21 +1,17 @@
1
1
  #!/usr/bin/env ruby
2
- =begin
2
+ =begin =======================================================================
3
3
 
4
- TORK 1 2012-01-30 17.1.0
5
- ==============================================================================
4
+ # TORK 1 2012-02-06 18.0.0
6
5
 
7
- NAME
8
- ------------------------------------------------------------------------------
6
+ ## NAME
9
7
 
10
8
  tork - Continuous testing tool for Ruby
11
9
 
12
- SYNOPSIS
13
- ------------------------------------------------------------------------------
10
+ ## SYNOPSIS
14
11
 
15
12
  `tork` [*OPTION*]... [*CONFIG*]...
16
13
 
17
- DESCRIPTION
18
- ------------------------------------------------------------------------------
14
+ ## DESCRIPTION
19
15
 
20
16
  This program is a simple command-line user interface for tork-driver(1). It
21
17
  loads the given *CONFIG* files (which are either paths to actual files or
@@ -23,14 +19,12 @@ names of helper libraries in the tork/config/ namespace of Ruby's load path)
23
19
  and then waits for you to supply interactive commands on its stdin. You may
24
20
  press the ENTER key (supplying no command) to see a menu of accepted commands.
25
21
 
26
- OPTIONS
27
- ------------------------------------------------------------------------------
22
+ ## OPTIONS
28
23
 
29
24
  `-h`, `--help`
30
- Display this help manual using man(1).
25
+ Show this help manual.
31
26
 
32
- SEE ALSO
33
- ------------------------------------------------------------------------------
27
+ ## SEE ALSO
34
28
 
35
29
  tork(1), tork-driver(1), tork-master(1), tork-herald(1)
36
30
 
data/bin/tork-driver CHANGED
@@ -1,41 +1,32 @@
1
1
  #!/usr/bin/env ruby
2
- =begin
2
+ =begin =======================================================================
3
3
 
4
- TORK-DRIVER 1 2012-01-30 17.1.0
5
- ==============================================================================
4
+ # TORK-DRIVER 1 2012-02-06 18.0.0
6
5
 
7
- NAME
8
- ------------------------------------------------------------------------------
6
+ ## NAME
9
7
 
10
- tork-driver - drives tork-master(1) and does bookkeeping
8
+ tork-driver - drives tork-engine(1) when files change
11
9
 
12
- SYNOPSIS
13
- ------------------------------------------------------------------------------
10
+ ## SYNOPSIS
14
11
 
15
12
  `tork-driver` [*OPTION*]...
16
13
 
17
- DESCRIPTION
18
- ------------------------------------------------------------------------------
14
+ ## DESCRIPTION
19
15
 
20
- This program reads the following single-line commands (JSON arrays) from its
21
- standard input stream and performs the respective actions as described below.
22
- It also funnels the standard output stream of tork-master(1) into its own.
16
+ This program drives tork-engine(1) according to tork-herald(1)'s observations.
17
+ It reads the following single-line commands (JSON arrays) from its standard
18
+ input stream and performs the respective actions as described below. It also
19
+ funnels the standard output stream of tork-engine(1) into its own.
23
20
 
24
21
  `["run_all_test_files"]`
25
22
  Runs all test files found within and beneath the current working directory.
26
23
 
27
- `["stop_running_test_files"]`
28
- Stops any test files that are currently running.
29
-
30
- `["rerun_passed_test_files"]`
31
- Runs all test files that have passed during their most recent run.
32
-
33
24
  `["reabsorb_overhead_files"]`
34
25
  Stops any test files that are currently running, reabsorbs the test
35
26
  execution overhead, and resumes running those interrupted test files.
36
27
 
37
- `["quit"]`
38
- Stops all tests that are currently running and exits.
28
+ *...*
29
+ This program accepts tork-engine(1) commands and delegates them accordingly.
39
30
 
40
31
  When tork-herald(1) reports that a file belonging to the test execution
41
32
  overhead has been modified, this program replaces tork-master(1) with a new
@@ -48,30 +39,26 @@ its standard output stream to provide notifications about its activity:
48
39
  The test execution overhead is currently being reabsorbed, by replacing
49
40
  tork-master(1) with a new instance, because *overhead_file* has changed.
50
41
 
51
- OPTIONS
52
- ------------------------------------------------------------------------------
42
+ ## OPTIONS
53
43
 
54
44
  `-h`, `--help`
55
- Display this help manual using man(1).
45
+ Show this help manual.
56
46
 
57
- FILES
58
- ------------------------------------------------------------------------------
47
+ ## FILES
59
48
 
60
49
  *.tork.rb*
61
50
  Optional Ruby script for configuring tork(1).
62
51
 
63
- ENVIRONMENT
64
- ------------------------------------------------------------------------------
52
+ ## ENVIRONMENT
65
53
 
66
54
  `TORK_CONFIGS`
67
55
  A single-line JSON array containing paths to actual files or names of
68
56
  helper libraries in the tork/config/ namespace of Ruby's load path.
69
57
  These configuration files are loaded just before *.tork.rb* is loaded.
70
58
 
71
- SEE ALSO
72
- ------------------------------------------------------------------------------
59
+ ## SEE ALSO
73
60
 
74
- tork(1), tork-driver(1), tork-master(1), tork-herald(1)
61
+ tork(1), tork-herald(1), tork-driver(1), tork-engine(1), tork-master(1)
75
62
 
76
63
  =end =========================================================================
77
64
 
@@ -81,6 +68,4 @@ require 'binman'
81
68
  BinMan.help
82
69
 
83
70
  require 'tork/driver'
84
- Tork::Driver.loop
85
-
86
- Process.waitall
71
+ Tork::Driver.new.loop
data/bin/tork-engine ADDED
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env ruby
2
+ =begin =======================================================================
3
+
4
+ # TORK-ENGINE 1 2012-02-06 18.0.0
5
+
6
+ ## NAME
7
+
8
+ tork-engine - wraps tork-master(1) with bookkeeping
9
+
10
+ ## SYNOPSIS
11
+
12
+ `tork-engine` [*OPTION*]...
13
+
14
+ ## DESCRIPTION
15
+
16
+ This program tells tork-master(1) to run your tests and keeps track of test
17
+ results. It reads the following single-line commands (JSON arrays) from its
18
+ standard input stream and performs the respective actions as described below.
19
+ It also funnels the standard output stream of tork-master(1) into its own.
20
+
21
+ `["reabsorb_overhead",` *paths*`,` *files*`]`
22
+ Stops any test files that are currently running, reabsorbs the given test
23
+ execution overhead, and resumes running those interrupted test files. See
24
+ the "load" command in tork-master(1) for more information.
25
+
26
+ `["run_test_file"`, *test_file*`,` *line_numbers*`]`
27
+ Runs tests that correspond to the given *line_numbers* array in the given
28
+ *test_file*. If *line_numbers* is `null`, then only those lines that have
29
+ changed since the last time the *test_file* was run will be substituted. If
30
+ *line_numbers* is an empty array, then the entire *test_file* will be run.
31
+
32
+ `["stop_running_test_files"]`
33
+ Stops any test files that are currently running.
34
+
35
+ `["rerun_passed_test_files"]`
36
+ Runs all test files that have passed during their most recent run.
37
+
38
+ `["rerun_failed_test_files"]`
39
+ Runs all test files that have failed during their most recent run.
40
+
41
+ `["quit"]`
42
+ Stops all tests that are currently running and exits.
43
+
44
+ ## OPTIONS
45
+
46
+ `-h`, `--help`
47
+ Show this help manual.
48
+
49
+ ## FILES
50
+
51
+ *.tork.rb*
52
+ Optional Ruby script for configuring tork(1).
53
+
54
+ ## ENVIRONMENT
55
+
56
+ `TORK_CONFIGS`
57
+ A single-line JSON array containing paths to actual files or names of
58
+ helper libraries in the tork/config/ namespace of Ruby's load path.
59
+ These configuration files are loaded just before *.tork.rb* is loaded.
60
+
61
+ ## SEE ALSO
62
+
63
+ tork(1), tork-herald(1), tork-driver(1), tork-engine(1), tork-master(1)
64
+
65
+ =end =========================================================================
66
+
67
+ $0 = File.basename(__FILE__) # for easier identification in ps(1) output
68
+
69
+ require 'binman'
70
+ BinMan.help
71
+
72
+ require 'tork/engine'
73
+ Tork::Engine.new.loop