test-loop 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md +9 -6
  2. data/bin/test-loop +14 -11
  3. metadata +3 -3
data/README.md CHANGED
@@ -8,21 +8,24 @@ and tests changes in your Ruby application in an efficient manner, whereby it:
8
8
  2. Forks to evaluate your test files directly and without overhead.
9
9
 
10
10
  It relies on file modification times to determine what parts of your Ruby
11
- application have changed and then determines which test files in your test
12
- suite correspond to those changes using a simple lambda mapping function.
11
+ application have changed and then uses a simple lambda mapping function to
12
+ determine which test files in your test suite correspond to those changes.
13
13
 
14
14
 
15
15
  Features
16
16
  --------
17
17
 
18
- * Tests CHANGES in your Ruby application; does NOT run all tests every time.
18
+ * Tests *changes* in your Ruby application; does not run all tests every time.
19
19
 
20
20
  * Reabsorbs test execution overhead if the test or spec helper file changes.
21
21
 
22
22
  * Mostly I/O bound, so you can have it always running without CPU slowdowns.
23
23
 
24
- * Supports Test::Unit, RSpec, or any other testing framework that is utilized
25
- by your application's `test/test_helper.rb` and `spec/spec_helper.rb` files.
24
+ * Supports any testing framework that (1) reflects failures in the process'
25
+ exit status and (2) is loaded by your application's `test/test_helper.rb`
26
+ or `spec/spec_helper.rb` file.
27
+
28
+ * Configurable through a `.test-loop` file in your current working directory.
26
29
 
27
30
  * Implemented in less than 60 (SLOC) lines of code! :-)
28
31
 
@@ -95,7 +98,7 @@ define the following instance variables:
95
98
  end
96
99
  }
97
100
 
98
- * `@after_test_execution` is a proc/lambda object that is executed after tests
101
+ * `@after_test_execution` is a lambda function that is executed after tests
99
102
  are run. It is passed three things: the status of the test execution
100
103
  subprocess, the time when the tests were run, and the list of test files
101
104
  that were run.
data/bin/test-loop CHANGED
@@ -21,12 +21,13 @@
21
21
  # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
22
22
  # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23
23
  #
24
+
25
+ process_invocation_vector = [$0, *ARGV].map! {|s| s.dup }
26
+
24
27
  begin
25
- def notify message
26
- puts "test-loop: #{message}"
27
- end
28
+ notify = lambda {|message| puts "test-loop: #{message}" }
28
29
 
29
- notify 'Loading configuration...'
30
+ notify.call 'Loading configuration...'
30
31
  config_file = File.join(Dir.pwd, '.test-loop')
31
32
  load config_file if File.exist? config_file
32
33
 
@@ -54,7 +55,7 @@ begin
54
55
  # absorb test execution overhead into master process
55
56
  $LOAD_PATH.unshift 'lib' # for non-Rails applications
56
57
 
57
- notify 'Absorbing overhead...'
58
+ notify.call 'Absorbing overhead...'
58
59
  Dir[*@overhead_file_globs].each do |file|
59
60
  $LOAD_PATH.insert 1, File.dirname(file)
60
61
  require File.basename(file, File.extname(file))
@@ -66,7 +67,7 @@ begin
66
67
  trap(:QUIT) { started_at = epoch_time }
67
68
  trap(:TSTP) { last_ran_at = epoch_time }
68
69
 
69
- notify 'Ready for testing!'
70
+ notify.call 'Ready for testing!'
70
71
  loop do
71
72
  # figure out what test files need to be run
72
73
  test_files = @source_file_to_test_file_mapping.
@@ -78,24 +79,26 @@ begin
78
79
 
79
80
  # fork worker process to run the test files
80
81
  unless test_files.empty?
81
- notify 'Running tests...'
82
+ notify.call 'Running tests...'
82
83
  last_ran_at = Time.now
83
- fork { test_files.each {|file| notify file; load file } }
84
+ fork { test_files.each {|file| notify.call file; load file } }
84
85
  Process.wait
85
86
  @after_test_execution.call($?, last_ran_at, test_files)
86
87
  end
87
88
 
88
89
  # reabsorb test execution overhead as necessary
89
90
  if Dir[*@reabsorb_file_globs].any? {|file| File.mtime(file) > started_at }
90
- notify 'Restarting loop...'
91
- exec $0, *ARGV
91
+ notify.call 'Restarting loop...'
92
+ exec(*process_invocation_vector)
92
93
  end
93
94
 
94
95
  sleep 1
95
96
  end
97
+
96
98
  rescue Interrupt
97
99
  # user wants to quit the loop
100
+
98
101
  rescue StandardError, LoadError, SyntaxError => error
99
102
  puts error.inspect, error.backtrace
100
- sleep 1 and exec $0, *ARGV
103
+ sleep 1 and exec(*process_invocation_vector)
101
104
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 3
7
7
  - 0
8
- - 0
9
- version: 3.0.0
8
+ - 1
9
+ version: 3.0.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Suraj N. Kurapati
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-04 00:00:00 -08:00
17
+ date: 2011-01-05 00:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies: []
20
20