tork 19.8.2 → 19.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION.markdown +27 -0
  3. data/bin/tork +3 -16
  4. data/bin/tork-driver +2 -2
  5. data/bin/tork-engine +2 -2
  6. data/bin/tork-herald +1 -1
  7. data/bin/tork-master +2 -2
  8. data/bin/tork-notify +1 -1
  9. data/bin/tork-runner +1 -1
  10. data/lib/tork/cliapp.rb +32 -17
  11. data/lib/tork/config.rb +5 -5
  12. data/lib/tork/config/bundler/config.rb +1 -0
  13. data/lib/tork/config/cucumber/config.rb +1 -0
  14. data/lib/tork/config/devise/config.rb +1 -0
  15. data/lib/tork/config/factory_girl/config.rb +1 -0
  16. data/lib/tork/config/rails/config.rb +1 -0
  17. data/lib/tork/config/spec/config.rb +4 -0
  18. data/lib/tork/config/spec/driver.rb +5 -9
  19. data/lib/tork/config/spec/master.rb +1 -0
  20. data/lib/tork/config/spec/worker.rb +1 -1
  21. data/lib/tork/config/test/config.rb +10 -0
  22. data/lib/tork/config/test/driver.rb +5 -9
  23. data/lib/tork/config/test/master.rb +1 -0
  24. data/lib/tork/config/test/worker.rb +1 -1
  25. data/lib/tork/engine.rb +3 -3
  26. data/lib/tork/master.rb +1 -1
  27. data/lib/tork/version.rb +1 -1
  28. data/man/index.html +1 -1
  29. data/man/man0/README.html +1 -1
  30. data/man/man0/VERSION.html +126 -105
  31. data/man/man0/VERSION.markdown +27 -0
  32. data/man/man1/tork-driver.1 +2 -2
  33. data/man/man1/tork-driver.1.html +3 -3
  34. data/man/man1/tork-engine.1 +2 -2
  35. data/man/man1/tork-engine.1.html +3 -3
  36. data/man/man1/tork-herald.1 +1 -1
  37. data/man/man1/tork-herald.1.html +2 -2
  38. data/man/man1/tork-master.1 +2 -2
  39. data/man/man1/tork-master.1.html +3 -3
  40. data/man/man1/tork-notify.1 +1 -1
  41. data/man/man1/tork-notify.1.html +2 -2
  42. data/man/man1/tork-remote.1.html +1 -1
  43. data/man/man1/tork-runner.1 +1 -1
  44. data/man/man1/tork-runner.1.html +2 -2
  45. data/man/man1/tork.1 +9 -45
  46. data/man/man1/tork.1.html +4 -17
  47. metadata +9 -3
  48. data/lib/tork/config/default/config.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d43b1c853bce71a2d45e8c10285f62086b87d695
4
- data.tar.gz: 121972db46e71b3ae1638e1db88aa7d97caeaf36
3
+ metadata.gz: db7c9496a3b8d6e14495d3cf7697adbed44650d5
4
+ data.tar.gz: 1aac8ca254bc58ebe2561f7aeeef8eb7a7ee672c
5
5
  SHA512:
