ZenTest 3.2.0 → 3.3.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 +21 -0
- data/Manifest.txt +8 -24
- data/Rakefile +32 -8
- data/bin/autotest +4 -1
- data/bin/multiruby +20 -6
- data/bin/ruby_fork +6 -0
- data/bin/ruby_fork_client +6 -0
- data/example_dot_autotest.rb +148 -0
- data/lib/autotest.rb +201 -254
- data/lib/rails_autotest.rb +48 -110
- data/lib/ruby_fork.rb +178 -0
- data/lib/test/rails.rb +2 -2
- data/lib/test/rails/controller_test_case.rb +1 -1
- data/lib/test/rails/helper_test_case.rb +60 -0
- data/lib/test/rails/pp_html_document.rb +74 -0
- data/lib/test/rails/rake_tasks.rb +13 -12
- data/lib/test/rails/view_test_case.rb +2 -2
- data/lib/test/zentest_assertions.rb +39 -0
- data/lib/unit_diff.rb +6 -3
- data/lib/zentest.rb +1 -1
- data/test/test_autotest.rb +160 -208
- data/test/test_rails_autotest.rb +115 -138
- data/test/test_ruby_fork.rb +172 -0
- data/test/test_unit_diff.rb +69 -1
- data/test/test_zentest_assertions.rb +66 -0
- metadata +13 -27
- data/test/data/normal/lib/.#photo.rb +0 -0
- data/test/data/normal/lib/blah.rb +0 -0
- data/test/data/normal/lib/photo.rb +0 -0
- data/test/data/normal/test/#test_photo.rb# +0 -0
- data/test/data/normal/test/test_camelcase.rb +0 -0
- data/test/data/normal/test/test_photo.rb +0 -0
- data/test/data/normal/test/test_route.rb +0 -0
- data/test/data/normal/test/test_user.rb +0 -0
- data/test/data/rails/app/controllers/admin/theme_controller.rb +0 -0
- data/test/data/rails/app/controllers/route_controller.rb +0 -0
- data/test/data/rails/app/models/flickr_photo.rb +0 -0
- data/test/data/rails/app/models/route.rb +0 -0
- data/test/data/rails/app/views/route/index.rhtml +0 -0
- data/test/data/rails/config/environment.rb +0 -0
- data/test/data/rails/config/routes.rb +0 -0
- data/test/data/rails/test/controllers/route_controller_test.rb +0 -0
- data/test/data/rails/test/fixtures/routes.yml +0 -0
- data/test/data/rails/test/functional/admin/themes_controller_test.rb +0 -0
- data/test/data/rails/test/functional/dummy_controller_test.rb +0 -0
- data/test/data/rails/test/functional/route_controller_test.rb +0 -0
- data/test/data/rails/test/unit/flickr_photo_test.rb +0 -0
- data/test/data/rails/test/unit/photo_test.rb +0 -0
- data/test/data/rails/test/unit/route_test.rb +0 -0
- data/test/data/rails/test/views/route_view_test.rb +0 -0
@@ -1,25 +1,25 @@
|
|
1
1
|
require 'code_statistics'
|
2
2
|
|
3
|
-
|
4
|
-
desc
|
5
|
-
Rake::TestTask.new
|
3
|
+
def define_test_task(test_type)
|
4
|
+
desc "Run the #{test_type} tests in test/#{test_type}s"
|
5
|
+
Rake::TestTask.new "#{test_type}s" => [ 'db:test:prepare' ] do |t|
|
6
6
|
t.libs << 'test'
|
7
|
-
t.pattern =
|
7
|
+
t.pattern = "test/#{test_type}s/**/*_test.rb"
|
8
8
|
t.verbose = true
|
9
9
|
end
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
t.verbose = true
|
16
|
-
end
|
12
|
+
namespace :test do
|
13
|
+
define_test_task 'helper'
|
14
|
+
define_test_task 'view'
|
15
|
+
define_test_task 'controller'
|
17
16
|
end
|
18
17
|
|
19
18
|
desc 'Run all tests'
|
20
19
|
task :test => %w[
|
21
20
|
test:units
|
22
21
|
test:controllers
|
22
|
+
test:helpers
|
23
23
|
test:views
|
24
24
|
test:functionals
|
25
25
|
test:integration
|
@@ -32,6 +32,7 @@ dirs = [
|
|
32
32
|
%w[Components components],
|
33
33
|
%w[Controllers app/controllers],
|
34
34
|
%w[Controller\ tests test/controllers],
|
35
|
+
%w[Helper\ tests test/helpers],
|
35
36
|
%w[View\ tests test/views],
|
36
37
|
%w[Functional\ tests test/functional],
|
37
38
|
%w[Integration\ tests test/integration],
|
@@ -44,6 +45,6 @@ dirs = dirs.select { |name, dir| File.directory? dir }
|
|
44
45
|
|
45
46
|
STATS_DIRECTORIES.replace dirs
|
46
47
|
|
47
|
-
|
48
|
-
CodeStatistics::TEST_TYPES
|
48
|
+
new_test_types = ['Controller tests', 'Helper tests', 'View tests']
|
49
|
+
CodeStatistics::TEST_TYPES.push(*new_test_types)
|
49
50
|
|
@@ -71,8 +71,8 @@
|
|
71
71
|
# @request.request_uri = '/foo'
|
72
72
|
# assigns[:action_title] = 'Hello & Goodbye'
|
73
73
|
#
|
74
|
-
# # Render an empty string with the '
|
75
|
-
# render :text => '', :layout => '
|
74
|
+
# # Render an empty string with the 'application' layout.
|
75
|
+
# render :text => '', :layout => 'application'
|
76
76
|
#
|
77
77
|
# # Assert content just like a regular view test.
|
78
78
|
# assert_links_to '/', 'Home'
|
@@ -17,6 +17,14 @@ module Test::Unit::Assertions
|
|
17
17
|
|
18
18
|
alias deny_equal assert_not_equal
|
19
19
|
|
20
|
+
##
|
21
|
+
# Asserts that +obj+ responds to #empty? and #empty? returns true.
|
22
|
+
|
23
|
+
def assert_empty(obj)
|
24
|
+
assert_respond_to obj, :empty?
|
25
|
+
assert_equal true, obj.empty?
|
26
|
+
end
|
27
|
+
|
20
28
|
##
|
21
29
|
# Asserts that +obj+ responds to #empty? and #empty? returns false.
|
22
30
|
|
@@ -42,5 +50,36 @@ module Test::Unit::Assertions
|
|
42
50
|
assert_equal false, obj.include?(item), message
|
43
51
|
end
|
44
52
|
|
53
|
+
##
|
54
|
+
# Captures $stdout and $stderr to StringIO objects and returns them.
|
55
|
+
# Restores $stdout and $stderr when done.
|
56
|
+
#
|
57
|
+
# Usage:
|
58
|
+
# def test_puts
|
59
|
+
# out, err = capture do
|
60
|
+
# puts 'hi'
|
61
|
+
# STDERR.puts 'bye!'
|
62
|
+
# end
|
63
|
+
# assert_equal "hi\n", out.string
|
64
|
+
# assert_equal "bye!\n", err.string
|
65
|
+
# end
|
66
|
+
|
67
|
+
def util_capture
|
68
|
+
require 'stringio'
|
69
|
+
orig_stdout = $stdout.dup
|
70
|
+
orig_stderr = $stderr.dup
|
71
|
+
captured_stdout = StringIO.new
|
72
|
+
captured_stderr = StringIO.new
|
73
|
+
$stdout = captured_stdout
|
74
|
+
$stderr = captured_stderr
|
75
|
+
yield
|
76
|
+
captured_stdout.rewind
|
77
|
+
captured_stderr.rewind
|
78
|
+
return captured_stdout, captured_stderr
|
79
|
+
ensure
|
80
|
+
$stdout = orig_stdout
|
81
|
+
$stderr = orig_stderr
|
82
|
+
end
|
83
|
+
|
45
84
|
end
|
46
85
|
|
data/lib/unit_diff.rb
CHANGED
@@ -28,7 +28,7 @@ def temp_file(data)
|
|
28
28
|
data = data.map { |l| '%3d) %s' % [count+=1, l] } if $l
|
29
29
|
data = data.join('')
|
30
30
|
# unescape newlines, strip <> from entire string
|
31
|
-
data = data.gsub(/\\n/, "\n").gsub(
|
31
|
+
data = data.gsub(/\\n/, "\n").gsub(/0x[a-f0-9]+/m, '0xXXXXXX') + "\n"
|
32
32
|
temp.print data
|
33
33
|
temp.puts unless data =~ /\n\Z/m
|
34
34
|
temp.flush
|
@@ -80,6 +80,7 @@ class UnitDiff
|
|
80
80
|
# Handy wrapper for UnitDiff#unit_diff.
|
81
81
|
|
82
82
|
def self.unit_diff(input)
|
83
|
+
trap 'INT' do exit 1 end
|
83
84
|
ud = UnitDiff.new
|
84
85
|
ud.unit_diff(input)
|
85
86
|
end
|
@@ -193,8 +194,10 @@ class UnitDiff
|
|
193
194
|
end
|
194
195
|
end
|
195
196
|
|
196
|
-
|
197
|
-
|
197
|
+
if footer then
|
198
|
+
footer.shift if footer.first.strip.empty?
|
199
|
+
output.push footer.compact.map {|line| line.strip}.join("\n")
|
200
|
+
end
|
198
201
|
|
199
202
|
return output.flatten.join("\n")
|
200
203
|
end
|
data/lib/zentest.rb
CHANGED
data/test/test_autotest.rb
CHANGED
@@ -1,269 +1,221 @@
|
|
1
|
+
#!/usr/local/bin/ruby -w
|
2
|
+
|
1
3
|
$TESTING = true
|
2
4
|
|
5
|
+
require 'test/unit/testcase'
|
6
|
+
require 'test/unit' if $0 == __FILE__
|
3
7
|
require 'stringio'
|
4
|
-
require 'test/unit'
|
5
|
-
|
6
8
|
require 'autotest'
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
raise 'Out of system responses' if @system_responses.empty?
|
18
|
-
return @system_responses.shift
|
19
|
-
end
|
20
|
-
|
21
|
-
attr_accessor :backtick_responses
|
22
|
-
|
23
|
-
def `(cmd) # ` appeases emacs
|
24
|
-
@backtick_responses ||= []
|
25
|
-
raise 'Out of backtick responses' if @backtick_responses.empty?
|
26
|
-
return @backtick_responses.shift
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
10
|
+
# NOT TESTED:
|
11
|
+
# class_run
|
12
|
+
# add_sigint_handler
|
13
|
+
# all_good
|
14
|
+
# get_to_green
|
15
|
+
# reset
|
16
|
+
# ruby
|
17
|
+
# run
|
18
|
+
# run_tests
|
30
19
|
|
31
20
|
class TestAutotest < Test::Unit::TestCase
|
32
|
-
|
33
21
|
def setup
|
34
|
-
@
|
35
|
-
|
36
|
-
@
|
37
|
-
@photo_file = 'lib/photo.rb'
|
38
|
-
@photo_test_file = 'test/test_photo.rb'
|
39
|
-
@route_test_file = 'test/test_route.rb'
|
40
|
-
@user_test_file = 'test/test_user.rb'
|
41
|
-
@camelcase_test_file = 'test/test_camelcase.rb'
|
22
|
+
@test_class = 'TestBlah'
|
23
|
+
@test = 'test/test_blah.rb'
|
24
|
+
@impl = 'lib/blah.rb'
|
42
25
|
|
43
|
-
@
|
26
|
+
@a = Object.const_get(self.class.name[4..-1]).new
|
27
|
+
@a.output = StringIO.new
|
28
|
+
@a.files.clear
|
29
|
+
@a.files[@impl] = Time.at(1)
|
30
|
+
@a.files[@test] = Time.at(2)
|
31
|
+
@a.last_mtime = Time.at(2)
|
32
|
+
end
|
44
33
|
|
45
|
-
|
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
|
46
38
|
|
47
|
-
|
48
|
-
|
49
|
-
util_touch @photo_test_file, (Time.now - 60)
|
50
|
-
util_touch @camelcase_test_file, (Time.now - 60)
|
39
|
+
Autotest.add_hook(:reset) do |at|
|
40
|
+
at.instance_variable_set :@reset1, true
|
51
41
|
end
|
52
42
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
def test_consolidate_failures
|
57
|
-
failed = [
|
58
|
-
%w[test_a TestOne],
|
59
|
-
%w[test_b TestOne],
|
60
|
-
%w[test_c TestOne],
|
61
|
-
%w[test_d TestTwo],
|
62
|
-
]
|
63
|
-
|
64
|
-
expected = [
|
65
|
-
["'/^(test_a|test_b|test_c)$/'", /one/],
|
66
|
-
["'/^(test_d)$/'", /two/],
|
67
|
-
]
|
68
|
-
|
69
|
-
assert_equal expected,
|
70
|
-
@at.consolidate_failures(failed).sort_by { |f,k| k.source }
|
71
|
-
end
|
43
|
+
Autotest.add_hook(:reset) do |at|
|
44
|
+
at.instance_variable_set :@reset2, true
|
45
|
+
end
|
72
46
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
updated_files = []
|
47
|
+
Autotest.add_hook(:reset) do |at|
|
48
|
+
at.instance_variable_set :@reset3, true
|
49
|
+
end
|
77
50
|
|
78
|
-
|
51
|
+
@a.reset
|
79
52
|
|
80
|
-
|
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"
|
81
56
|
end
|
82
57
|
|
83
|
-
#
|
84
|
-
def test_failed_test_files_test_updated
|
85
|
-
tests = [@user_test_file, @photo_test_file]
|
86
|
-
updated_files = [@photo_test_file]
|
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
|
87
59
|
|
88
|
-
|
60
|
+
def test_consolidate_failures_experiment
|
61
|
+
@a.files.clear
|
62
|
+
@a.files['lib/autotest.rb'] = Time.at(1)
|
63
|
+
@a.files['test/test_autotest.rb'] = Time.at(2)
|
89
64
|
|
90
|
-
|
65
|
+
input = [['test_fail1', 'TestAutotest'], ['test_fail2', 'TestAutotest'], ['test_error1', 'TestAutotest'], ['test_error2', 'TestAutotest']]
|
66
|
+
result = @a.consolidate_failures input
|
67
|
+
expected = { 'test/test_autotest.rb' => %w( test_fail1 test_fail2 test_error1 test_error2 ) }
|
68
|
+
assert_equal expected, result
|
91
69
|
end
|
92
70
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
failed_files = @at.failed_test_files(/photo/, tests, updated_files)
|
99
|
-
|
100
|
-
assert_equal [], failed_files
|
71
|
+
def test_consolidate_failures_green
|
72
|
+
result = @a.consolidate_failures([])
|
73
|
+
expected = {}
|
74
|
+
assert_equal expected, result
|
101
75
|
end
|
102
76
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
assert_equal [@camelcase_test_file], failed_files
|
77
|
+
def test_consolidate_failures_multiple_matches
|
78
|
+
@a.files['test/test_blah_again.rb'] = Time.at(42)
|
79
|
+
result = @a.consolidate_failures([['test_unmatched', @test_class]])
|
80
|
+
expected = {}
|
81
|
+
assert_equal expected, result
|
82
|
+
expected = "multiple files matched class TestBlah [\"test/test_blah.rb\", \"test/test_blah_again.rb\"].\n"
|
83
|
+
assert_equal expected, @a.output.string
|
111
84
|
end
|
112
85
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
failed_files = @at.failed_test_files(/photo/, tests, updated_files)
|
120
|
-
|
121
|
-
assert_equal [@photo_test_file], failed_files
|
122
|
-
|
123
|
-
failed_files = @at.failed_test_files(/user/, tests, updated_files)
|
124
|
-
|
125
|
-
assert_equal [@user_test_file], failed_files
|
86
|
+
def test_consolidate_failures_no_match
|
87
|
+
result = @a.consolidate_failures([['test_blah1', @test_class], ['test_blah2', @test_class], ['test_blah1', 'TestUnknown']])
|
88
|
+
expected = {@test => ['test_blah1', 'test_blah2']}
|
89
|
+
assert_equal expected, result
|
90
|
+
expected = "Unable to map class TestUnknown to a file\n"
|
91
|
+
assert_equal expected, @a.output.string
|
126
92
|
end
|
127
93
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
failed_files = @at.failed_test_files(/photo/, tests, updated_files)
|
134
|
-
|
135
|
-
assert_equal [@photo_test_file], failed_files
|
94
|
+
def test_consolidate_failures_red
|
95
|
+
result = @a.consolidate_failures([['test_blah1', @test_class], ['test_blah2', @test_class]])
|
96
|
+
expected = {@test => ['test_blah1', 'test_blah2']}
|
97
|
+
assert_equal expected, result
|
136
98
|
end
|
137
99
|
|
138
|
-
|
139
|
-
@at.files['test/test_one.rb'] = Time.at 0
|
140
|
-
@at.files['test/test_two.rb'] = Time.at 0
|
100
|
+
# TODO: lots of filename edgecases for find_files_to_test
|
141
101
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
]
|
102
|
+
def test_find_files_to_test
|
103
|
+
@a.last_mtime = Time.at(0)
|
104
|
+
assert @a.find_files_to_test(@a.files)
|
146
105
|
|
147
|
-
|
148
|
-
|
149
|
-
# test_a
|
150
|
-
# test_b
|
151
|
-
# test_c
|
152
|
-
# test/test_two.rb:
|
153
|
-
# test_d"
|
154
|
-
|
155
|
-
assert_equal expected, @at.failure_report(failures)
|
106
|
+
@a.last_mtime = @a.files.values.sort.last + 1
|
107
|
+
assert ! @a.find_files_to_test(@a.files)
|
156
108
|
end
|
157
109
|
|
158
|
-
def
|
159
|
-
|
160
|
-
util_add_map('lib/autotest.rb', ['test/test_autotest.rb'])
|
161
|
-
util_add_map('lib/auto_test.rb', ['test/test_autotest.rb'])
|
162
|
-
util_add_map('test/test_autotest.rb', ['test/test_autotest.rb'])
|
163
|
-
|
164
|
-
@file_map.keys.each { |file| @at.files[file] = Time.at 0 }
|
110
|
+
def test_find_files_to_test_dunno
|
111
|
+
empty = {}
|
165
112
|
|
166
|
-
|
113
|
+
files = { "fooby.rb" => Time.at(42) }
|
114
|
+
assert @a.find_files_to_test(files) # we find fooby,
|
115
|
+
assert_equal empty, @a.files_to_test # but it isn't something to test
|
116
|
+
assert_equal "Dunno! fooby.rb\n", @a.output.string
|
167
117
|
end
|
168
118
|
|
169
|
-
def
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
failed = [['test_route', /photo/]]
|
174
|
-
tests = [@photo_test_file]
|
175
|
-
|
176
|
-
@at.backtick_responses = ['1 tests, 1 assertions, 0 failures, 0 errors']
|
177
|
-
|
178
|
-
util_touch @photo_test_file
|
179
|
-
|
180
|
-
out, err = util_capture do
|
181
|
-
@at.retest_failed failed, tests
|
182
|
-
end
|
183
|
-
|
184
|
-
out = out.split $/
|
185
|
-
|
186
|
-
assert_equal "# Waiting for changes", out.shift
|
187
|
-
assert_equal "# Rerunning failures: #{@photo_test_file}", out.shift
|
188
|
-
assert_equal "+ #{@at.ruby} -Ilib:test #{@photo_test_file} -n test_route | unit_diff -u", out.shift
|
119
|
+
def test_flunk
|
120
|
+
flunk
|
121
|
+
end
|
189
122
|
|
190
|
-
|
191
|
-
|
123
|
+
def test_find_files_to_test_lib
|
124
|
+
# ensure we add test_blah.rb when blah.rb updates
|
125
|
+
util_find_files_to_test(@impl, @test => [])
|
192
126
|
end
|
193
127
|
|
194
|
-
def
|
195
|
-
|
196
|
-
@at.updated?(@photo_test_file)
|
128
|
+
def test_find_files_to_test_no_change
|
129
|
+
empty = {}
|
197
130
|
|
198
|
-
|
199
|
-
|
131
|
+
# ensure world is virginal
|
132
|
+
assert_equal empty, @a.files_to_test
|
200
133
|
|
201
|
-
|
134
|
+
# ensure we do nothing when nothing changes...
|
135
|
+
files = { @impl => @a.files[@impl] } # same time
|
136
|
+
assert ! @a.find_files_to_test(files)
|
137
|
+
assert_equal empty, @a.files_to_test
|
138
|
+
assert_equal "", @a.output.string
|
202
139
|
|
203
|
-
|
204
|
-
|
205
|
-
|
140
|
+
files = { @impl => @a.files[@impl] } # same time
|
141
|
+
assert(! @a.find_files_to_test(files))
|
142
|
+
assert_equal empty, @a.files_to_test
|
143
|
+
assert_equal "", @a.output.string
|
206
144
|
end
|
207
145
|
|
208
|
-
def
|
209
|
-
|
210
|
-
|
211
|
-
assert_equal this_ruby, @at.ruby
|
146
|
+
def test_find_files_to_test_test
|
147
|
+
# ensure we add test_blah.rb when test_blah.rb itself updates
|
148
|
+
util_find_files_to_test(@test, @test => [])
|
212
149
|
end
|
213
150
|
|
214
|
-
def
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
end
|
222
|
-
end
|
151
|
+
def test_handle_results
|
152
|
+
@a.files_to_test.clear
|
153
|
+
@a.files.clear
|
154
|
+
@a.files['lib/autotest.rb'] = Time.at(1)
|
155
|
+
@a.files['test/test_autotest.rb'] = Time.at(2)
|
156
|
+
empty = {}
|
157
|
+
assert_equal empty, @a.files_to_test, "must start empty"
|
223
158
|
|
224
|
-
|
225
|
-
|
226
|
-
|
159
|
+
s1 = "Loaded suite -e
|
160
|
+
Started
|
161
|
+
............
|
162
|
+
Finished in 0.001655 seconds.
|
227
163
|
|
228
|
-
|
164
|
+
12 tests, 18 assertions, 0 failures, 0 errors
|
165
|
+
"
|
229
166
|
|
230
|
-
|
167
|
+
@a.handle_results(s1)
|
168
|
+
assert_equal empty, @a.files_to_test, "must stay empty"
|
231
169
|
|
232
|
-
|
170
|
+
s2 = "
|
171
|
+
1) Failure:
|
172
|
+
test_fail1(TestAutotest) [./test/test_autotest.rb:59]:
|
173
|
+
2) Failure:
|
174
|
+
test_fail2(TestAutotest) [./test/test_autotest.rb:59]:
|
175
|
+
3) Error:
|
176
|
+
test_error1(TestAutotest):
|
177
|
+
3) Error:
|
178
|
+
test_error2(TestAutotest):
|
179
|
+
"
|
233
180
|
|
234
|
-
|
235
|
-
|
236
|
-
|
181
|
+
@a.handle_results(s2)
|
182
|
+
expected = { "test/test_autotest.rb" => %w( test_fail1 test_fail2 test_error1 test_error2 ) }
|
183
|
+
assert_equal expected, @a.files_to_test
|
237
184
|
|
238
|
-
|
239
|
-
|
185
|
+
@a.handle_results(s1)
|
186
|
+
assert_equal empty, @a.files_to_test
|
240
187
|
end
|
241
188
|
|
242
|
-
def
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
189
|
+
def test_make_test_cmd
|
190
|
+
ruby_cmd = Config::CONFIG['ruby_install_name']
|
191
|
+
f = {
|
192
|
+
@test => [],
|
193
|
+
'test/test_fooby.rb' => [ 'test_something1', 'test_something2' ]
|
194
|
+
}
|
195
|
+
expected = [ "/usr/local/bin/#{ruby_cmd} -I.:lib:test -rtest/unit -e \"%w[#{@test}].each { |f| load f }\" | unit_diff -u",
|
196
|
+
"/usr/local/bin/#{ruby_cmd} -I.:lib:test test/test_fooby.rb -n \"/^(test_something1|test_something2)$/\" | unit_diff -u" ].join("; ")
|
249
197
|
|
250
|
-
|
251
|
-
|
252
|
-
old_stderr = $stderr
|
253
|
-
out = StringIO.new
|
254
|
-
err = StringIO.new
|
255
|
-
$stdout = out
|
256
|
-
$stderr = err
|
257
|
-
yield
|
258
|
-
return out.string, err.string
|
259
|
-
ensure
|
260
|
-
$stdout = old_stdout
|
261
|
-
$stderr = old_stderr
|
198
|
+
result = @a.make_test_cmd f
|
199
|
+
assert_equal expected, result
|
262
200
|
end
|
263
201
|
|
264
|
-
def
|
265
|
-
|
202
|
+
def test_tests_for_file
|
203
|
+
assert_equal [@test], @a.tests_for_file(@impl)
|
204
|
+
assert_equal [@test], @a.tests_for_file(@test)
|
205
|
+
|
206
|
+
assert_equal ['test/test_unknown.rb'], @a.tests_for_file('test/test_unknown.rb')
|
207
|
+
assert_equal [], @a.tests_for_file('lib/unknown.rb')
|
208
|
+
assert_equal [], @a.tests_for_file('unknown.rb')
|
209
|
+
assert_equal [], @a.tests_for_file('test_unknown.rb')
|
266
210
|
end
|
267
211
|
|
268
|
-
|
212
|
+
def util_find_files_to_test(f, expected)
|
213
|
+
t = @a.last_mtime + 1
|
214
|
+
files = { f => t }
|
269
215
|
|
216
|
+
assert @a.find_files_to_test(files)
|
217
|
+
assert_equal expected, @a.files_to_test
|
218
|
+
assert_equal t, @a.files[f]
|
219
|
+
assert_equal "", @a.output.string
|
220
|
+
end
|
221
|
+
end
|