grosser-autotest 4.0.3 → 4.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +13 -8
- data/Rakefile +60 -0
- data/VERSION.yml +1 -1
- data/bin/autotest +2 -6
- data/bin/unit_diff +1 -1
- data/lib/autotest.rb +46 -36
- metadata +29 -28
data/README.markdown
CHANGED
@@ -11,21 +11,25 @@ Requirements
|
|
11
11
|
|
12
12
|
Install
|
13
13
|
=======
|
14
|
-
|
14
|
+
Uninstall ZenTest first, or autotest will not be found:
|
15
15
|
sudo gem uninstall ZenTest
|
16
|
-
|
16
|
+
Install:
|
17
17
|
sudo gem install grosser-autotest -s http://gems.github.com
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
To install an [AutoTest free ZenTest](http://github.com/grosser/zentest) version:
|
19
|
+
sudo gem install grosser-zentest -s http://gems.github.com
|
20
|
+
To install from source:
|
21
|
+
git clone git://github.com/grosser/autotest.git && cd autotest
|
21
22
|
rake install
|
22
23
|
|
23
24
|
Setup
|
24
25
|
=====
|
25
26
|
###Options
|
26
|
-
-f
|
27
|
-
-c
|
28
|
-
|
27
|
+
-f, --fast-start Do not run full tests at start
|
28
|
+
-c, --no-full-after-failed Do not run full tests after failed test passed
|
29
|
+
-v, --verbose Be verbose. Prints files that autotest doesn't know how to map to tests
|
30
|
+
-q, --quiet Be quiet.
|
31
|
+
-h, --help Show this.
|
32
|
+
|
29
33
|
|
30
34
|
|
31
35
|
TODO
|
@@ -35,6 +39,7 @@ TODO
|
|
35
39
|
- cleanup bin/autotest Dir hacks / passing of globals
|
36
40
|
- cleanup bin/unit_diff
|
37
41
|
- add gnome notification library
|
42
|
+
- add some automatic notifications e.g. autotest -n -> use any notify library found
|
38
43
|
|
39
44
|
|
40
45
|
License
|
data/Rakefile
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
$LOAD_PATH << 'lib'
|
3
|
+
|
4
|
+
#rake test
|
5
|
+
require 'rake/testtask'
|
6
|
+
Rake::TestTask.new(:test) {|test| test.libs << "test"}
|
7
|
+
task :default => :test
|
8
|
+
|
9
|
+
desc "run autotest on itself"
|
10
|
+
task :autotest do
|
11
|
+
ruby "-Ilib -w ./bin/autotest"
|
12
|
+
end
|
13
|
+
|
14
|
+
#TODO exclude /usr/ folder
|
15
|
+
#TODO improve coverage ? only 20% atm...
|
16
|
+
desc "show rcov report"
|
17
|
+
task :rcov_info do
|
18
|
+
ruby "-Ilib -S rcov --text-report --save coverage.info test/test_*.rb"
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "update example_dot_autotest.rb with all possible constants"
|
22
|
+
task :update do
|
23
|
+
system "p4 edit example_dot_autotest.rb"
|
24
|
+
File.open "example_dot_autotest.rb", "w" do |f|
|
25
|
+
f.puts "# -*- ruby -*-"
|
26
|
+
f.puts
|
27
|
+
Dir.chdir "lib" do
|
28
|
+
Dir["autotest/*.rb"].sort.each do |s|
|
29
|
+
next if s =~ /rails|discover/
|
30
|
+
f.puts "# require '#{s[0..-4]}'"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
f.puts
|
35
|
+
|
36
|
+
Dir["lib/autotest/*.rb"].sort.each do |file|
|
37
|
+
file = File.read(file)
|
38
|
+
m = file[/module.*/].split(/ /).last rescue nil
|
39
|
+
next unless m
|
40
|
+
|
41
|
+
file.grep(/def[^(]+=/).each do |setter|
|
42
|
+
setter = setter.sub(/^ *def self\./, '').sub(/\s*=\s*/, ' = ')
|
43
|
+
f.puts "# #{m}.#{setter}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
system "p4 diff -du example_dot_autotest.rb"
|
48
|
+
end
|
49
|
+
|
50
|
+
begin
|
51
|
+
require 'jeweler'
|
52
|
+
Jeweler::Tasks.new do |gem|
|
53
|
+
gem.name = "autotest"
|
54
|
+
gem.summary = "Autotest, without ZenTest"
|
55
|
+
gem.homepage = "http://github.com/grosser/autotest"
|
56
|
+
gem.authors = ["Ryan Davis"]
|
57
|
+
end
|
58
|
+
rescue LoadError
|
59
|
+
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
60
|
+
end
|
data/VERSION.yml
CHANGED
data/bin/autotest
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
1
2
|
require 'rubygems'
|
2
3
|
require 'optparse'
|
3
4
|
|
@@ -29,14 +30,9 @@ class Dir
|
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
32
|
-
#TODO pass options instead of globals
|
33
|
-
$v = options[:verbose]
|
34
|
-
$f = options[:no_full_after_start]
|
35
|
-
$c = options[:no_full_after_failed]
|
36
|
-
$q = options[:quiet]
|
37
|
-
|
38
33
|
#run the correct Autotest variant fitting to the local structure
|
39
34
|
require 'autotest'
|
35
|
+
Autotest.options.merge!(options)
|
40
36
|
target = Autotest
|
41
37
|
style = Autotest.autodiscover
|
42
38
|
unless style.empty? then
|
data/bin/unit_diff
CHANGED
data/lib/autotest.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'find'
|
2
2
|
require 'rbconfig'
|
3
3
|
|
4
|
-
$v ||= false
|
5
4
|
$TESTING = false unless defined? $TESTING
|
6
5
|
|
7
6
|
##
|
@@ -63,11 +62,13 @@ class Autotest
|
|
63
62
|
|
64
63
|
ALL_HOOKS = [ :all_good, :died, :green, :initialize, :interrupt, :quit,
|
65
64
|
:ran_command, :red, :reset, :run_command, :updated, :waiting ]
|
66
|
-
|
67
|
-
RERUN_ALL_AFTER_FAILED_PASS = !$c
|
68
65
|
|
66
|
+
@@options = {}
|
67
|
+
def self.options;@@options;end
|
68
|
+
def options;@@options;end
|
69
69
|
|
70
|
-
|
70
|
+
|
71
|
+
HOOKS = Hash.new { |h,k| h[k] = [] } #unfound keys are []
|
71
72
|
unless defined? WINDOZE then
|
72
73
|
WINDOZE = /win32/ =~ RUBY_PLATFORM
|
73
74
|
SEP = WINDOZE ? '&' : ';'
|
@@ -107,31 +108,24 @@ class Autotest
|
|
107
108
|
# "rails" if File.exist? 'config/environment.rb'
|
108
109
|
# end
|
109
110
|
#
|
110
|
-
|
111
111
|
def self.autodiscover
|
112
|
-
|
113
|
-
|
114
|
-
paths = $:.dup
|
112
|
+
#find all potential load paths
|
113
|
+
paths = $LOAD_PATH.dup
|
115
114
|
paths.push 'lib'
|
116
115
|
paths.push(*Dir["vendor/plugins/*/lib"])
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
paths.each do |d|
|
126
|
-
next unless File.directory? d
|
127
|
-
f = File.join(d, 'autotest', 'discover.rb')
|
128
|
-
if File.exist? f then
|
129
|
-
$: << d unless $:.include? d
|
130
|
-
load f
|
116
|
+
paths += rubygem_load_paths
|
117
|
+
|
118
|
+
#make paths available if they contain a discover.rb
|
119
|
+
paths.select{|p| File.directory?(p)}.each do |dir|
|
120
|
+
discover_rb = File.join(dir, 'autotest', 'discover.rb')
|
121
|
+
if File.exist? discover_rb then
|
122
|
+
$LOAD_PATH << dir unless $LOAD_PATH.include? dir
|
123
|
+
load discover_rb
|
131
124
|
end
|
132
125
|
end
|
133
126
|
|
134
|
-
|
127
|
+
#call all discover procs an determine style
|
128
|
+
@@discoveries.map{ |proc| proc.call }.flatten.compact.sort.uniq
|
135
129
|
end
|
136
130
|
|
137
131
|
##
|
@@ -185,15 +179,19 @@ class Autotest
|
|
185
179
|
self.find_directories = ['.']
|
186
180
|
self.unit_diff = "unit_diff -u"
|
187
181
|
|
182
|
+
#add Test::Unit mappings
|
183
|
+
#file in /lib -> run test in /test
|
188
184
|
self.add_mapping(/^lib\/.*\.rb$/) do |filename, _|
|
189
185
|
possible = File.basename(filename).gsub '_', '_?'
|
190
186
|
files_matching %r%^test/.*#{possible}$%
|
191
187
|
end
|
192
188
|
|
189
|
+
#file in /test -> run it
|
193
190
|
self.add_mapping(/^test.*\/test_.*rb$/) do |filename, _|
|
194
191
|
filename
|
195
192
|
end
|
196
193
|
|
194
|
+
#execute custom extensions
|
197
195
|
[File.expand_path('~/.autotest'), './.autotest'].each do |f|
|
198
196
|
load f if File.exist? f
|
199
197
|
end
|
@@ -208,12 +206,12 @@ class Autotest
|
|
208
206
|
reset
|
209
207
|
add_sigint_handler
|
210
208
|
|
211
|
-
self.last_mtime = Time.now if
|
209
|
+
self.last_mtime = Time.now if options[:no_full_after_start]
|
212
210
|
|
213
|
-
loop do
|
214
|
-
begin
|
211
|
+
loop do
|
212
|
+
begin # ^c handler
|
215
213
|
get_to_green
|
216
|
-
if self.tainted and
|
214
|
+
if self.tainted and not options[:no_full_after_failed] then
|
217
215
|
rerun_all_tests
|
218
216
|
else
|
219
217
|
hook :all_good
|
@@ -252,7 +250,7 @@ class Autotest
|
|
252
250
|
cmd = self.make_test_cmd self.files_to_test
|
253
251
|
return if cmd.empty?
|
254
252
|
|
255
|
-
puts cmd unless
|
253
|
+
puts cmd unless options[:quiet]
|
256
254
|
|
257
255
|
old_sync = $stdout.sync
|
258
256
|
$stdout.sync = true
|
@@ -379,16 +377,16 @@ class Autotest
|
|
379
377
|
|
380
378
|
##
|
381
379
|
# Find the files which have been modified, update the recorded
|
382
|
-
# timestamps, and use this to update the files to test. Returns
|
383
|
-
#
|
384
|
-
#
|
385
|
-
|
380
|
+
# timestamps, and use this to update the files to test. Returns
|
381
|
+
# the latest mtime of the files modified or nil when nothing was
|
382
|
+
# modified.
|
386
383
|
def find_files_to_test(files=find_files)
|
387
384
|
updated = files.select { |filename, mtime| self.last_mtime < mtime }
|
388
385
|
|
389
|
-
|
390
|
-
|
391
|
-
|
386
|
+
unless updated.empty? or self.last_mtime.to_i == 0 #nothing to update or initial run
|
387
|
+
p updated if options[:verbose]
|
388
|
+
hook :updated, updated
|
389
|
+
end
|
392
390
|
|
393
391
|
updated.map { |f,m| test_files_for(f) }.flatten.uniq.each do |filename|
|
394
392
|
self.files_to_test[filename] # creates key with default value
|
@@ -520,7 +518,7 @@ class Autotest
|
|
520
518
|
result = result.nil? ? [] : Array(result.last.call(filename, $~))
|
521
519
|
|
522
520
|
output.puts "No tests matched #{filename}" if
|
523
|
-
(
|
521
|
+
(options[:verbose] or $TESTING) and result.empty?
|
524
522
|
|
525
523
|
result.sort.uniq.select { |f| known_files[f] }
|
526
524
|
end
|
@@ -658,4 +656,16 @@ class Autotest
|
|
658
656
|
def self.add_hook(name, &block)
|
659
657
|
HOOKS[name] << block
|
660
658
|
end
|
659
|
+
|
660
|
+
private
|
661
|
+
|
662
|
+
#list of all available rubygem load paths
|
663
|
+
def self.rubygem_load_paths
|
664
|
+
begin
|
665
|
+
require 'rubygems'
|
666
|
+
Gem.latest_load_paths
|
667
|
+
rescue LoadError
|
668
|
+
[]
|
669
|
+
end
|
670
|
+
end
|
661
671
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grosser-autotest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-05-07 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -20,49 +20,48 @@ executables:
|
|
20
20
|
- unit_diff
|
21
21
|
extensions: []
|
22
22
|
|
23
|
-
extra_rdoc_files:
|
24
|
-
|
23
|
+
extra_rdoc_files:
|
24
|
+
- README.markdown
|
25
25
|
files:
|
26
|
-
- VERSION.yml
|
27
26
|
- History.txt
|
28
27
|
- README.markdown
|
28
|
+
- Rakefile
|
29
|
+
- VERSION.yml
|
29
30
|
- bin/autotest
|
30
31
|
- bin/unit_diff
|
31
32
|
- lib/autotest.rb
|
32
|
-
- lib/autotest
|
33
|
-
- lib/autotest/restart.rb
|
34
|
-
- lib/autotest/snarl.rb
|
35
|
-
- lib/autotest/jabber_notify.rb
|
36
|
-
- lib/autotest/fixtures.rb
|
37
|
-
- lib/autotest/menu.rb
|
38
|
-
- lib/autotest/kdenotify.rb
|
39
|
-
- lib/autotest/emacs.rb
|
33
|
+
- lib/autotest/autoupdate.rb
|
40
34
|
- lib/autotest/camping.rb
|
41
|
-
- lib/autotest/
|
35
|
+
- lib/autotest/cctray.rb
|
36
|
+
- lib/autotest/discover.rb
|
37
|
+
- lib/autotest/emacs.rb
|
42
38
|
- lib/autotest/email_notify.rb
|
39
|
+
- lib/autotest/fixtures.rb
|
40
|
+
- lib/autotest/growl.rb
|
43
41
|
- lib/autotest/heckle.rb
|
44
|
-
- lib/autotest/
|
45
|
-
- lib/autotest/
|
46
|
-
- lib/autotest/
|
47
|
-
- lib/autotest/
|
48
|
-
- lib/autotest/once.rb
|
42
|
+
- lib/autotest/html_report.rb
|
43
|
+
- lib/autotest/jabber_notify.rb
|
44
|
+
- lib/autotest/kdenotify.rb
|
45
|
+
- lib/autotest/menu.rb
|
49
46
|
- lib/autotest/migrate.rb
|
50
|
-
- lib/autotest/autoupdate.rb
|
51
|
-
- lib/autotest/rails.rb
|
52
|
-
- lib/autotest/timestamp.rb
|
53
|
-
- lib/autotest/growl.rb
|
54
47
|
- lib/autotest/notify.rb
|
48
|
+
- lib/autotest/once.rb
|
49
|
+
- lib/autotest/pretty.rb
|
50
|
+
- lib/autotest/rails.rb
|
51
|
+
- lib/autotest/rcov.rb
|
55
52
|
- lib/autotest/redgreen.rb
|
56
|
-
- lib/autotest/
|
53
|
+
- lib/autotest/restart.rb
|
54
|
+
- lib/autotest/shame.rb
|
55
|
+
- lib/autotest/snarl.rb
|
56
|
+
- lib/autotest/timestamp.rb
|
57
57
|
- lib/unit_diff.rb
|
58
|
-
- test/test_unit_diff.rb
|
59
58
|
- test/helper.rb
|
60
59
|
- test/test_autotest.rb
|
60
|
+
- test/test_unit_diff.rb
|
61
61
|
has_rdoc: true
|
62
62
|
homepage: http://github.com/grosser/autotest
|
63
63
|
post_install_message:
|
64
64
|
rdoc_options:
|
65
|
-
- --inline-source
|
66
65
|
- --charset=UTF-8
|
67
66
|
require_paths:
|
68
67
|
- lib
|
@@ -85,5 +84,7 @@ rubygems_version: 1.2.0
|
|
85
84
|
signing_key:
|
86
85
|
specification_version: 2
|
87
86
|
summary: Autotest, without ZenTest
|
88
|
-
test_files:
|
89
|
-
|
87
|
+
test_files:
|
88
|
+
- test/test_unit_diff.rb
|
89
|
+
- test/helper.rb
|
90
|
+
- test/test_autotest.rb
|