6
- metadata.gz: 9ae7a869ff7da979724748a11376e3eb20e67bca33708845f9c6205cfe72c705306866f79b8232f00011d8f56a9f28335dc7acefa6b4570cea48d9b41353f51f
7
- data.tar.gz: a1cde8d17f54545c9d7fd329fc9f2a0ec3a4b9f0644fadcee29b2f7396af9a0975452777e233d9e340a0725fb7fe8252a76215ff47eaeb006bf7c10ee9775a37
6
+ metadata.gz: a730b6a80141971a6c8eee69fa45aed9ff464ea23a4d0c85b4a91241f8e60ae7cdc3f1c05e23d0348fea55fb227784c007d4ea0d785d95ead7a52b798ae684dc
7
+ data.tar.gz: 12e0de85fbb9ca6b2075251068979b78e945e22d0b85f42c121211d9018ee4ae308476bf5a189e0b078449fbc1001c1d74c7a0fb7a68ac1d126237ed9046662d
data/VERSION.markdown CHANGED
@@ -1,3 +1,30 @@
1
+ ## Version 19.9.0 (2014-07-17)
2
+
3
+ ### Minor:
4
+
5
+ * Add support for testing outside `test/` and `spec/` directories. This
6
+ change lets you run test files directly from the current working directory
7
+ without having to put them inside special `test/` and `spec/` directories.
8
+
9
+ This can be useful if you are learning Ruby or writing tests for simple
10
+ scripts because you need not create a directory structure that is fit for
11
+ a larger application just for the sole purpose of running your tests!
12
+
13
+ * Drop the `default` configuration helper and load the `config.rb` files of
14
+ all configuration helpers on startup instead. This way, each helper can
15
+ itself detect whether it is needed from inside its own `config.rb` file.
16
+
17
+ * Censor Tork internals from test failure backtraces so that users can
18
+ inspect them quickly to find where errors are arising in their code.
19
+
20
+ ### Patch:
21
+
22
+ * Only 1 worker was being used on a dual-core system.
23
+
24
+ ### Other:
25
+
26
+ * tork(1): use complete sentences in the help message.
27
+
1
28
  ## Version 19.8.2 (2014-07-01)
2
29
 
3
30
  This release adds support for RSpec 3+ in the `spec` configuration helper.
data/bin/tork CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  =begin =======================================================================
3
3
 
4
- # TORK 1 2014-07-01 19.8.2
4
+ # TORK 1 2014-07-17 19.9.0
5
5
 
6
6
  ## NAME
7
7
 
@@ -46,7 +46,7 @@ This program can be controlled remotely by multiple tork-remote(1) instances.
46
46
  ## FILES
47
47
 
48
48
  *.tork/config.rb*
49
- Optional Ruby script that is loaded inside the driver process on startup.
49
+ Optional Ruby script that is loaded inside this Tork process on startup.
50
50
  It can read and change the `ENV['TORK_CONFIGS']` environment variable.
51
51
 
52
52
  ## ENVIRONMENT
@@ -54,21 +54,7 @@ This program can be controlled remotely by multiple tork-remote(1) instances.
54
54
  `TORK_CONFIGS`
55
55
  Colon-separated (:) list of either paths to directories that contain
56
56
  configuration files or names of the following configuration helpers.
57
- If this variable is not set, then its value is assumed to be "default".
58
57
 
59
- > `default`
60
- > Loads the following configuration helpers (as appropriate) if your
61
- > current working directory appears to utilize what they configure.
62
- > See below for complete descriptions of these configuration helpers.
63
- >
64
- > * bundler
65
- > * rails
66
- > * devise
67
- > * test
68
- > * spec
69
- > * cucumber
70
- > * factory_girl
71
- >
72
58
  > `dotlog`
73
59
  > Hides log files by prefixing their names with a period (dot).
74
60
  >
@@ -129,6 +115,7 @@ tork-runner(1), tork-driver(1), tork-master(1)
129
115
 
130
116
  =end =========================================================================
131
117
 
118
+ TORK_DOLLAR_ZERO = $0
132
119
  $0 = File.basename(__FILE__) # for easier identification in ps(1) output
133
120
 
134
121
  require 'binman'
data/bin/tork-driver CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  =begin =======================================================================
3
3
 
4
- # TORK-DRIVER 1 2014-07-01 19.8.2
4
+ # TORK-DRIVER 1 2014-07-17 19.9.0
5
5
 
6
6
  ## NAME
7
7
 
@@ -51,7 +51,7 @@ to stdout.
51
51
  ## FILES
52
52
 
53
53
  *.tork/config.rb*
54
- Optional Ruby script that is loaded inside the driver process on startup.
54
+ Optional Ruby script that is loaded inside this Tork process on startup.
55
55
  It can read and change the `ENV['TORK_CONFIGS']` environment variable.
