test-loop 0.0.2 → 1.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.
- data/README.md +13 -14
- data/bin/test-loop +51 -1
- metadata +3 -5
- data/lib/tasks/test-loop.rake +0 -8
- data/lib/test-loop.rb +0 -42
data/README.md
CHANGED
@@ -15,16 +15,16 @@ determine which test files in your test suite correspond to those changes.
|
|
15
15
|
Features
|
16
16
|
--------
|
17
17
|
|
18
|
-
* Supports Test::Unit, RSpec, or any other testing framework that is utilized
|
19
|
-
by your application's `test/test_helper.rb` and `spec/spec_helper.rb` files.
|
20
|
-
|
21
18
|
* Tests CHANGES in your Ruby application; does NOT run all tests every time.
|
22
19
|
|
23
20
|
* Reabsorbs test execution overhead if the test or spec helper file changes.
|
24
21
|
|
25
22
|
* Mostly I/O bound, so you can have it always running without CPU slowdowns.
|
26
23
|
|
27
|
-
*
|
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.
|
26
|
+
|
27
|
+
* Implemented in less than 50 (SLOC) lines of code! :-)
|
28
28
|
|
29
29
|
|
30
30
|
Installation
|
@@ -34,10 +34,9 @@ As a Ruby gem:
|
|
34
34
|
|
35
35
|
gem install test-loop
|
36
36
|
|
37
|
-
As a
|
37
|
+
As a Git clone:
|
38
38
|
|
39
|
-
|
40
|
-
script/plugin install git://github.com/sunaku/test-loop # older Rails
|
39
|
+
git clone git://github.com/sunaku/test-loop
|
41
40
|
|
42
41
|
|
43
42
|
Invocation
|
@@ -47,21 +46,21 @@ If installed as a Ruby gem:
|
|
47
46
|
|
48
47
|
test-loop
|
49
48
|
|
50
|
-
If installed as a
|
49
|
+
If installed as a Git clone:
|
51
50
|
|
52
|
-
|
51
|
+
ruby -Ilib bin/test-loop
|
53
52
|
|
54
53
|
|
55
54
|
Operation
|
56
55
|
---------
|
57
56
|
|
58
|
-
* Press Control-Z to forcibly run all
|
59
|
-
if there are no changes in your Ruby application.
|
57
|
+
* Press Control-Z (or send the SIGTSTP signal) to forcibly run all
|
58
|
+
tests, even if there are no changes in your Ruby application.
|
60
59
|
|
61
|
-
* Press Control-\ (
|
62
|
-
execution overhead, even if its sources have not changed.
|
60
|
+
* Press Control-\ (or send the SIGQUIT signal) to forcibly reabsorb
|
61
|
+
the test execution overhead, even if its sources have not changed.
|
63
62
|
|
64
|
-
* Press Control-C to quit the test loop.
|
63
|
+
* Press Control-C (or send the SIGINT signal) to quit the test loop.
|
65
64
|
|
66
65
|
|
67
66
|
License
|
data/bin/test-loop
CHANGED
@@ -1,2 +1,52 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
require 'rake' # for String#pathmap
|
3
|
+
|
4
|
+
# absorb test execution overhead into master process
|
5
|
+
overhead_file_glob = '{test,spec}/*_helper.rb'
|
6
|
+
$LOAD_PATH.unshift 'lib' # for non-Rails applications
|
7
|
+
|
8
|
+
Dir[overhead_file_glob].each do |file|
|
9
|
+
$LOAD_PATH.unshift file.pathmap('%d')
|
10
|
+
require file.pathmap('%n')
|
11
|
+
end
|
12
|
+
|
13
|
+
# continuously watch for and test changed code
|
14
|
+
started_at = last_ran_at = Time.now
|
15
|
+
|
16
|
+
trap :QUIT do
|
17
|
+
puts 'test-loop: Reabsorbing overhead...'
|
18
|
+
started_at = Time.at(0)
|
19
|
+
end
|
20
|
+
|
21
|
+
trap :TSTP do
|
22
|
+
puts 'test-loop: Testing everything...'
|
23
|
+
last_ran_at = Time.at(0)
|
24
|
+
end
|
25
|
+
|
26
|
+
puts 'test-loop: Ready for testing!'
|
27
|
+
loop do
|
28
|
+
# figure out what test files need to be run
|
29
|
+
test_files = {
|
30
|
+
'{test,spec}/**/*_{test,spec}.rb' => '%p',
|
31
|
+
'{lib,app}/**/*.rb' => '{test,spec}/**/%n_{test,spec}%x',
|
32
|
+
}.
|
33
|
+
map do |source_file_glob, test_file_pathmap|
|
34
|
+
Dir[source_file_glob].
|
35
|
+
select {|file| File.mtime(file) > last_ran_at }.
|
36
|
+
map {|path| Dir[path.pathmap(test_file_pathmap)] }
|
37
|
+
end.flatten.uniq
|
38
|
+
|
39
|
+
# fork worker process to run the test files
|
40
|
+
unless test_files.empty?
|
41
|
+
last_ran_at = Time.now
|
42
|
+
fork { test_files.each {|file| load file } }
|
43
|
+
Process.wait
|
44
|
+
end
|
45
|
+
|
46
|
+
# reabsorb test execution overhead as necessary
|
47
|
+
if Dir[overhead_file_glob].any? {|file| File.mtime(file) > started_at }
|
48
|
+
exec 'ruby', __FILE__, *ARGV
|
49
|
+
end
|
50
|
+
|
51
|
+
sleep 1
|
52
|
+
end
|
metadata
CHANGED
@@ -3,10 +3,10 @@ name: test-loop
|
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
|
+
- 1
|
6
7
|
- 0
|
7
8
|
- 0
|
8
|
-
|
9
|
-
version: 0.0.2
|
9
|
+
version: 1.0.0
|
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: 2010-10-
|
17
|
+
date: 2010-10-15 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -30,8 +30,6 @@ files:
|
|
30
30
|
- LICENSE
|
31
31
|
- README.md
|
32
32
|
- bin/test-loop
|
33
|
-
- lib/test-loop.rb
|
34
|
-
- lib/tasks/test-loop.rake
|
35
33
|
has_rdoc: true
|
36
34
|
homepage: http://github.com/sunaku/test-loop
|
37
35
|
licenses: []
|
data/lib/tasks/test-loop.rake
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
namespace :test do
|
2
|
-
desc 'Test changes; Ctrl-Z forces; Ctrl-\ reloads; Ctrl-C quits.'
|
3
|
-
task :loop do |test_loop_task|
|
4
|
-
ENV['RAILS_ENV'] = 'test' # for Rails
|
5
|
-
ARGV.delete test_loop_task.name # obstructs RSpec
|
6
|
-
exec 'ruby', File.expand_path('../../test-loop.rb', __FILE__), *ARGV
|
7
|
-
end
|
8
|
-
end
|
data/lib/test-loop.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'rake' # for String#pathmap
|
2
|
-
|
3
|
-
# absorb test execution overhead into master process
|
4
|
-
overhead_file_glob = '{test,spec}/*_helper.rb'
|
5
|
-
$LOAD_PATH.unshift 'lib' # for non-Rails applications
|
6
|
-
|
7
|
-
Dir[overhead_file_glob].each do |file|
|
8
|
-
$LOAD_PATH.unshift file.pathmap('%d')
|
9
|
-
require file.pathmap('%n')
|
10
|
-
end
|
11
|
-
|
12
|
-
# continuously watch for and test changed code
|
13
|
-
started_at = last_ran_at = Time.now
|
14
|
-
trap(:QUIT) { started_at = Time.at(0) } # Control-\
|
15
|
-
trap(:TSTP) { last_ran_at = Time.at(0) } # Control-Z
|
16
|
-
|
17
|
-
loop do
|
18
|
-
# figure out what test files need to be run
|
19
|
-
test_files = {
|
20
|
-
'{test,spec}/**/*_{test,spec}.rb' => '%p',
|
21
|
-
'{lib,app}/**/*.rb' => '{test,spec}/**/%n_{test,spec}%x',
|
22
|
-
}.
|
23
|
-
map do |source_file_glob, test_file_pathmap|
|
24
|
-
Dir[source_file_glob].
|
25
|
-
select {|file| File.mtime(file) > last_ran_at }.
|
26
|
-
map {|path| Dir[path.pathmap(test_file_pathmap)] }
|
27
|
-
end.flatten.uniq
|
28
|
-
|
29
|
-
# fork worker process to run the test files
|
30
|
-
unless test_files.empty?
|
31
|
-
last_ran_at = Time.now
|
32
|
-
fork { test_files.each {|f| load f } }
|
33
|
-
Process.wait
|
34
|
-
end
|
35
|
-
|
36
|
-
# re-absorb test execution overhead as necessary
|
37
|
-
if Dir[overhead_file_glob].any? {|file| File.mtime(file) > started_at }
|
38
|
-
exec 'ruby', __FILE__, *ARGV
|
39
|
-
end
|
40
|
-
|
41
|
-
sleep 1
|
42
|
-
end
|