ZenTest 3.3.0 → 3.4.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/History.txt +46 -23
- data/Manifest.txt +9 -0
- data/README.txt +1 -0
- data/bin/multiruby +1 -1
- data/example_dot_autotest.rb +8 -146
- data/lib/autotest.rb +21 -17
- data/lib/autotest/growl.rb +35 -0
- data/lib/autotest/html_report.rb +31 -0
- data/lib/autotest/kdenotify.rb +14 -0
- data/lib/autotest/menu.rb +51 -0
- data/lib/autotest/pretty.rb +83 -0
- data/lib/autotest/redgreen.rb +13 -0
- data/lib/autotest/snarl.rb +51 -0
- data/lib/autotest/timestamp.rb +7 -0
- data/lib/rails_autotest.rb +3 -12
- data/lib/test/rails/functional_test_case.rb +6 -0
- data/lib/test/rails/rake_tasks.rb +2 -2
- data/lib/test/rails/render_tree.rb +89 -0
- data/lib/test/rails/test_case.rb +1 -2
- data/lib/test/rails/view_test_case.rb +5 -4
- data/lib/unit_diff.rb +2 -2
- data/lib/zentest.rb +8 -4
- data/test/test_autotest.rb +78 -33
- data/test/test_rails_autotest.rb +2 -0
- data/test/test_zentest.rb +2 -7
- metadata +11 -2
data/History.txt
CHANGED
@@ -1,8 +1,31 @@
|
|
1
|
+
*** 3.4.0 / 2006-09-12
|
2
|
+
|
3
|
+
+ 13 minor enhancements:
|
4
|
+
* Broke out example_dot_autotest into multiple files in lib.
|
5
|
+
* Enhanced hook system so it can return true if event handled.
|
6
|
+
* Sleep is now 1 second by default because life is too short.
|
7
|
+
* Hooked interrupt with new hook system. First handler wins.
|
8
|
+
* Hooked test results before output
|
9
|
+
* Accurate test counts for Test::Rails.
|
10
|
+
* Added snarl autotest plugin, thanks to Patrick Hurley.
|
11
|
+
* Added timestamp autotest plugin, thanks to Joe Goldberg.
|
12
|
+
* Added redgreen, thanks to Pat Eyler, Sean Carley, and Rob Sanheim.
|
13
|
+
* Added kdenotify autotest plugin, thanks to Geir Freysson.
|
14
|
+
* Added markaby support for Test::Rails.
|
15
|
+
* Added hack to display a tree of render calls.
|
16
|
+
* Added hook to perform extra setup for
|
17
|
+
+ 5 bug fixes:
|
18
|
+
- Extended zentest to deal with rails a bit better... ugh.
|
19
|
+
- Fixed @libs for windoze.
|
20
|
+
- Fixed inner class/test identification in autotest.
|
21
|
+
- Namespaced all plugins... eric is anal.
|
22
|
+
- No longer freak out if rubygems tarball not in multiruby/versions.
|
23
|
+
|
1
24
|
*** 3.3.0 / 2006-07-28
|
2
25
|
|
3
26
|
+ 1 major enhancement:
|
4
27
|
+ autotest has been rewritten to be much cleaner, now has a plugin system.
|
5
|
-
+ 5 minor
|
28
|
+
+ 5 minor enhancements:
|
6
29
|
+ test/rails adds helper tests, "stolen" from Geoff's work, (which was "stolen" from ryan's work. :P)
|
7
30
|
+ autotest turnaround is now faster.
|
8
31
|
+ Added more prune dirs to autotest.
|
@@ -33,10 +56,10 @@
|
|
33
56
|
|
34
57
|
*** 3.1.0 / 2006-03-29
|
35
58
|
|
36
|
-
+ 2 major enhancements
|
59
|
+
+ 2 major enhancements:
|
37
60
|
+ Added multiruby! YAY!
|
38
61
|
+ Massive improvements to autotest: speed, reliability, reporting, etc.
|
39
|
-
+ 10 minor enhancements
|
62
|
+
+ 10 minor enhancements:
|
40
63
|
+ multiruby builds in a centralized location. YAY!
|
41
64
|
+ multiruby now allows reinstalls quickly and easily (can even skip config).
|
42
65
|
+ multiruby exits with total sum of exit codes.
|
@@ -47,7 +70,7 @@
|
|
47
70
|
+ autotest always runs with unit_diff -u.
|
48
71
|
+ autotest can now run cvs/svn/p4 up periodically to be a mini-tinderbox.
|
49
72
|
+ autotest now has real help.
|
50
|
-
+ 4 bug fixes
|
73
|
+
+ 4 bug fixes:
|
51
74
|
+ ZenTest is now zentest. Yay for consistency! (do a rake uninstall to clean)
|
52
75
|
+ ZenTest excludes pretty_print methods.
|
53
76
|
+ Fixed unary operator issues (they were backwards... oops!) for ZenTest.
|
@@ -55,25 +78,25 @@
|
|
55
78
|
|
56
79
|
*** 3.0.0 / 2006-03-06
|
57
80
|
|
58
|
-
+ 2 major enhancements
|
81
|
+
+ 2 major enhancements:
|
59
82
|
+ Added autotest and rails_autotest. YAY for continous testing!
|
60
83
|
+ Repackaged and gemified. YAY for gemification!
|
61
|
-
+ 3 minor enhancements
|
84
|
+
+ 3 minor enhancements:
|
62
85
|
+ Added non-mappable tests starting with test_integration_.
|
63
86
|
+ Lots of code and test refactoring and cleanup.
|
64
87
|
+ Massive improvement on unit tests.
|
65
|
-
+ 3 bug fixes
|
88
|
+
+ 3 bug fixes:
|
66
89
|
+ Cleaned up class method inheritence. Esp relevant for rails testing.
|
67
90
|
+ Finally fixed the unit_diff parse bug!
|
68
91
|
+ Fixed improper counting of errors if a class was missing, should be 1 + missing methods.
|
69
92
|
|
70
93
|
*** 2.4.0 / 2005-03-21
|
71
94
|
|
72
|
-
+ 3 minor enhancements
|
95
|
+
+ 3 minor enhancements:
|
73
96
|
+ Able to audit standard class library (so now we can audit rubicon!).
|
74
97
|
+ Able to map against class methods (self.blah <=> test_class_blah).
|
75
98
|
+ Added -I=rubypath support
|
76
|
-
+ 4 bug fixes
|
99
|
+
+ 4 bug fixes:
|
77
100
|
+ bug:1151 Fixed stupid problem w/ unit_diff.
|
78
101
|
+ bug:1454 code generation correctly matches class/module for nested classes.
|
79
102
|
+ bug:1455 Updated method mapping to work on all operators listed in my quickref.
|
@@ -81,14 +104,14 @@
|
|
81
104
|
|
82
105
|
*** 2.3.0 / 2004-11-18
|
83
106
|
|
84
|
-
+ 6 minor enhancements
|
107
|
+
+ 6 minor enhancements:
|
85
108
|
+ Massively expanded the method name mappings.
|
86
109
|
+ Added -r flag to reverse map names, for Rails style testing.
|
87
110
|
+ Added -e to auto eval tests generated.
|
88
111
|
+ Added -b & -c flags in unit_diff (passed to diff)
|
89
112
|
+ Added install and uninstall rules to Makefile.
|
90
113
|
+ Added some more doco to README.txt
|
91
|
-
+ 7 bug fixes
|
114
|
+
+ 7 bug fixes:
|
92
115
|
+ Cleaned up and refactored tests.
|
93
116
|
+ Changed the way files are generated, to accomodate new flags.
|
94
117
|
+ Added some more tests.
|
@@ -99,19 +122,19 @@
|
|
99
122
|
|
100
123
|
*** 2.2.0 / 2004-10-18
|
101
124
|
|
102
|
-
+ 4 minor enhancements
|
125
|
+
+ 4 minor enhancements:
|
103
126
|
+ Added LinuxJournalArticle.txt! WOOT!
|
104
127
|
+ Added unit_diff.rb - a very cool filter for test output!
|
105
128
|
+ Extended ZenTest to work with standard input
|
106
129
|
+ Added "ZenTest FULL" to force ZenTest to analyze inherited methods, for subclasses of the standard library.
|
107
|
-
+ 3 bug fixes
|
130
|
+
+ 3 bug fixes:
|
108
131
|
+ Extended makefile to be more dynamic and stop diffing versions. ugh.
|
109
132
|
+ Expanded the method rename map to handle <<, *, +, and ==.
|
110
133
|
+ Added more test cases.
|
111
134
|
|
112
135
|
*** 2.1.2 / 2004-03-08
|
113
136
|
|
114
|
-
+
|
137
|
+
+ 4 bug fixes:
|
115
138
|
+ Fixed yet another 1.8ism, results will be the same in 1.8 and 1.6.
|
116
139
|
+ Fixed code responsible for method name conversion.
|
117
140
|
+ I am a moron... didn't run tests after updating version.
|
@@ -119,41 +142,41 @@
|
|
119
142
|
|
120
143
|
*** 2.1.1 / 2004-03-06
|
121
144
|
|
122
|
-
+ 3 bug fixes
|
145
|
+
+ 3 bug fixes:
|
123
146
|
+ Fixed a 1.8ism.
|
124
147
|
+ Removed zentestrunner. Older ruby users will just have to suffer.
|
125
148
|
+ Updated history to ZenWeb format.
|
126
149
|
|
127
150
|
*** 2.1.0 / 2003-01-07
|
128
151
|
|
129
|
-
+ 3 major enhancements
|
152
|
+
+ 3 major enhancements:
|
130
153
|
+ Output is runnable as-is thanks to zentestrunner.rb.
|
131
154
|
+ Wrapped up all running functionality into ZenTest.fix
|
132
155
|
+ Added simple statistic output... Thanks Dave & Andy!!!
|
133
|
-
+
|
156
|
+
+ 2 minor enhancements:
|
134
157
|
+ Added zentestrunner.rb until Nathaniel accepts my changes!
|
135
|
-
+ 3 bug fixes
|
136
|
-
+ Removed at_exit override and avoided test/unit altogether.
|
137
158
|
+ Added a clean rule to Makefile
|
159
|
+
+ 3 bug fixes:
|
160
|
+
+ Removed at_exit override and avoided test/unit altogether.
|
138
161
|
+ Extended README.txt to include some of the rules.
|
139
162
|
+ Fixed several tests and added assertions for new stats
|
140
163
|
|
141
164
|
*** 2.0.0 / 2002-10-29
|
142
165
|
|
143
|
-
+ 2 major enhancements
|
166
|
+
+ 2 major enhancements:
|
144
167
|
+ Rewrite of ZenTest.rb into actual OO design.
|
145
168
|
+ Added unit tests, finally...
|
146
169
|
|
147
170
|
*** 1.0.1 / 2002-09-28
|
148
171
|
|
149
|
-
+ 1 minor
|
172
|
+
+ 1 minor enhancement:
|
150
173
|
+ Only loads when a class is detected, allows some scripts to be skipped.
|
151
|
-
+ 3 bug fixes
|
174
|
+
+ 3 bug fixes:
|
152
175
|
+ Cleaned up output. Verbose when $DEBUG is true.
|
153
176
|
+ Added an error count that is output at end.
|
154
177
|
+ Better filtering or conversion on some method names.
|
155
178
|
|
156
179
|
*** 1.0.0 / 2002-09-24
|
157
180
|
|
158
|
-
+ 1 major
|
181
|
+
+ 1 major enhancement:
|
159
182
|
+ Birthday!
|
data/Manifest.txt
CHANGED
@@ -15,6 +15,14 @@ example1.rb
|
|
15
15
|
example2.rb
|
16
16
|
example_dot_autotest.rb
|
17
17
|
lib/autotest.rb
|
18
|
+
lib/autotest/growl.rb
|
19
|
+
lib/autotest/html_report.rb
|
20
|
+
lib/autotest/kdenotify.rb
|
21
|
+
lib/autotest/menu.rb
|
22
|
+
lib/autotest/pretty.rb
|
23
|
+
lib/autotest/redgreen.rb
|
24
|
+
lib/autotest/snarl.rb
|
25
|
+
lib/autotest/timestamp.rb
|
18
26
|
lib/rails_autotest.rb
|
19
27
|
lib/ruby_fork.rb
|
20
28
|
lib/test/rails.rb
|
@@ -24,6 +32,7 @@ lib/test/rails/helper_test_case.rb
|
|
24
32
|
lib/test/rails/ivar_proxy.rb
|
25
33
|
lib/test/rails/pp_html_document.rb
|
26
34
|
lib/test/rails/rake_tasks.rb
|
35
|
+
lib/test/rails/render_tree.rb
|
27
36
|
lib/test/rails/test_case.rb
|
28
37
|
lib/test/rails/view_test_case.rb
|
29
38
|
lib/test/zentest_assertions.rb
|
data/README.txt
CHANGED
data/bin/multiruby
CHANGED
@@ -38,7 +38,7 @@ Dir.chdir root_dir do
|
|
38
38
|
|
39
39
|
tarballs = Dir["versions/rubygems*.tgz"]
|
40
40
|
raise "You should delete all but one rubygem tarball" if tarballs.size > 1
|
41
|
-
rubygem_tarball = File.expand_path tarballs.last
|
41
|
+
rubygem_tarball = File.expand_path tarballs.last rescue nil
|
42
42
|
|
43
43
|
Dir.chdir "build" do
|
44
44
|
Dir["../versions/ruby*.tar.gz"].each do |tarball|
|
data/example_dot_autotest.rb
CHANGED
@@ -1,148 +1,10 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
Autotest.add_hook :red do |at|
|
13
|
-
growl "Tests Failed", "#{at.files_to_test.size} tests failed", 2
|
14
|
-
end
|
15
|
-
|
16
|
-
Autotest.add_hook :green do |at|
|
17
|
-
growl "Tests Passed", "All tests passed", -2 if at.tainted
|
18
|
-
end
|
19
|
-
|
20
|
-
Autotest.add_hook :init do |at|
|
21
|
-
growl "autotest", "autotest was started" unless $TESTING
|
22
|
-
end
|
23
|
-
|
24
|
-
Autotest.add_hook :interrupt do |at|
|
25
|
-
growl "autotest", "autotest was reset" unless $TESTING
|
26
|
-
end
|
27
|
-
|
28
|
-
Autotest.add_hook :quit do |at|
|
29
|
-
growl "autotest", "autotest is exiting" unless $TESTING
|
30
|
-
end
|
31
|
-
|
32
|
-
Autotest.add_hook :all do |at|_hook
|
33
|
-
growl "autotest", "Tests have fully passed", -2 unless $TESTING
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
module HtmlConsole
|
38
|
-
MAX = 30
|
39
|
-
STATUS = {}
|
40
|
-
PATH = File.expand_path("~/Sites/autotest.html")
|
41
|
-
|
42
|
-
def self.update
|
43
|
-
STATUS.delete STATUS.keys.sort.last if STATUS.size > MAX
|
44
|
-
File.open(PATH, "w") do |f|
|
45
|
-
f.puts "<title>Autotest Status</title>"
|
46
|
-
STATUS.sort.reverse.each do |t,s|
|
47
|
-
if s > 0 then
|
48
|
-
f.puts "<p style=\"color:red\">#{t}: #{s}"
|
49
|
-
else
|
50
|
-
f.puts "<p style=\"color:green\">#{t}: #{s}"
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
Autotest.add_hook :red do |at|
|
57
|
-
STATUS[Time.now] = at.files_to_test.size
|
58
|
-
update
|
59
|
-
end
|
60
|
-
|
61
|
-
Autotest.add_hook :green do |at|
|
62
|
-
STATUS[Time.now] = 0
|
63
|
-
update
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
require 'osx/cocoa'
|
68
|
-
include Math
|
69
|
-
include OSX
|
70
|
-
|
71
|
-
OSX::NSBundle.bundleWithPath(File.expand_path("~/Library/Frameworks/Aquaterm.framework")).load
|
72
|
-
OSX.ns_import :AQTAdapter
|
73
|
-
|
74
|
-
class StatusBoard
|
75
|
-
BLACK = 0
|
76
|
-
WHITE = 1
|
77
|
-
RED = 2
|
78
|
-
GREEN = 3
|
79
|
-
GRAY = 4
|
80
|
-
|
81
|
-
def initialize
|
82
|
-
@past = []
|
83
|
-
|
84
|
-
@adapter = AQTAdapter.alloc.init
|
85
|
-
@adapter.openPlotWithIndex 1
|
86
|
-
@adapter.setPlotSize([122,122])
|
87
|
-
@adapter.setPlotTitle("Autotest Status")
|
88
|
-
|
89
|
-
@adapter.setColormapEntry_red_green_blue(0, 0.0, 0.0, 0.0) # black
|
90
|
-
@adapter.setColormapEntry_red_green_blue(1, 1.0, 1.0, 1.0) # white
|
91
|
-
@adapter.setColormapEntry_red_green_blue(2, 1.0, 0.0, 0.0) # red
|
92
|
-
@adapter.setColormapEntry_red_green_blue(3, 0.0, 1.0, 0.0) # green
|
93
|
-
@adapter.setColormapEntry_red_green_blue(4, 0.7, 0.7, 0.7) # gray
|
94
|
-
|
95
|
-
draw
|
96
|
-
end
|
97
|
-
|
98
|
-
def draw
|
99
|
-
# @past = @past[10..-1] if @past.size >= 100
|
100
|
-
@past.shift if @past.size > 100
|
101
|
-
|
102
|
-
@adapter.takeColorFromColormapEntry(@past.last ? GREEN : RED)
|
103
|
-
@adapter.addFilledRect([0, 0, 122, 122])
|
104
|
-
|
105
|
-
@adapter.takeColorFromColormapEntry(BLACK)
|
106
|
-
@adapter.addFilledRect([10, 10, 102, 102])
|
107
|
-
|
108
|
-
@adapter.takeColorFromColormapEntry(GRAY)
|
109
|
-
@adapter.addFilledRect([11, 11, 100, 100])
|
110
|
-
|
111
|
-
@adapter.takeColorFromColormapEntry(0)
|
112
|
-
|
113
|
-
@past.each_with_index do |passed,i|
|
114
|
-
x = i % 10
|
115
|
-
y = i / 10
|
116
|
-
|
117
|
-
@adapter.takeColorFromColormapEntry(passed ? GREEN : RED)
|
118
|
-
@adapter.addFilledRect([x*10+11, y*10+11, 10, 10])
|
119
|
-
end
|
120
|
-
@adapter.renderPlot
|
121
|
-
end
|
122
|
-
|
123
|
-
def pass
|
124
|
-
@past.push true
|
125
|
-
draw
|
126
|
-
end
|
127
|
-
|
128
|
-
def fail
|
129
|
-
@past.push false
|
130
|
-
draw
|
131
|
-
end
|
132
|
-
|
133
|
-
def close
|
134
|
-
@adapter.closePlot
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
unless $TESTING then
|
139
|
-
board = StatusBoard.new
|
140
|
-
|
141
|
-
Autotest.add_hook :red do |at|
|
142
|
-
board.fail unless $TESTING
|
143
|
-
end
|
144
|
-
|
145
|
-
Autotest.add_hook :green do |at|
|
146
|
-
board.pass unless $TESTING
|
147
|
-
end
|
148
|
-
end
|
3
|
+
# require 'autotest/growl'
|
4
|
+
# require 'autotest/html_report'
|
5
|
+
# require 'autotest/kdenotify'
|
6
|
+
# require 'autotest/menu'
|
7
|
+
# require 'autotest/pretty'
|
8
|
+
# require 'autotest/redgreen'
|
9
|
+
# require 'autotest/snarl'
|
10
|
+
# require 'autotest/timestamp'
|
data/lib/autotest.rb
CHANGED
@@ -62,15 +62,16 @@ class Autotest
|
|
62
62
|
new.run
|
63
63
|
end
|
64
64
|
|
65
|
-
attr_accessor :exceptions, :files, :files_to_test, :interrupted, :last_mtime, :libs, :output, :tainted
|
65
|
+
attr_accessor :exceptions, :files, :files_to_test, :interrupted, :last_mtime, :libs, :output, :results, :tainted, :wants_to_quit
|
66
66
|
|
67
67
|
def initialize
|
68
68
|
@files = Hash.new Time.at(0)
|
69
69
|
@files_to_test = Hash.new { |h,k| h[k] = [] }
|
70
70
|
@exceptions = false
|
71
|
-
@libs =
|
71
|
+
@libs = %w[. lib test].join(File::PATH_SEPARATOR)
|
72
72
|
@output = $stderr
|
73
|
-
@sleep =
|
73
|
+
@sleep = 1
|
74
|
+
hook :initialize
|
74
75
|
end
|
75
76
|
|
76
77
|
def run
|
@@ -88,7 +89,6 @@ class Autotest
|
|
88
89
|
break
|
89
90
|
else
|
90
91
|
reset
|
91
|
-
hook :interrupt
|
92
92
|
end
|
93
93
|
end
|
94
94
|
end
|
@@ -123,9 +123,11 @@ class Autotest
|
|
123
123
|
if @interrupted then
|
124
124
|
@wants_to_quit = true
|
125
125
|
else
|
126
|
-
|
127
|
-
|
128
|
-
|
126
|
+
unless hook :interrupt then
|
127
|
+
puts "Interrupt a second time to quit"
|
128
|
+
@interrupted = true
|
129
|
+
sleep 1.5
|
130
|
+
end
|
129
131
|
raise Interrupt # let the run loop catch it
|
130
132
|
end
|
131
133
|
end
|
@@ -139,6 +141,7 @@ class Autotest
|
|
139
141
|
filters = Hash.new { |h,k| h[k] = [] }
|
140
142
|
|
141
143
|
failed.each do |method, klass|
|
144
|
+
klass = klass.split(/::/).last
|
142
145
|
failed_file_name = klass.gsub(/(.)([A-Z])/, '\1_?\2')
|
143
146
|
failed_files = @files.keys.grep(/#{failed_file_name}/i)
|
144
147
|
case failed_files.size
|
@@ -167,23 +170,25 @@ class Autotest
|
|
167
170
|
|
168
171
|
filename = f.sub(/^\.\//, '')
|
169
172
|
|
170
|
-
result[filename] = File.stat(filename).mtime
|
173
|
+
result[filename] = File.stat(filename).mtime rescue next
|
171
174
|
end
|
172
175
|
return result
|
173
176
|
end
|
174
177
|
|
175
178
|
def find_files_to_test(files=find_files)
|
176
|
-
updated =
|
179
|
+
updated = files.select { |filename, mtime|
|
180
|
+
@files[filename] < mtime
|
181
|
+
}
|
177
182
|
|
178
183
|
# TODO: keep an mtime at app level and drop the files hash
|
179
|
-
|
180
|
-
|
184
|
+
updated.each do |filename, mtime|
|
185
|
+
@files[filename] = mtime
|
186
|
+
end
|
181
187
|
|
188
|
+
updated.each do |filename, mtime|
|
182
189
|
tests_for_file(filename).each do |f|
|
183
190
|
@files_to_test[f] # creates key with default value
|
184
191
|
end
|
185
|
-
|
186
|
-
@files[filename] = mtime
|
187
192
|
end
|
188
193
|
|
189
194
|
previous = @last_mtime
|
@@ -261,6 +266,7 @@ class Autotest
|
|
261
266
|
end
|
262
267
|
|
263
268
|
def wait_for_changes
|
269
|
+
hook :waiting
|
264
270
|
begin
|
265
271
|
sleep @sleep
|
266
272
|
end until find_files_to_test
|
@@ -270,8 +276,8 @@ class Autotest
|
|
270
276
|
# Hooks:
|
271
277
|
|
272
278
|
def hook(name)
|
273
|
-
HOOKS[name].
|
274
|
-
plugin[self]
|
279
|
+
HOOKS[name].inject(false) do |handled,plugin|
|
280
|
+
plugin[self] || handled
|
275
281
|
end
|
276
282
|
end
|
277
283
|
|
@@ -284,6 +290,4 @@ if test ?f, './.autotest' then
|
|
284
290
|
load './.autotest'
|
285
291
|
elsif test ?f, File.expand_path('~/.autotest') then
|
286
292
|
load File.expand_path('~/.autotest')
|
287
|
-
else
|
288
|
-
puts "couldn't find ./.autotest in #{Dir.pwd}"
|
289
293
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- mode -*-
|
2
|
+
|
3
|
+
module Autotest::Growl
|
4
|
+
def self.growl title, msg, pri=0
|
5
|
+
system "growlnotify -n autotest --image /Applications/Mail.app/Contents/Resources/Caution.tiff -p #{pri} -m #{msg.inspect} #{title}"
|
6
|
+
end
|
7
|
+
|
8
|
+
Autotest.add_hook :run do |at|
|
9
|
+
growl "Run", "Run" unless $TESTING
|
10
|
+
end
|
11
|
+
|
12
|
+
Autotest.add_hook :red do |at|
|
13
|
+
growl "Tests Failed", "#{at.files_to_test.size} tests failed", 2
|
14
|
+
end
|
15
|
+
|
16
|
+
Autotest.add_hook :green do |at|
|
17
|
+
growl "Tests Passed", "All tests passed", -2 if at.tainted
|
18
|
+
end
|
19
|
+
|
20
|
+
Autotest.add_hook :init do |at|
|
21
|
+
growl "autotest", "autotest was started" unless $TESTING
|
22
|
+
end
|
23
|
+
|
24
|
+
Autotest.add_hook :interrupt do |at|
|
25
|
+
growl "autotest", "autotest was reset" unless $TESTING
|
26
|
+
end
|
27
|
+
|
28
|
+
Autotest.add_hook :quit do |at|
|
29
|
+
growl "autotest", "autotest is exiting" unless $TESTING
|
30
|
+
end
|
31
|
+
|
32
|
+
Autotest.add_hook :all do |at|_hook
|
33
|
+
growl "autotest", "Tests have fully passed", -2 unless $TESTING
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- mode -*-
|
2
|
+
|
3
|
+
module Autotest::HtmlConsole
|
4
|
+
MAX = 30
|
5
|
+
STATUS = {}
|
6
|
+
PATH = File.expand_path("~/Sites/autotest.html")
|
7
|
+
|
8
|
+
def self.update
|
9
|
+
STATUS.delete STATUS.keys.sort.last if STATUS.size > MAX
|
10
|
+
File.open(PATH, "w") do |f|
|
11
|
+
f.puts "<title>Autotest Status</title>"
|
12
|
+
STATUS.sort.reverse.each do |t,s|
|
13
|
+
if s > 0 then
|
14
|
+
f.puts "<p style=\"color:red\">#{t}: #{s}"
|
15
|
+
else
|
16
|
+
f.puts "<p style=\"color:green\">#{t}: #{s}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
Autotest.add_hook :red do |at|
|
23
|
+
STATUS[Time.now] = at.files_to_test.size
|
24
|
+
update
|
25
|
+
end
|
26
|
+
|
27
|
+
Autotest.add_hook :green do |at|
|
28
|
+
STATUS[Time.now] = 0
|
29
|
+
update
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
# stolen (with permission) from http://www.snailbyte.com/2006/08/24/rails-autotest-growl-notification-using-dcop-and-knotify
|
4
|
+
|
5
|
+
module Autotest::KDENotify
|
6
|
+
def self.knotify title, msg
|
7
|
+
system "dcop knotify default notify " +
|
8
|
+
"eventname \'#{title}\' \'#{msg}\' '' '' 16 2"
|
9
|
+
end
|
10
|
+
|
11
|
+
Autotest.add_hook :red do |at|
|
12
|
+
knotify "Tests failed", "#{at.files_to_test.size} tests failed"
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/usr/local/bin/ruby -w
|
2
|
+
|
3
|
+
module Autotest::Menu
|
4
|
+
WINDOZE = /win32/ =~ RUBY_PLATFORM unless defined? WINDOZE
|
5
|
+
|
6
|
+
if WINDOZE then
|
7
|
+
require "Win32API"
|
8
|
+
def self.getchar
|
9
|
+
Win32API.new("crtdll", "_getch", [], "L").Call
|
10
|
+
end
|
11
|
+
else
|
12
|
+
STTY_SAVE_STATE=`stty -g`
|
13
|
+
def self.getchar
|
14
|
+
system 'stty raw echo'
|
15
|
+
STDIN.getc
|
16
|
+
ensure
|
17
|
+
system "stty '#{STTY_SAVE_STATE}'"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.menu(choices)
|
22
|
+
result = nil
|
23
|
+
choices.sort.each do |c, desc|
|
24
|
+
puts "#{c.chr}: #{desc}"
|
25
|
+
end
|
26
|
+
until choices[result]
|
27
|
+
print "menu> "
|
28
|
+
result = getchar
|
29
|
+
print " invalid input" unless choices[result]
|
30
|
+
puts
|
31
|
+
end
|
32
|
+
result
|
33
|
+
end
|
34
|
+
|
35
|
+
Autotest.add_hook(:interrupt) do |at|
|
36
|
+
$stderr.puts "menu"
|
37
|
+
case menu ?q => "quit", ?c => "continue", ?r => "restart"
|
38
|
+
when ?c
|
39
|
+
true
|
40
|
+
when ?r
|
41
|
+
at.reset
|
42
|
+
true
|
43
|
+
when ?q
|
44
|
+
at.wants_to_quit = true
|
45
|
+
true
|
46
|
+
else
|
47
|
+
false
|
48
|
+
end
|
49
|
+
# puts "you chose #{c.chr}"
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'osx/cocoa'
|
4
|
+
include Math
|
5
|
+
include OSX
|
6
|
+
|
7
|
+
OSX::NSBundle.bundleWithPath(File.expand_path("~/Library/Frameworks/Aquaterm.framework")).load
|
8
|
+
OSX.ns_import :AQTAdapter
|
9
|
+
|
10
|
+
class Autotest::Pretty
|
11
|
+
BLACK = 0
|
12
|
+
WHITE = 1
|
13
|
+
RED = 2
|
14
|
+
GREEN = 3
|
15
|
+
GRAY = 4
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
@past = []
|
19
|
+
|
20
|
+
@adapter = AQTAdapter.alloc.init
|
21
|
+
@adapter.openPlotWithIndex 1
|
22
|
+
@adapter.setPlotSize([122,122])
|
23
|
+
@adapter.setPlotTitle("Autotest Status")
|
24
|
+
|
25
|
+
@adapter.setColormapEntry_red_green_blue(0, 0.0, 0.0, 0.0) # black
|
26
|
+
@adapter.setColormapEntry_red_green_blue(1, 1.0, 1.0, 1.0) # white
|
27
|
+
@adapter.setColormapEntry_red_green_blue(2, 1.0, 0.0, 0.0) # red
|
28
|
+
@adapter.setColormapEntry_red_green_blue(3, 0.0, 1.0, 0.0) # green
|
29
|
+
@adapter.setColormapEntry_red_green_blue(4, 0.7, 0.7, 0.7) # gray
|
30
|
+
|
31
|
+
draw
|
32
|
+
end
|
33
|
+
|
34
|
+
def draw
|
35
|
+
@past.shift if @past.size > 100
|
36
|
+
|
37
|
+
@adapter.takeColorFromColormapEntry(@past.last ? GREEN : RED)
|
38
|
+
@adapter.addFilledRect([0, 0, 122, 122])
|
39
|
+
|
40
|
+
@adapter.takeColorFromColormapEntry(BLACK)
|
41
|
+
@adapter.addFilledRect([10, 10, 102, 102])
|
42
|
+
|
43
|
+
@adapter.takeColorFromColormapEntry(GRAY)
|
44
|
+
@adapter.addFilledRect([11, 11, 100, 100])
|
45
|
+
|
46
|
+
@adapter.takeColorFromColormapEntry(0)
|
47
|
+
|
48
|
+
@past.each_with_index do |passed,i|
|
49
|
+
x = i % 10
|
50
|
+
y = i / 10
|
51
|
+
|
52
|
+
@adapter.takeColorFromColormapEntry(passed ? GREEN : RED)
|
53
|
+
@adapter.addFilledRect([x*10+11, y*10+11, 10, 10])
|
54
|
+
end
|
55
|
+
@adapter.renderPlot
|
56
|
+
end
|
57
|
+
|
58
|
+
def pass
|
59
|
+
@past.push true
|
60
|
+
draw
|
61
|
+
end
|
62
|
+
|
63
|
+
def fail
|
64
|
+
@past.push false
|
65
|
+
draw
|
66
|
+
end
|
67
|
+
|
68
|
+
def close
|
69
|
+
@adapter.closePlot
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
unless $TESTING then
|
74
|
+
board = Autotest::Pretty.new
|
75
|
+
|
76
|
+
Autotest.add_hook :red do |at|
|
77
|
+
board.fail unless $TESTING
|
78
|
+
end
|
79
|
+
|
80
|
+
Autotest.add_hook :green do |at|
|
81
|
+
board.pass unless $TESTING
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
# special thanks to Pat Eyler, Sean Carley, and Rob Sanheim
|
4
|
+
module Autotest::RedGreen
|
5
|
+
BAR = "=" * 80
|
6
|
+
|
7
|
+
Autotest.add_hook :ran_command do |at|
|
8
|
+
at.results.gsub!(/^.* (\d+) failures, (\d+) errors$/) { |match|
|
9
|
+
code = ($1 != "0" or $2 != "0") ? 31 : 32
|
10
|
+
"\e[#{code}m#{BAR}\n#{match}\e[0m\n\n"
|
11
|
+
}
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# special thanks to: Patrick Hurley <phurley@gmail.com>
|
2
|
+
# requires the ruby-snarl gem.
|
3
|
+
|
4
|
+
begin require 'rubygems'; rescue LoadError; end
|
5
|
+
require 'snarl'
|
6
|
+
|
7
|
+
module Autotest::Snarl
|
8
|
+
def self.icon
|
9
|
+
# icons from http://www.famfamfam.com/lab/icons/silk/
|
10
|
+
path = File.join(File.dirname(__FILE__), "/../icons")
|
11
|
+
{
|
12
|
+
:green => "#{path}/accept.png",
|
13
|
+
:red => "#{path}/exclamation.png",
|
14
|
+
:info => "#{path}/information.png"
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.snarl title, msg, ico = nil
|
19
|
+
Snarl.show_message(title, msg, icon[ico])
|
20
|
+
end
|
21
|
+
|
22
|
+
Autotest.add_hook :run do |at|
|
23
|
+
snarl "Run", "Run" unless $TESTING
|
24
|
+
end
|
25
|
+
|
26
|
+
Autotest.add_hook :red do |at|
|
27
|
+
failed_tests = at.files_to_test.inject(0){ |s,a| k,v = a; s + v.size}
|
28
|
+
snarl "Tests Failed", "#{failed_tests} tests failed", :red
|
29
|
+
end
|
30
|
+
|
31
|
+
Autotest.add_hook :green do |at|
|
32
|
+
snarl "Tests Passed", "All tests passed", :green #if at.tainted
|
33
|
+
end
|
34
|
+
|
35
|
+
Autotest.add_hook :run do |at|
|
36
|
+
snarl "autotest", "autotest was started", :info unless $TESTING
|
37
|
+
end
|
38
|
+
|
39
|
+
Autotest.add_hook :interrupt do |at|
|
40
|
+
snarl "autotest", "autotest was reset", :info unless $TESTING
|
41
|
+
end
|
42
|
+
|
43
|
+
Autotest.add_hook :quit do |at|
|
44
|
+
snarl "autotest", "autotest is exiting", :info unless $TESTING
|
45
|
+
end
|
46
|
+
|
47
|
+
Autotest.add_hook :all do |at|_hook
|
48
|
+
snarl "autotest", "Tests have fully passed", :green unless $TESTING
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
data/lib/rails_autotest.rb
CHANGED
@@ -15,13 +15,7 @@ class RailsAutotest < Autotest
|
|
15
15
|
"test/controllers/#{$1}_controller_test.rb",
|
16
16
|
"test/views/#{$1}_view_test.rb",
|
17
17
|
"test/functional/#{$1}_controller_test.rb"]
|
18
|
-
when %r%^test/unit/.*rb$% then
|
19
|
-
[filename]
|
20
|
-
when %r%^test/controllers/.*\.rb$% then
|
21
|
-
[filename]
|
22
|
-
when %r%^test/views/.*\.rb$% then
|
23
|
-
[filename]
|
24
|
-
when %r%^test/functional/.*\.rb$% then
|
18
|
+
when %r%^test/(unit|integration|controllers|views|functional)/.*rb$% then
|
25
19
|
[filename]
|
26
20
|
when %r%^app/models/(.*)\.rb$% then
|
27
21
|
["test/unit/#{$1}_test.rb"]
|
@@ -29,10 +23,10 @@ class RailsAutotest < Autotest
|
|
29
23
|
@files.keys.select { |f|
|
30
24
|
f =~ %r%^test/(views|functional)/.*_test\.rb$%
|
31
25
|
}
|
32
|
-
when %r%^app/helpers/(.*)_helper.rb% then
|
26
|
+
when %r%^app/helpers/(.*)_helper.rb%, %r%^app/views/(.*)/% then
|
33
27
|
["test/views/#{$1}_view_test.rb",
|
34
28
|
"test/functional/#{$1}_controller_test.rb"]
|
35
|
-
when %r%^app/controllers/application.rb$% then
|
29
|
+
when %r%^app/controllers/application.rb$% then # FIX: wtf?
|
36
30
|
["test/controllers/dummy_controller_test.rb",
|
37
31
|
"test/functional/dummy_controller_test.rb"]
|
38
32
|
when %r%^app/controllers/(.*)\.rb$% then
|
@@ -40,9 +34,6 @@ class RailsAutotest < Autotest
|
|
40
34
|
"test/functional/#{$1}_test.rb"]
|
41
35
|
when %r%^app/views/layouts/% then
|
42
36
|
["test/views/layouts_view_test.rb"]
|
43
|
-
when %r%^app/views/(.*)/% then
|
44
|
-
["test/views/#{$1}_view_test.rb",
|
45
|
-
"test/functional/#{$1}_controller_test.rb"]
|
46
37
|
when %r%^config/routes.rb$% then
|
47
38
|
@files.keys.select do |f|
|
48
39
|
f =~ %r%^test/(controllers|views|functional)/.*_test\.rb$%
|
@@ -11,6 +11,10 @@ class Test::Rails::FunctionalTestCase < Test::Rails::TestCase
|
|
11
11
|
# controller class to instantiate.
|
12
12
|
#
|
13
13
|
# setup also instantiates a new @request and @response object.
|
14
|
+
#
|
15
|
+
# If you need to perform extra setup actions, define #setup_extra and
|
16
|
+
# FunctionalTestCase will call it after performing the rest of its setup
|
17
|
+
# actions.
|
14
18
|
|
15
19
|
def setup
|
16
20
|
return if self.class.name =~ /TestCase$/
|
@@ -29,6 +33,8 @@ class Test::Rails::FunctionalTestCase < Test::Rails::TestCase
|
|
29
33
|
@request.session = @session
|
30
34
|
|
31
35
|
@response = ActionController::TestResponse.new
|
36
|
+
|
37
|
+
setup_extra if respond_to? :setup_extra
|
32
38
|
end
|
33
39
|
|
34
40
|
##
|
@@ -29,15 +29,15 @@ dirs = [
|
|
29
29
|
%w[Libraries lib/],
|
30
30
|
%w[Models app/models],
|
31
31
|
%w[Unit\ tests test/unit],
|
32
|
+
%w[Helpers app/helpers],
|
33
|
+
%w[Helper\ tests test/helpers],
|
32
34
|
%w[Components components],
|
33
35
|
%w[Controllers app/controllers],
|
34
36
|
%w[Controller\ tests test/controllers],
|
35
|
-
%w[Helper\ tests test/helpers],
|
36
37
|
%w[View\ tests test/views],
|
37
38
|
%w[Functional\ tests test/functional],
|
38
39
|
%w[Integration\ tests test/integration],
|
39
40
|
%w[APIs app/apis],
|
40
|
-
%w[Helpers app/helpers],
|
41
41
|
]
|
42
42
|
|
43
43
|
dirs = dirs.map { |name, dir| [name, File.join(RAILS_ROOT, dir)] }
|
@@ -0,0 +1,89 @@
|
|
1
|
+
##
|
2
|
+
# test/rails/render_tree.rb adds debug rendering to ActionView::Base#render.
|
3
|
+
#
|
4
|
+
# Debug rendering prints out a tree of calls to render allowing you to easily
|
5
|
+
# visualize where rendering occurs in unfamiliar code.
|
6
|
+
|
7
|
+
class ActionView::Base
|
8
|
+
|
9
|
+
alias plain_render render # :nodoc:
|
10
|
+
|
11
|
+
##
|
12
|
+
# List of render types for ActionView::Base#render
|
13
|
+
|
14
|
+
RENDERS = [:partial, :template, :file, :action, :text, :inline, :nothing,
|
15
|
+
:update]
|
16
|
+
|
17
|
+
##
|
18
|
+
# Add debug output to rendering.
|
19
|
+
#
|
20
|
+
# When you include lib/rails/render_tree a tree of renders will be displayed
|
21
|
+
# in the console. This is especially useful when writing tests.
|
22
|
+
#
|
23
|
+
# This test:
|
24
|
+
#
|
25
|
+
# require 'test/test_helper'
|
26
|
+
# require 'test/rails/render_tree'
|
27
|
+
#
|
28
|
+
# class ThingsViewTest < Test::Rails::ViewTestCase
|
29
|
+
#
|
30
|
+
# fixtures :goals
|
31
|
+
#
|
32
|
+
# def test_body
|
33
|
+
# assigns[:goal] = goals(:first)
|
34
|
+
# assigns[:related_goals_moved] = []
|
35
|
+
# assigns[:related_goals_instead] = []
|
36
|
+
#
|
37
|
+
# render :partial => 'things/body'
|
38
|
+
#
|
39
|
+
# assert_tag :tag => 'div', :attributes => { :id => 'entriesbucket' }
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
# end
|
43
|
+
#
|
44
|
+
# Will give this output when run:
|
45
|
+
#
|
46
|
+
# $ ruby test/views/things_view_test.rb -n test_body
|
47
|
+
# Loaded suite test/views/things_view_test
|
48
|
+
# Started
|
49
|
+
# "things/_body"
|
50
|
+
# :partial => "widgets/goals_gallery_teaser"
|
51
|
+
# "widgets/_goals_gallery_teaser"
|
52
|
+
# :partial => "entries_bucket"
|
53
|
+
# "things/_entries_bucket"
|
54
|
+
# :partial => "things/ask_a_question"
|
55
|
+
# "things/_ask_a_question"
|
56
|
+
# "widgets/forms/related_goals"
|
57
|
+
# .
|
58
|
+
# Finished in 1.293523 seconds.
|
59
|
+
#
|
60
|
+
# 1 tests, 1 assertions, 0 failures, 0 errors
|
61
|
+
|
62
|
+
def render(*args)
|
63
|
+
@level ||= 0
|
64
|
+
|
65
|
+
print ' ' * @level
|
66
|
+
|
67
|
+
case args.first
|
68
|
+
when String then
|
69
|
+
p args.first
|
70
|
+
when Hash then
|
71
|
+
hash = args.first
|
72
|
+
found = hash.keys & RENDERS
|
73
|
+
if found.length == 1 then
|
74
|
+
puts "%p => %p" % [found.first, hash[found.first]]
|
75
|
+
else
|
76
|
+
raise "Dunno: %p" % [hash]
|
77
|
+
end
|
78
|
+
else
|
79
|
+
raise "Dunno: %p" % [args]
|
80
|
+
end
|
81
|
+
|
82
|
+
@level += 1
|
83
|
+
result = plain_render(*args)
|
84
|
+
@level -= 1
|
85
|
+
result
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
data/lib/test/rails/test_case.rb
CHANGED
@@ -415,14 +415,15 @@ class Test::Rails::ViewTestCase < Test::Rails::FunctionalTestCase
|
|
415
415
|
controller = @controller.class.name.sub('Controller', '')
|
416
416
|
controller = controller.gsub(/([A-Z])/, '_\1'.downcase).sub('_', '')
|
417
417
|
|
418
|
+
extensions = %w(rhtml rxml mab)
|
419
|
+
|
418
420
|
while test =~ /_/ do
|
419
|
-
return test if File.file? "app/views/#{controller}/#{test}
|
420
|
-
|
421
|
+
return test if extensions.any? { |ext| File.file? "app/views/#{controller}/#{test}.#{ext}" }
|
422
|
+
|
421
423
|
test = test.sub(/_[^_]+$/, '')
|
422
424
|
end
|
423
425
|
|
424
|
-
return test if File.file? "app/views/#{controller}/#{test}
|
425
|
-
return test if File.file? "app/views/#{controller}/#{test}.rxml"
|
426
|
+
return test if extensions.any? { |ext| File.file? "app/views/#{controller}/#{test}.#{ext}" }
|
426
427
|
|
427
428
|
flunk "Couldn't find view for test_#{orig_name}"
|
428
429
|
end
|
data/lib/unit_diff.rb
CHANGED
@@ -73,8 +73,8 @@ end
|
|
73
73
|
|
74
74
|
class UnitDiff
|
75
75
|
|
76
|
-
WINDOZE = /win32/ =~ RUBY_PLATFORM
|
77
|
-
DIFF = (WINDOZE ? 'diff.exe' : 'diff')
|
76
|
+
WINDOZE = /win32/ =~ RUBY_PLATFORM unless defined? WINDOZE
|
77
|
+
DIFF = (WINDOZE ? 'diff.exe' : 'diff') unless defined? DIFF
|
78
78
|
|
79
79
|
##
|
80
80
|
# Handy wrapper for UnitDiff#unit_diff.
|
data/lib/zentest.rb
CHANGED
@@ -5,9 +5,13 @@ $:.unshift( *$I.split(/:/) ) if defined? $I and String === $I
|
|
5
5
|
$r = false unless defined? $r # reverse mapping for testclass names
|
6
6
|
|
7
7
|
if $r then
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
# all this is needed because rails is retarded
|
9
|
+
$-w = false
|
10
|
+
$: << 'test'
|
11
|
+
$: << 'lib'
|
12
|
+
require 'config/environment'
|
13
|
+
f = './app/controllers/application.rb'
|
14
|
+
require f if test ?f, f
|
11
15
|
end
|
12
16
|
|
13
17
|
$ZENTEST = true
|
@@ -71,7 +75,7 @@ end
|
|
71
75
|
|
72
76
|
class ZenTest
|
73
77
|
|
74
|
-
VERSION = '3.
|
78
|
+
VERSION = '3.4.0'
|
75
79
|
|
76
80
|
if $TESTING then
|
77
81
|
attr_reader :missing_methods
|
data/test/test_autotest.rb
CHANGED
@@ -17,7 +17,17 @@ require 'autotest'
|
|
17
17
|
# run
|
18
18
|
# run_tests
|
19
19
|
|
20
|
+
class Autotest
|
21
|
+
def self.clear_hooks
|
22
|
+
HOOKS.clear
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
20
26
|
class TestAutotest < Test::Unit::TestCase
|
27
|
+
|
28
|
+
WINDOZE = /win32/ =~ RUBY_PLATFORM unless defined? WINDOZE
|
29
|
+
RUBY = (WINDOZE ? 'c:\ruby\bin\ruby' : '/usr/local/bin/ruby') unless defined? RUBY
|
30
|
+
|
21
31
|
def setup
|
22
32
|
@test_class = 'TestBlah'
|
23
33
|
@test = 'test/test_blah.rb'
|
@@ -31,32 +41,6 @@ class TestAutotest < Test::Unit::TestCase
|
|
31
41
|
@a.last_mtime = Time.at(2)
|
32
42
|
end
|
33
43
|
|
34
|
-
def test_hooks
|
35
|
-
@a.instance_variable_set :@reset1, false
|
36
|
-
@a.instance_variable_set :@reset2, false
|
37
|
-
@a.instance_variable_set :@reset3, false
|
38
|
-
|
39
|
-
Autotest.add_hook(:reset) do |at|
|
40
|
-
at.instance_variable_set :@reset1, true
|
41
|
-
end
|
42
|
-
|
43
|
-
Autotest.add_hook(:reset) do |at|
|
44
|
-
at.instance_variable_set :@reset2, true
|
45
|
-
end
|
46
|
-
|
47
|
-
Autotest.add_hook(:reset) do |at|
|
48
|
-
at.instance_variable_set :@reset3, true
|
49
|
-
end
|
50
|
-
|
51
|
-
@a.reset
|
52
|
-
|
53
|
-
assert @a.instance_variable_get(:@reset1), "Hook1 should work on reset"
|
54
|
-
assert @a.instance_variable_get(:@reset2), "Hook2 should work on reset"
|
55
|
-
assert @a.instance_variable_get(:@reset3), "Hook3 should work on reset"
|
56
|
-
end
|
57
|
-
|
58
|
-
# TODO BUG /usr/local/bin/ruby -I.:lib:test test/test_rails_autotest.rb -n "/^(test_hooks)$/" | unit_diff -u; /usr/local/bin/ruby -I.:lib:test test/test_autotest.rb -n "/^(test_hooks|test_hooks)$/" | unit_diff -u
|
59
|
-
|
60
44
|
def test_consolidate_failures_experiment
|
61
45
|
@a.files.clear
|
62
46
|
@a.files['lib/autotest.rb'] = Time.at(1)
|
@@ -91,6 +75,19 @@ class TestAutotest < Test::Unit::TestCase
|
|
91
75
|
assert_equal expected, @a.output.string
|
92
76
|
end
|
93
77
|
|
78
|
+
def test_consolidate_failures_nested_classes
|
79
|
+
@a.files.clear
|
80
|
+
@a.files['lib/outer/inner.rb'] = Time.at(5)
|
81
|
+
@a.files['test/outer/test_inner.rb'] = Time.at(5)
|
82
|
+
@a.files['lib/outer.rb'] = Time.at(5)
|
83
|
+
@a.files['test/test_outer.rb'] = Time.at(5)
|
84
|
+
result = @a.consolidate_failures([['test_blah1', "TestOuter::TestInner"]])
|
85
|
+
expected = {'test/outer/test_inner.rb' => ['test_blah1']}
|
86
|
+
assert_equal expected, result
|
87
|
+
expected = ""
|
88
|
+
assert_equal expected, @a.output.string
|
89
|
+
end
|
90
|
+
|
94
91
|
def test_consolidate_failures_red
|
95
92
|
result = @a.consolidate_failures([['test_blah1', @test_class], ['test_blah2', @test_class]])
|
96
93
|
expected = {@test => ['test_blah1', 'test_blah2']}
|
@@ -116,10 +113,6 @@ class TestAutotest < Test::Unit::TestCase
|
|
116
113
|
assert_equal "Dunno! fooby.rb\n", @a.output.string
|
117
114
|
end
|
118
115
|
|
119
|
-
def test_flunk
|
120
|
-
flunk
|
121
|
-
end
|
122
|
-
|
123
116
|
def test_find_files_to_test_lib
|
124
117
|
# ensure we add test_blah.rb when blah.rb updates
|
125
118
|
util_find_files_to_test(@impl, @test => [])
|
@@ -186,14 +179,58 @@ test_error2(TestAutotest):
|
|
186
179
|
assert_equal empty, @a.files_to_test
|
187
180
|
end
|
188
181
|
|
182
|
+
# TODO BUG /usr/local/bin/ruby -I.:lib:test test/test_rails_autotest.rb -n "/^(test_hooks)$/" | unit_diff -u; /usr/local/bin/ruby -I.:lib:test test/test_autotest.rb -n "/^(test_hooks|test_hooks)$/" | unit_diff -u
|
183
|
+
|
184
|
+
# TODO BUG /usr/local/bin/ruby -I.:lib:test test/test_rails_autotest.rb -n "/^(test_hook|test_hooks)$/" | unit_diff -u; /usr/local/bin/ruby -I.:lib:test test/test_autotest.rb -n "/^(test_hooks|test_hooks)$/" | unit_diff -u
|
185
|
+
|
186
|
+
def test_hook_overlap
|
187
|
+
Autotest.clear_hooks
|
188
|
+
|
189
|
+
@a.instance_variable_set :@blah1, false
|
190
|
+
@a.instance_variable_set :@blah2, false
|
191
|
+
@a.instance_variable_set :@blah3, false
|
192
|
+
|
193
|
+
Autotest.add_hook(:blah) do |at|
|
194
|
+
at.instance_variable_set :@blah1, true
|
195
|
+
end
|
196
|
+
|
197
|
+
Autotest.add_hook(:blah) do |at|
|
198
|
+
at.instance_variable_set :@blah2, true
|
199
|
+
end
|
200
|
+
|
201
|
+
Autotest.add_hook(:blah) do |at|
|
202
|
+
at.instance_variable_set :@blah3, true
|
203
|
+
end
|
204
|
+
|
205
|
+
@a.hook :blah
|
206
|
+
|
207
|
+
assert @a.instance_variable_get(:@blah1), "Hook1 should work on blah"
|
208
|
+
assert @a.instance_variable_get(:@blah2), "Hook2 should work on blah"
|
209
|
+
assert @a.instance_variable_get(:@blah3), "Hook3 should work on blah"
|
210
|
+
end
|
211
|
+
|
212
|
+
def test_hook_response
|
213
|
+
Autotest.clear_hooks
|
214
|
+
assert ! @a.hook(:blah)
|
215
|
+
|
216
|
+
Autotest.add_hook(:blah) { false }
|
217
|
+
assert ! @a.hook(:blah)
|
218
|
+
|
219
|
+
Autotest.add_hook(:blah) { false }
|
220
|
+
assert ! @a.hook(:blah)
|
221
|
+
|
222
|
+
Autotest.add_hook(:blah) { true }
|
223
|
+
assert @a.hook(:blah)
|
224
|
+
end
|
225
|
+
|
189
226
|
def test_make_test_cmd
|
190
|
-
ruby_cmd = Config::CONFIG['ruby_install_name']
|
191
227
|
f = {
|
192
228
|
@test => [],
|
193
229
|
'test/test_fooby.rb' => [ 'test_something1', 'test_something2' ]
|
194
230
|
}
|
195
|
-
|
196
|
-
|
231
|
+
|
232
|
+
expected = [ "#{RUBY} -I.:lib:test -rtest/unit -e \"%w[#{@test}].each { |f| load f }\" | unit_diff -u",
|
233
|
+
"#{RUBY} -I.:lib:test test/test_fooby.rb -n \"/^(test_something1|test_something2)$/\" | unit_diff -u" ].join("; ")
|
197
234
|
|
198
235
|
result = @a.make_test_cmd f
|
199
236
|
assert_equal expected, result
|
@@ -204,9 +241,17 @@ test_error2(TestAutotest):
|
|
204
241
|
assert_equal [@test], @a.tests_for_file(@test)
|
205
242
|
|
206
243
|
assert_equal ['test/test_unknown.rb'], @a.tests_for_file('test/test_unknown.rb')
|
244
|
+
# assert_equal [], @a.tests_for_file('test/test_unknown.rb')
|
207
245
|
assert_equal [], @a.tests_for_file('lib/unknown.rb')
|
208
246
|
assert_equal [], @a.tests_for_file('unknown.rb')
|
209
247
|
assert_equal [], @a.tests_for_file('test_unknown.rb')
|
248
|
+
|
249
|
+
# @a.files.clear
|
250
|
+
# @a.files["blah.rb"] = Time.at(1)
|
251
|
+
# @a.files["test_blah.rb"] = Time.at(2)
|
252
|
+
# @a.last_mtime = Time.at(2)
|
253
|
+
# assert_equal ["test_blah.rb"], @a.tests_for_file("test_blah.rb")
|
254
|
+
# assert_equal ["test_blah.rb"], @a.tests_for_file("blah.rb")
|
210
255
|
end
|
211
256
|
|
212
257
|
def util_find_files_to_test(f, expected)
|
data/test/test_rails_autotest.rb
CHANGED
@@ -54,6 +54,8 @@ class TestRailsAutotest < TestAutotest
|
|
54
54
|
def test_consolidate_failures_multiple_matches
|
55
55
|
@test2 = 'test/unit/route_again_test.rb'
|
56
56
|
@a.files[@test2] = Time.at(42)
|
57
|
+
@a.files['app/views/routes/edit.rhtml'] = Time.at(42)
|
58
|
+
@a.files['app/views/routes/list.rhtml'] = Time.at(42)
|
57
59
|
result = @a.consolidate_failures([['test_unmatched', @test_class]])
|
58
60
|
expected = {"test/unit/route_test.rb"=>["test_unmatched"]}
|
59
61
|
assert_equal expected, result
|
data/test/test_zentest.rb
CHANGED
@@ -5,10 +5,7 @@ require 'test/unit' unless defined? $ZENTEST and $ZENTEST
|
|
5
5
|
$TESTING = true
|
6
6
|
|
7
7
|
# I do this so I can still run ZenTest against the tests and itself...
|
8
|
-
|
9
|
-
puts "Requiring ZenTest"
|
10
|
-
require 'ZenTest'
|
11
|
-
#end
|
8
|
+
require 'ZenTest' unless defined? $ZENTEST
|
12
9
|
|
13
10
|
# These are just classes set up for quick testing.
|
14
11
|
# TODO: need to test a compound class name Mod::Cls
|
@@ -136,9 +133,7 @@ class MyClass8
|
|
136
133
|
def MyClass8.foobaz; end
|
137
134
|
end
|
138
135
|
|
139
|
-
class TestTrueClass
|
140
|
-
|
141
|
-
end
|
136
|
+
class TestTrueClass; end
|
142
137
|
|
143
138
|
class TestZenTest < Test::Unit::TestCase
|
144
139
|
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11.15
|
|
3
3
|
specification_version: 1
|
4
4
|
name: ZenTest
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 3.
|
7
|
-
date: 2006-
|
6
|
+
version: 3.4.0
|
7
|
+
date: 2006-09-12 00:00:00 -07:00
|
8
8
|
summary: |-
|
9
9
|
ZenTest can also be used to evaluate generated code and execute your
|
10
10
|
tests, allowing for very rapid development of both tests and
|
@@ -73,6 +73,14 @@ files:
|
|
73
73
|
- example2.rb
|
74
74
|
- example_dot_autotest.rb
|
75
75
|
- lib/autotest.rb
|
76
|
+
- lib/autotest/growl.rb
|
77
|
+
- lib/autotest/html_report.rb
|
78
|
+
- lib/autotest/kdenotify.rb
|
79
|
+
- lib/autotest/menu.rb
|
80
|
+
- lib/autotest/pretty.rb
|
81
|
+
- lib/autotest/redgreen.rb
|
82
|
+
- lib/autotest/snarl.rb
|
83
|
+
- lib/autotest/timestamp.rb
|
76
84
|
- lib/rails_autotest.rb
|
77
85
|
- lib/ruby_fork.rb
|
78
86
|
- lib/test/rails.rb
|
@@ -82,6 +90,7 @@ files:
|
|
82
90
|
- lib/test/rails/ivar_proxy.rb
|
83
91
|
- lib/test/rails/pp_html_document.rb
|
84
92
|
- lib/test/rails/rake_tasks.rb
|
93
|
+
- lib/test/rails/render_tree.rb
|
85
94
|
- lib/test/rails/test_case.rb
|
86
95
|
- lib/test/rails/view_test_case.rb
|
87
96
|
- lib/test/zentest_assertions.rb
|