56
56
 
57
57
  `.tork/driver.rb`
data/bin/tork-engine CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  =begin =======================================================================
3
3
 
4
- # TORK-ENGINE 1 2014-07-01 19.8.2
4
+ # TORK-ENGINE 1 2014-07-17 19.9.0
5
5
 
6
6
  ## NAME
7
7
 
@@ -76,7 +76,7 @@ to stdout.
76
76
  ## FILES
77
77
 
78
78
  *.tork/config.rb*
79
- Optional Ruby script that is loaded inside the driver process on startup.
79
+ Optional Ruby script that is loaded inside this Tork process on startup.
80
80
  It can read and change the `ENV['TORK_CONFIGS']` environment variable.
81
81
 
82
82
  *.tork/engine.rb*
data/bin/tork-herald CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  =begin =======================================================================
3
3
 
4
- # TORK-HERALD 1 2014-07-01 19.8.2
4
+ # TORK-HERALD 1 2014-07-17 19.9.0
5
5
 
6
6
  ## NAME
7
7
 
data/bin/tork-master CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  =begin =======================================================================
3
3
 
4
- # TORK-MASTER 1 2014-07-01 19.8.2
4
+ # TORK-MASTER 1 2014-07-17 19.9.0
5
5
 
6
6
  ## NAME
7
7
 
@@ -66,7 +66,7 @@ to stdout.
66
66
  ## FILES
67
67
 
68
68
  *.tork/config.rb*
69
- Optional Ruby script that is loaded inside the driver process on startup.
69
+ Optional Ruby script that is loaded inside this Tork process on startup.
70
70
  It can read and change the `ENV['TORK_CONFIGS']` environment variable.
71
71
 
72
72
  *.tork/master.rb*
data/bin/tork-notify CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  =begin =======================================================================
3
3
 
4
- # TORK-NOTIFY 1 2014-07-01 19.8.2
4
+ # TORK-NOTIFY 1 2014-07-17 19.9.0
5
5
 
6
6
  ## NAME
7
7
 
data/bin/tork-runner CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  =begin =======================================================================
3
3
 
4
- # TORK-RUNNER 1 2014-07-01 19.8.2
4
+ # TORK-RUNNER 1 2014-07-17 19.9.0
5
5
 
6
6
  ## NAME
7
7
 
data/lib/tork/cliapp.rb CHANGED
@@ -3,17 +3,6 @@ require 'tork/server'
3
3
  module Tork
4
4
  class CLIApp < Server
5
5
 
6
- COMMANDS = {
7
- 't' => :run_test_file,
8
- 'a' => :run_all_test_files,
9
- 's' => :stop_running_test_files,
10
- 'k' => [:stop_running_test_files, :SIGKILL],
11
- 'p' => :rerun_passed_test_files,
12
- 'f' => :rerun_failed_test_files,
13
- 'o' => :reabsorb_overhead,
14
- 'q' => :quit,
15
- }
16
-
17
6
  def loop
18
7
  tell @clients, 'Absorbing test execution overhead...', false
19
8
  @driver = popen('tork-driver')
@@ -29,6 +18,10 @@ protected
29
18
  help client
30
19
  end
31
20
 
21
+ BACKTRACE_CENSOR = /\n\s+(?:from\s)?#{
22
+ Regexp.union(File.expand_path('../../..', __FILE__), TORK_DOLLAR_ZERO)
23
+ }[^:]*:\d+:.+$/
24
+
32
25
  def recv client, message
33
26
  case client
34
27
  when @driver
@@ -51,7 +44,12 @@ protected
51
44
  when :fail then "\e[31m%s\e[0m" # red
52
45
  end
53
46
  message = color % message if color and STDOUT.tty?
54
- message = [message, File.read(log_file), message] if event_sym == :fail
47
+
48
+ if event_sym == :fail
49
+ # censor Tork internals from test failure backtraces
50
+ log = File.read(log_file).gsub(BACKTRACE_CENSOR, '')
51
+ message = [message, log, message]
52
+ end
55
53
 
