tork 18.2.4 → 19.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.
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/bin/tork CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  =begin =======================================================================
3
3
 
4
- # TORK 1 2012-10-10 18.2.4
4
+ # TORK 1 2012-10-17 19.0.0
5
5
 
6
6
  ## NAME
7
7
 
@@ -13,20 +13,108 @@ tork - Continuous testing tool for Ruby
13
13
 
14
14
  ## DESCRIPTION
15
15
 
16
- This program is a simple command-line user interface for tork-driver(1). It
17
- loads the given *CONFIG* files (which are either paths to actual files or
18
- names of helper libraries in the tork/config/ namespace of Ruby's load path)
19
- and then waits for you to supply interactive commands on its stdin. You may
16
+ This program is a simple command-line user interface for tork-driver(1).
17
+
18
+ First, it applies the given *CONFIG* values, which are either (1) paths to
19
+ directories that contain configuration files or (2) names of configuration
20
+ helpers listed in the description of the `TORK_CONFIGS` environment variable.
21
+
22
+ Next, it waits for you to supply interactive commands either (1) directly on
23
+ its stdin or (2) remotely through tork-remote(1). From then onward, you may
20
24
  press the ENTER key (supplying no command) to see a menu of accepted commands.
21
25
 
26
+ Some interactive commands accept additional arguments, described as follows.
27
+
28
+ `t` *test_file* [*line_number*]...
29
+ Runs the given *test_file* while only running those tests that are defined
30
+ on the given list of *line_number*s. If no *line_number*s are given, then
31
+ only those tests that have changed since the last run of the *test_file*
32
+ will now be run.
33
+
34
+ `s` [*signal*]
35
+ Stops test files that are currently running by sending the given *signal*
36
+ (optional; defaults to `SIGTERM`) to their respective worker processes.
37
+
38
+ This program can be controlled remotely by multiple tork-remote(1) instances.
39
+
22
40
  ## OPTIONS
23
41
 
24
42
  `-h`, `--help`
25
43
  Show this help manual.
26
44
 
45
+ ## FILES
46
+
47
+ *.tork/config.rb*
48
+ Optional Ruby script that is loaded inside the driver process on startup.
49
+ It can read and change the `ENV['TORK_CONFIGS']` environment variable.
50
+
51
+ ## ENVIRONMENT
52
+
53
+ `TORK_CONFIGS`
54
+ Colon-separated (:) list of either paths to directories that contain
55
+ configuration files or names of the following configuration helpers.
56
+ If this variable is not set, then its value is assumed to be "default".
57
+
58
+ > `default`
59
+ > Loads the following configuration helpers (as appropriate) if your
60
+ > current working directory appears to utilize what they configure.
61
+ > See below for complete descriptions of these configuration helpers.
62
+ >
63
+ > * rails
64
+ > * test
65
+ > * spec
66
+ > * cucumber
67
+ > * factory_girl
68
+ >
69
+ > `dotlog`
70
+ > Hides log files by prefixing their names with a period (dot).
71
+ >
72
+ > `logdir`
73
+ > Keeps log files away from your tests, in the `log/` directory.
74
+ >
75
+ > `coverage`
76
+ > Measures C0 code coverage under Ruby 1.9 and dumps a hash in YAML
77
+ > format at the end of your log file containing every Ruby script that
78
+ > was loaded from the current working directory or any of its descendant
79
+ > directories (the key) mapped to the following information (the value):
80
+ >
81
+ > > `:grade`
82
+ > > Percentage of source lines that were C0 covered.
83
+ > >
84
+ > > `:nsloc`
85
+ > > Total number of source lines of code in the file.
86
+ > >
87
+ > > `:holes`
88
+ > > Line numbers of source lines that were not covered.
89
+ >
90
+ > `test`
91
+ > Supports the Test::Unit standard library.
92
+ >
93
+ > `spec`
94
+ > Supports the [RSpec] testing framework.
95
+ >
96
+ > `cucumber`
97
+ > Supports the [Cucumber] testing framework.
98
+ >
99
+ > `rails`
100
+ > Supports the [Ruby on Rails] web framework.
101
+ >
102
+ > `factory_girl`
103
+ > Supports the [factory_girl] testing library.
104
+ >
105
+ > `parallel_tests`
106
+ > Supports the [parallel_tests] testing library.
107
+
27
108
  ## SEE ALSO
28
109
 
29
- tork(1), tork-driver(1), tork-master(1), tork-herald(1)
110
+ tork(1), tork-driver(1), tork-master(1)
111
+
112
+ [factory_girl]: https://github.com/thoughtbot/factory_girl
113
+ [memory_test_fix]: https://github.com/stepahn/memory_test_fix
114
+ [parallel_tests]: https://github.com/grosser/parallel_tests
115
+ [Ruby on Rails]: http://rubyonrails.org
116
+ [Cucumber]: https://cukes.info
117
+ [RSpec]: http://rspec.info
30
118
 
31
119
  =end =========================================================================
32
120
 
@@ -35,59 +123,8 @@ $0 = File.basename(__FILE__) # for easier identification in ps(1) output
35
123
  require 'binman'
36
124
  BinMan.help
37
125
 
38
- require 'json'
39
- ENV['TORK_CONFIGS'] = JSON.dump(ARGV)
40
-
41
- #-----------------------------------------------------------------------------
42
- # backend
43
- #-----------------------------------------------------------------------------
44
-
45
- require 'tork/client'
46
-
47
- warn "#{$0}: Absorbing test execution overhead..."
48
- @driver = Tork::Client::Transceiver.new('tork-driver') do |event, *details|
49
- case event_sym = event.to_sym
50
- when :load then warn "#{$0}: Overhead absorbed. Ready for testing!"
51
- when :over then warn "#{$0}: Reabsorbing changed overhead files..."
52
- else
53
- test_file, line_numbers, log_file, worker_number, exit_status = details
54
- message = [event.upcase, [test_file, *line_numbers].join(':'),
55
- exit_status].compact.join(' ')
56
-
57
- color = case event_sym
58
- when :pass then "\e[34m%s\e[0m" # blue
59
- when :fail then "\e[31m%s\e[0m" # red
60
- end
61
- message = color % message if color and STDOUT.tty?
62
- message = [message, File.read(log_file), message] if event_sym == :fail
63
-
64
- puts message
65
- end
66
- end
67
-
68
- #-----------------------------------------------------------------------------
69
- # frontend
70
- #-----------------------------------------------------------------------------
71
-
72
- COMMANDS = {
73
- 't' => :run_all_test_files,
74
- 's' => :stop_running_test_files,
75
- 'p' => :rerun_passed_test_files,
76
- 'f' => :rerun_failed_test_files,
77
- 'o' => :reabsorb_overhead_files,
78
- 'q' => :quit,
79
- }
80
-
81
- while key = STDIN.gets
82
- if command = COMMANDS[key.strip]
83
- warn "#{$0}: Sending #{command.to_s.inspect} command..."
84
- @driver.send [command]
85
- break if command == :quit
86
- else # invalid command
87
- COMMANDS.each do |key, cmd|
88
- warn "#{$0}: Type #{key} then ENTER to #{cmd.to_s.tr('_', ' ')}."
89
- end
90
- end
91
- end
92
-
93
- Process.waitall
126
+ ENV['TORK_CONFIGS'] = [ENV['TORK_CONFIGS'], *ARGV].join(':') if ARGV.any?
127
+ require 'tork/config'
128
+
129
+ require 'tork/cliapp'
130
+ Tork::CLIApp.new.loop
data/bin/tork-driver CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  =begin =======================================================================
3
3
 
4
- # TORK-DRIVER 1 2012-10-10 18.2.4
4
+ # TORK-DRIVER 1 2012-10-17 19.0.0
5
5
 
6
6
  ## NAME
7
7
 
@@ -13,31 +13,32 @@ tork-driver - drives tork-engine(1) when files change
13
13
 
14
14
  ## DESCRIPTION
15
15
 
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.
16
+ This program drives tork-engine(1) when tork-herald(1) reports files changes.
17
+
18
+ This program can be controlled remotely by multiple tork-remote(1) instances.
19
+
20
+ ### Input
21
+
22
+ This program reads the following commands, which are single-line JSON arrays,
23
+ from stdin and performs the actions described respectively.
20
24
 
21
25
  `["run_all_test_files"]`
22
26
  Runs all test files found within and beneath the current working directory.
23
27
 
24
- `["reabsorb_overhead_files"]`
25
- Stops any test files that are currently running, reabsorbs the test
26
- execution overhead, and resumes running those interrupted test files.
27
-
28
28
  *...*
29
- This program accepts tork-engine(1) commands and delegates them accordingly.
29
+ Commands for tork-engine(1) are also accepted here.
30
+
31
+ ### Output
30
32
 
31
- When tork-herald(1) reports that a file belonging to the test execution
32
- overhead has been modified, this program replaces tork-master(1) with a new
33
- instance, which then absorbs the modified test execution overhead into itself.
33
+ This program prints the following messages, which are single-line JSON arrays,
34
+ to stdout.
34
35
 
35
- This program emits the following single-line status messages (JSON arrays) on
36
- its standard output stream to provide notifications about its activity:
36
+ `["reabsorb",` *overhead_file*`]`
37
+ Test execution overhead is being reabsorbed because *overhead_file* has
38
+ changed.
37
39
 
38
- `["over",` *overhead_file*`]`
39
- The test execution overhead is currently being reabsorbed, by replacing
40
- tork-master(1) with a new instance, because *overhead_file* has changed.
40
+ *...*
41
+ Messages from tork-engine(1) and tork-master(1) are also reproduced here.
41
42
 
42
43
  ## OPTIONS
43
44
 
@@ -46,19 +47,117 @@ its standard output stream to provide notifications about its activity:
46
47
 
47
48
  ## FILES
48
49
 
49
- *.tork.rb*
50
- Optional Ruby script for configuring tork(1).
50
+ *.tork/config.rb*
51
+ Optional Ruby script that is loaded inside the driver process on startup.
52
+ It can read and change the `ENV['TORK_CONFIGS']` environment variable.
53
+
54
+ `.tork/driver.rb`
55
+ Optional Ruby script that is loaded inside the driver process on startup.
56
+ It can read and change the following variables.
57
+
58
+ > `Tork::Driver::REABSORB_FILE_GREPS`
59
+ > Array of strings or regular expressions that match the paths of overhead
60
+ > files. If any of these equal or match the path of a changed file
61
+ > reported by tork-herald(1), then the test execution overhead will be
62
+ > reabsorbed in tork-master(1).
63
+ >
64
+ > `Tork::Driver::ALL_TEST_FILE_GLOBS`
65
+ > Array of file globbing patterns that describe the set of all test files
66
+ > in your Ruby application.
67
+ >
68
+ > `Tork::Driver::TEST_FILE_GLOBBERS`
69
+ > Hash that maps (1) a regular expression describing a set of file paths
70
+ > to (2) a lambda function that accepts a `MatchData` object containing
71
+ > the results of the regular expression matching against the path of a
72
+ > changed file, and yields one or more file globbing patterns (a single
73
+ > string, or an array of strings) that describe a set of test files that
74
+ > need to be run.
75
+ >
76
+ > The results of these functions are recursively expanded (fed back into
77
+ > them) to construct an entire dependency tree of test files that need to
78
+ > be run. For instance, if one function returns a glob that yields files
79
+ > matched by another function, then that second function will be called to
80
+ > glob more test files. This process repeats until all dependent test
81
+ > files have been accounted for.
82
+ >
83
+ > > ***Single glob expansion***
84
+ > >
85
+ > > For example, if test files had the same names as their source files
86
+ > > followed by an underscore and the file name in reverse like this:
87
+ > >
88
+ > > * lib/hello.rb => test/hello_olleh.rb
89
+ > > * app/world.rb => spec/world_ldrow.rb
90
+ > >
91
+ > > Then you would add the following to your configuration file:
92
+ > >
93
+ > > Tork::Driver::TEST_FILE_GLOBBERS.update(
94
+ > > %r{^(lib|app)/.*?([^/]+?)\.rb$} => lambda do |matches|
95
+ > > name = matches[2]
96
+ > > "{test,spec}/**/#{name}_#{name.reverse}.rb"
97
+ > > end
98
+ > > )
99
+ > >
100
+ > > ***Multi-glob expansion***
101
+ > >
102
+ > > For example, if test files could optionally have "test" or "spec"
103
+ > > prefixed or appended to their already peculiar names, like so:
104
+ > >
105
+ > > * lib/hello.rb => test/hello\_olleh\_test.rb
106
+ > > * lib/hello.rb => test/test\_hello\_olleh.rb
107
+ > > * app/world.rb => spec/world\_ldrow\_spec.rb
108
+ > > * app/world.rb => spec/spec\_world\_ldrow.rb
109
+ > >
110
+ > > Then you would add the following to your configuration file:
111
+ > >
112
+ > > Tork::Driver::TEST_FILE_GLOBBERS.update(
113
+ > > %r{^(lib|app)/.*?([^/]+?)\.rb$} => lambda do |matches|
114
+ > > name = matches[2]
115
+ > > ["{test,spec}/**/#{name}_#{name.reverse}.rb",
116
+ > > "{test,spec}/**/#{name}_#{name.reverse}_{test,spec}.rb",
117
+ > > "{test,spec}/**/{test,spec}_#{name}_#{name.reverse}.rb"]
118
+ > > end
119
+ > > )
120
+ > >
121
+ > > ***Recursive expansion***
122
+ > >
123
+ > > For example, if you wanted to run test files associated with
124
+ > > `lib/hello.rb` whenever the `app/world.rb` file changed, then you would
125
+ > > write:
126
+ > >
127
+ > > Tork::Driver::TEST_FILE_GLOBBERS.update(
128
+ > > %r{^app/world\.rb$} => lambda do |matches|
129
+ > > 'lib/hello.rb'
130
+ > > end
131
+ > > )
132
+ > >
133
+ > > This effectively aliases one file onto another, but not in both
134
+ > > directions.
135
+ > >
136
+ > > ***Suppressing expansion***
137
+ > >
138
+ > > These lambda functions can return `nil` if they do not wish for a
139
+ > > particular source file to be tested. For example, to ignore tests for
140
+ > > all source files except those within a `models/` directory, you would
141
+ > > write:
142
+ > >
143
+ > > Tork::Driver::TEST_FILE_GLOBBERS.update(
144
+ > > %r{^(lib|app)(/.*?)([^/]+?)\.rb$} => lambda do |matches|
145
+ > > if matches[2].include? '/models/'
146
+ > > ["{test,spec}/**/#{matches[3]}_{test,spec}.rb",
147
+ > > "{test,spec}/**/{test,spec}_#{matches[3]}.rb"]
148
+ > > #else # implied by the Ruby language
149
+ > > #nil # implied by the Ruby language
150
+ > > end
151
+ > > end
152
+ > > )
51
153
 
52
154
  ## ENVIRONMENT
53
155
 
54
- `TORK_CONFIGS`
55
- A single-line JSON array containing paths to actual files or names of
56
- helper libraries in the tork/config/ namespace of Ruby's load path.
57
- These configuration files are loaded just before *.tork.rb* is loaded.
156
+ See tork(1).
58
157
 
59
158
  ## SEE ALSO
60
159
 
61
- tork(1), tork-herald(1), tork-driver(1), tork-engine(1), tork-master(1)
160
+ tork(1), tork-remote(1), tork-herald(1), tork-engine(1), tork-master(1)
62
161
 
63
162
  =end =========================================================================
64
163
 
data/bin/tork-engine CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  =begin =======================================================================
3
3
 
4
- # TORK-ENGINE 1 2012-10-10 18.2.4
4
+ # TORK-ENGINE 1 2012-10-17 19.0.0
5
5
 
6
6
  ## NAME
7
7
 
@@ -13,24 +13,31 @@ tork-engine - wraps tork-master(1) with bookkeeping
13
13
 
14
14
  ## DESCRIPTION
15
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.
16
+ This program uses tork-master(1) to run tests and keeps track of the results.
20
17
 
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.
18
+ This program can be controlled remotely by multiple tork-remote(1) instances.
25
19
 
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.
20
+ ### Input
31
21
 
32
- `["stop_running_test_files"]`
33
- Stops any test files that are currently running.
22
+ This program reads the following commands, which are single-line JSON arrays,
23
+ from stdin and performs the actions described respectively.
24
+
25
+ `["reabsorb_overhead"]`
26
+ Stops any test files that are currently running, reabsorbs the test
27
+ execution overhead, and then re-runs those stopped test files.
28
+
29
+ `["run_test_file"`, *test_file*`,` *line_numbers*...`]`
30
+ Runs tests that correspond to the given sequence of *line_numbers* in the
31
+ given *test_file*. If no *line_numbers* are given, then only those lines
32
+ that have changed since the last run of *test_file* will be substituted.
33
+ If any *line_numbers* are zero, then the entire *test_file* will be run.
34
+
35
+ `["run_test_files"`, *test_files_with_optional_line_numbers*`]`
36
+ Calls the `run_test_file` command once for each item in the given array.
37
+
38
+ `["stop_running_test_files"`, *signal*`]`
39
+ Stops test files that are currently running by sending the given *signal*
40
+ (optional; defaults to "SIGTERM") to their respective worker processes.
34
41
 
35
42
  `["rerun_passed_test_files"]`
36
43
  Runs all test files that have passed during their most recent run.
@@ -41,6 +48,20 @@ It also funnels the standard output stream of tork-master(1) into its own.
41
48
  `["quit"]`
42
49
  Stops all tests that are currently running and exits.
43
50
 
51
+ ### Output
52
+
53
+ This program prints the following messages, which are single-line JSON arrays,
54
+ to stdout.
55
+
56
+ `["pass_now_fail",` *test_file*`,` *message*`]`
57
+ A previously passing *test_file* has now failed. See *message* for details.
58
+
59
+ `["fail_now_pass",` *test_file*`,` *message*`]`
60
+ A previously failing *test_file* has now passed. See *message* for details.
61
+
62
+ *...*
63
+ Messages from tork-master(1) are also reproduced here.
64
+
44
65
  ## OPTIONS
45
66
 
46
67
  `-h`, `--help`
@@ -48,19 +69,20 @@ It also funnels the standard output stream of tork-master(1) into its own.
48
69
 
49
70
  ## FILES
50
71
 
51
- *.tork.rb*
52
- Optional Ruby script for configuring tork(1).
72
+ *.tork/config.rb*
73
+ Optional Ruby script that is loaded inside the driver process on startup.
74
+ It can read and change the `ENV['TORK_CONFIGS']` environment variable.
75
+
76
+ *.tork/engine.rb*
77
+ Optional Ruby script that is loaded inside the master process on startup.
53
78
 
54
79
  ## ENVIRONMENT
55
80
 
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.
81
+ See tork(1).
60
82
 
61
83
  ## SEE ALSO
62
84
 
63
- tork(1), tork-herald(1), tork-driver(1), tork-engine(1), tork-master(1)
85
+ tork(1), tork-remote(1), tork-master(1)
64
86
 
65
87
  =end =========================================================================
66
88