test-loop 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ (the ISC license)
2
+
3
+ Copyright 2010 Suraj N. Kurapati <sunaku@gmail.com>
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,64 @@
1
+ test-loop - Continuous testing for Ruby with fork/eval
2
+ ======================================================
3
+
4
+ test-loop is a fast continuous testing tool for Ruby that continuously detects
5
+ and tests changes in your Ruby application in an efficient manner, whereby it:
6
+
7
+ 1. Absorbs the test execution overhead into the main Ruby process.
8
+ 2. Forks to evaluate your test files directly and without overhead.
9
+
10
+ It relies on file modification times to determine what parts of your Ruby
11
+ application have changed and then uses Rake's String#pathmap function to
12
+ determine which test files in your test suite correspond to those changes.
13
+
14
+
15
+ Features
16
+ --------
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
+ * Tests CHANGES in your Ruby application; does NOT run all tests every time.
22
+ (You can force it to run all tests by pressing Control-\ in your terminal.)
23
+
24
+ * Reabsorbs test execution overhead if the test or spec helper file changes.
25
+ (You can force it to reabsorb by pressing Control-Z in your terminal.)
26
+
27
+ * Mostly I/O bound, so you can have it always running without CPU slowdowns.
28
+
29
+ * Implemented in less than 40 (SLOC) lines of code! :-)
30
+
31
+
32
+ Install
33
+ -------
34
+
35
+ As a Ruby gem:
36
+
37
+ gem install test-loop
38
+
39
+ As a Rails plugin:
40
+
41
+ rails plugin install git://github.com/sunaku/test-loop # Rails >= 3
42
+ script/plugin install git://github.com/sunaku/test-loop # older Rails
43
+
44
+
45
+ Usage
46
+ -----
47
+
48
+ test-loop # if installed as a Ruby gem
49
+
50
+ rake test:loop # if installed as a Rails plugin
51
+
52
+ * Press Control-Z to forcibly run all tests, even
53
+ if there are no changes in your Ruby application.
54
+
55
+ * Press Control-\ (backslash) to forcibly reabsorb the test
56
+ execution overhead, even if its sources have not changed.
57
+
58
+ * Press Control-C to quit the test loop.
59
+
60
+
61
+ License
62
+ -------
63
+
64
+ See the LICENSE file for details.
data/bin/test-loop ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ load File.expand_path('../../lib/test-loop.rb', __FILE__)
@@ -0,0 +1,8 @@
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 ADDED
@@ -0,0 +1,42 @@
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
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: test-loop
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Suraj N. Kurapati
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-10-10 00:00:00 -07:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description:
22
+ email:
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files: []
28
+
29
+ files:
30
+ - LICENSE
31
+ - README.md
32
+ - bin/test-loop
33
+ - lib/test-loop.rb
34
+ - lib/tasks/test-loop.rake
35
+ has_rdoc: true
36
+ homepage: http://github.com/sunaku/test-loop
37
+ licenses: []
38
+
39
+ post_install_message:
40
+ rdoc_options: []
41
+
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ segments:
50
+ - 0
51
+ version: "0"
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ requirements: []
61
+
62
+ rubyforge_project:
63
+ rubygems_version: 1.3.7
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: Continuous testing for Ruby with fork/eval
67
+ test_files: []
68
+