56
54
  tell @clients, message, false
57
55
  end
@@ -69,12 +67,29 @@ protected
69
67
 
70
68
  private
71
69
 
70
+ COMMANDS = {
71
+ 't' => :run_test_file,
72
+ 'a' => :run_all_test_files,
73
+ 's' => :stop_running_test_files,
74
+ 'k' => [:stop_running_test_files, :SIGKILL],
75
+ 'p' => :rerun_passed_test_files,
76
+ 'f' => :rerun_failed_test_files,
77
+ 'o' => :reabsorb_overhead,
78
+ 'q' => :quit,
79
+ }
80
+
72
81
  def help client
73
- COMMANDS.each do |key, cmd|
74
- desc = Array(cmd).join(' with ').to_s.tr('_', ' ')
75
- tell client, "Type #{key} then ENTER to #{desc}.", false
76
- end
77
- tell client, 'Type h then ENTER to see this message.', false
82
+ tell client, <<HELP, false
83
+ Type a then ENTER to run all test files.
84
+ Type t then SPACE then a filename then ENTER to run a specific test file.
85
+ Type s then ENTER to stop currently running test files.
86
+ Type k then ENTER to stop currently running test files with SIGKILL.
87
+ Type p then ENTER to re-run passing test files.
88
+ Type f then ENTER to re-run failing test files.
89
+ Type o then ENTER to reabsorb test execution overhead.
90
+ Type h then ENTER to see this help message.
91
+ Type q then ENTER to quit.
92
+ HELP
78
93
  end
79
94
 
80
95
  end
data/lib/tork/config.rb CHANGED
@@ -1,17 +1,17 @@
1
1
  module Tork
2
2
  # Loads all Ruby scripts found having the given name in (1) the directories
3
- # specified in the TORK_CONFIGS environment variable, (2) the subdirectories
3
+ # specified in the given $TORK_CONFIGS search path, (2) the subdirectories
4
4
  # of lib/tork/config/, and (3) the user's .tork/ directory; in that order.
5
5
  #
6
6
  # @return [Array] paths of Ruby scripts that were loaded
7
7
  #
8
- def self.config name
9
- dirs = ENV['TORK_CONFIGS'].strip.split(/:+/).reject(&:empty?).uniq.
8
+ def self.config name, search_path=ENV['TORK_CONFIGS']
9
+ dirs = search_path.to_s.strip.split(/:+/).reject(&:empty?).uniq.
10
10
  map {|dir| [dir, __FILE__.sub(/\.rb$/, "/#{dir}")] }.flatten
11
11
 
12
12
  Dir["{#{dirs.join(',')},.tork}/#{name}.rb"].each {|script| load script }
13
13
  end
14
14
  end
15
15
 
16
- ENV['TORK_CONFIGS'] ||= 'default'.freeze # ENV values come frozen by default
17
- Tork.config :config
16
+ ENV['TORK_CONFIGS'] ||= String.new.freeze # ENV values come frozen by default
17
+ Tork.config :config, '*'
@@ -0,0 +1 @@
1
+ ENV['TORK_CONFIGS'] += ':bundler' if Dir['Gemfile{,.lock}'].any?
@@ -0,0 +1 @@
1
+ ENV['TORK_CONFIGS'] += ':cucumber' if File.directory? 'features'
@@ -0,0 +1 @@
1
+ ENV['TORK_CONFIGS'] += ':devise' if File.exist? 'config/initializers/devise.rb'
@@ -0,0 +1 @@
1
+ ENV['TORK_CONFIGS'] += ':factory_girl' if Dir['{test,spec}/factories/'].any?
@@ -0,0 +1 @@
1
+ ENV['TORK_CONFIGS'] += ':rails' if Dir['script/{rails,console}'].any?
@@ -0,0 +1,4 @@
1
+ $tork_config_spec_glob = '**/{spec_*,*_spec}.rb'
2
+ $tork_config_spec_grep = %r{.*(\bspec_[^/]+|[^/]+_spec)\.rb$}
3
+
4
+ ENV['TORK_CONFIGS'] += ':spec' if Dir['spec/', $tork_config_spec_glob].any?
@@ -1,17 +1,13 @@
1
- Tork::Driver::REABSORB_FILE_GREPS.push 'spec/spec_helper.rb'
1
+ Tork::Driver::REABSORB_FILE_GREPS.push /\bspec_helper\.rb$/
2
2
 
3
- Tork::Driver::ALL_TEST_FILE_GLOBS.push 'spec/**/{spec_*,*_spec}.rb'
3
+ Tork::Driver::ALL_TEST_FILE_GLOBS.push $tork_config_spec_glob
4
4
 
5
5
  Tork::Driver::TEST_FILE_GLOBBERS.update(
6
6
  # source files that correspond to test files
7
- %r{^lib/.*?([^/]+)\.rb$} => lambda do |matches|
8
- target = matches[1]
9
- "spec/**/{spec_#{target},#{target}_spec}.rb"
7
+ %r{([^/]+)\.rb$} => lambda do |matches|
8
+ $tork_config_spec_glob.gsub(/(?<=_)\*|\*(?=_)/, matches[1])
10
9
  end,
11
10
 
12
11
  # the actual test files themselves
13
- %r{^spec/.+\.rb$} => lambda do |matches|
14
- target = matches[0]
15
- target if File.basename(target) =~ /^spec_|_spec\./
16
- end
12
+ $tork_config_spec_grep => lambda {|matches| matches[0] }
17
13
  )
@@ -1,4 +1,5 @@
1
1
  $LOAD_PATH.unshift 'spec' unless $LOAD_PATH.include? 'spec'
2
2
  $LOAD_PATH.unshift 'lib' unless $LOAD_PATH.include? 'lib'
3
3
  require 'spec_helper' if File.exist? 'spec/spec_helper.rb'
4
+ require './spec_helper' if File.exist? 'spec_helper.rb'
4
5
  require 'rspec/autorun' if defined? RSpec
@@ -5,7 +5,7 @@ rescue LoadError, NameError
5
5
  # ignore
6
6
  end
7
7
 
8
- if $tork_test_file.start_with? 'spec/' and $tork_line_numbers.any?
8
+ if $tork_line_numbers.any? and $tork_test_file =~ $tork_config_spec_grep
9
9
  if rspec_version and rspec_version >= '3.0'
10
10
  ARGV.push [$tork_test_file, *$tork_line_numbers].join(':')
11
11
  else
@@ -0,0 +1,10 @@
1
+ # people generally prefix or suffix their test file names with these labels
2
+ # https://en.wikibooks.org/wiki/Ruby_Programming/Unit_testing#Naming_Conventions
3
+ labels = %w[ test ts tc t ]
4
+ labels_glob = '{' + labels.join(',') + '}'
5
+ labels_grep = '(' + labels.join('|') + ')'
6
+
7
+ $tork_config_test_glob = "**/{#{labels_glob}_*,*_#{labels_glob}}.rb"
8
+ $tork_config_test_grep = %r{.*(\b#{labels_grep}_[^/]+|[^/]+_#{labels_grep})\.rb$}
9
+
10
+ ENV['TORK_CONFIGS'] += ':test' if Dir['test/', $tork_config_test_glob].any?
@@ -1,17 +1,13 @@
1
- Tork::Driver::REABSORB_FILE_GREPS.push 'test/test_helper.rb'
1
+ Tork::Driver::REABSORB_FILE_GREPS.push /\btest_helper\.rb$/
2
2
 
3
- Tork::Driver::ALL_TEST_FILE_GLOBS.push 'test/**/{test_*,*_test}.rb'
3
+ Tork::Driver::ALL_TEST_FILE_GLOBS.push $tork_config_test_glob
4
4
 
5
5
  Tork::Driver::TEST_FILE_GLOBBERS.update(
6
6
  # source files that correspond to test files
7
- %r{^lib/.*?([^/]+)\.rb$} => lambda do |matches|
8
- target = matches[1]
9
- "test/**/{test_#{target},#{target}_test}.rb"
7
+ %r{([^/]+)\.rb$} => lambda do |matches|
8
+ $tork_config_test_glob.gsub(/(?<=_)\*|\*(?=_)/, matches[1])
10
9
  end,
11
10
 
12
11
  # the actual test files themselves
13
- %r{^test/.+\.rb$} => lambda do |matches|
14
- target = matches[0]
15
- target if File.basename(target) =~ /^test_|_test\./
16
- end
12
+ $tork_config_test_grep => lambda {|matches| matches[0] }
17
13
  )
@@ -1,4 +1,5 @@
1
1
  $LOAD_PATH.unshift 'test' unless $LOAD_PATH.include? 'test'
2
2
  $LOAD_PATH.unshift 'lib' unless $LOAD_PATH.include? 'lib'
3
3
  require 'test_helper' if File.exist? 'test/test_helper.rb'
4
+ require './test_helper' if File.exist? 'test_helper.rb'
4
5
  require 'minitest/autorun' if defined? MiniTest
@@ -1,4 +1,4 @@
1
- if $tork_test_file.start_with? 'test/' and $tork_line_numbers.any?
1
+ if $tork_line_numbers.any? and $tork_test_file =~ $tork_config_test_grep
2
2
  test_file_lines = File.readlines($tork_test_file)
3
3
  test_names = $tork_line_numbers.map do |line|
4
4
  catch :found do
data/lib/tork/engine.rb CHANGED
@@ -51,7 +51,7 @@ class Engine < Server
51
51
 
52
52
  def stop_running_test_files signal=nil
53
53
  if @running_test_files.empty?
54
- tell @client, 'There are no running test files to stop.'
54
+ tell @client, 'There are no test files currently running.'
55
55
  else
56
56
  send @master, [:stop, signal].compact
57
57
  @running_test_files.clear
@@ -60,7 +60,7 @@ class Engine < Server
60
60
 
61
61
  def rerun_passed_test_files
62
62
  if @passed_test_files.empty?
63
- tell @client, 'There are no passed test files to re-run.'
63
+ tell @client, 'There are no passing test files to re-run.'
64
64
  else
65
65
  run_test_files @passed_test_files
66
66
  end
@@ -68,7 +68,7 @@ class Engine < Server
68
68
 
69
69
  def rerun_failed_test_files
70
70
  if @failed_test_files.empty?
71
- tell @client, 'There are no failed test files to re-run.'
71
+ tell @client, 'There are no failing test files to re-run.'
72
72
  else
73
73
  run_test_files @failed_test_files
74
74
  end
data/lib/tork/master.rb CHANGED
@@ -31,7 +31,7 @@ class Master < Server
31
31
 
32
32
  def test test_file, line_numbers
33
33
  # throttle forking rate to meet the maximum concurrent workers limit
34
- sleep 1 until @command_by_worker_pid.size < @worker_number_pool.size
34
+ sleep 1 until @command_by_worker_pid.size <= @worker_number_pool.size
35
35
 
36
36
  $tork_test_file = test_file
37
37
  $tork_line_numbers = line_numbers
data/lib/tork/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tork
2
- VERSION = "19.8.2"
2
+ VERSION = "19.9.0"
3
3
  end
data/man/index.html CHANGED
@@ -2,7 +2,7 @@
2
2
  <html>
3
3
  <head>
4
4
  <meta charset="utf-8" />
5
- <meta name="generator" content="md2man 3.0.0 https://github.com/sunaku/md2man" />
5
+ <meta name="generator" content="md2man 3.0.1 https://github.com/sunaku/md2man" />
6
6
  <title>man/index</title>
7
7
  <link rel="stylesheet" href="style.css"/>
8
8
  <!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->