activesambaldap 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/NEWS.en +20 -18
- data/NEWS.ja +23 -21
- data/README.en +122 -95
- data/README.ja +125 -98
- data/Rakefile +29 -64
- data/bin/asl-groupadd +1 -1
- data/bin/asl-groupadd.help +1 -0
- data/bin/asl-groupdel +1 -1
- data/bin/asl-groupdel.help +1 -0
- data/bin/asl-groupmod +1 -1
- data/bin/asl-groupmod.help +1 -0
- data/bin/asl-groupshow +1 -1
- data/bin/asl-groupshow.help +1 -0
- data/bin/asl-passwd +1 -1
- data/bin/asl-passwd.help +1 -0
- data/bin/asl-populate +2 -2
- data/bin/asl-populate.help +1 -0
- data/bin/asl-purge +1 -1
- data/bin/asl-purge.help +1 -0
- data/bin/asl-samba-computeradd +1 -1
- data/bin/asl-samba-computeradd.help +1 -0
- data/bin/asl-samba-groupadd +1 -1
- data/bin/asl-samba-groupadd.help +1 -0
- data/bin/asl-samba-groupdel +1 -1
- data/bin/asl-samba-groupdel.help +1 -0
- data/bin/asl-samba-groupmod +1 -1
- data/bin/asl-samba-groupmod.help +1 -0
- data/bin/asl-samba-useradd +1 -1
- data/bin/asl-samba-useradd.help +1 -0
- data/bin/asl-samba-userdel +1 -1
- data/bin/asl-samba-userdel.help +1 -0
- data/bin/asl-samba-usermod +1 -1
- data/bin/asl-samba-usermod.help +1 -0
- data/bin/asl-useradd +1 -1
- data/bin/asl-useradd.help +6 -4
- data/bin/asl-userdel +1 -1
- data/bin/asl-userdel.help +1 -0
- data/bin/asl-usermod +1 -1
- data/bin/asl-usermod.help +2 -0
- data/bin/asl-usershow +1 -1
- data/bin/asl-usershow.help +1 -0
- data/data/locale/ja/LC_MESSAGES/active-samba-ldap.mo +0 -0
- data/lib/active_samba_ldap/version.rb +1 -1
- data/lib/active_samba_ldap.rb +1 -1
- data/po/ja/active-samba-ldap.po +5 -5
- data/rails/{plugin/active_samba_ldap/README → README} +0 -0
- data/rails/{plugin/active_samba_ldap/init.rb → init.rb} +1 -1
- data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/scaffold_active_samba_ldap_generator.rb +0 -0
- data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/computer.rb +0 -0
- data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/dc.rb +0 -0
- data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/group.rb +0 -0
- data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/idmap.rb +0 -0
- data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/ldap.yml +0 -0
- data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/ou.rb +0 -0
- data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/samba_controller.rb +0 -0
- data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/samba_helper.rb +0 -0
- data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/samba_index.rhtml +0 -0
- data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/samba_populate.rhtml +0 -0
- data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/samba_purge.rhtml +0 -0
- data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/unix_id_pool.rb +0 -0
- data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/user.rb +0 -0
- data/test/asl-test-utils.rb +2 -2
- data/test/test_asl_usershow.rb +2 -2
- data/test/test_password.rb +2 -2
- data/test/test_user_home_directory.rb +2 -2
- data/test-unit/History.txt +76 -1
- data/test-unit/README.txt +32 -12
- data/test-unit/Rakefile +19 -1
- data/test-unit/TODO +5 -0
- data/test-unit/lib/test/unit/assertions.rb +515 -88
- data/test-unit/lib/test/unit/autorunner.rb +93 -14
- data/test-unit/lib/test/unit/collector/load.rb +1 -1
- data/test-unit/lib/test/unit/collector.rb +1 -1
- data/test-unit/lib/test/unit/color-scheme.rb +86 -0
- data/test-unit/lib/test/unit/color.rb +40 -5
- data/test-unit/lib/test/unit/diff.rb +14 -0
- data/test-unit/lib/test/unit/fixture.rb +7 -16
- data/test-unit/lib/test/unit/notification.rb +9 -0
- data/test-unit/lib/test/unit/omission.rb +14 -0
- data/test-unit/lib/test/unit/pending.rb +16 -0
- data/test-unit/lib/test/unit/priority.rb +38 -3
- data/test-unit/lib/test/unit/runner/console.rb +8 -2
- data/test-unit/lib/test/unit/testcase.rb +263 -12
- data/test-unit/lib/test/unit/ui/console/testrunner.rb +58 -30
- data/test-unit/lib/test/unit/util/method-owner-finder.rb +28 -0
- data/test-unit/lib/test/unit/version.rb +1 -1
- data/test-unit/lib/test/unit.rb +62 -0
- data/test-unit/sample/test_user.rb +22 -0
- data/test-unit/test/collector/{test_descendant.rb → test-descendant.rb} +0 -0
- data/test-unit/test/collector/{test_load.rb → test-load.rb} +1 -1
- data/test-unit/test/{test_attribute.rb → test-attribute.rb} +0 -0
- data/test-unit/test/test-color-scheme.rb +56 -0
- data/test-unit/test/{test_color.rb → test-color.rb} +10 -0
- data/test-unit/test/{test_diff.rb → test-diff.rb} +0 -0
- data/test-unit/test/{test_emacs_runner.rb → test-emacs-runner.rb} +0 -0
- data/test-unit/test/test-fixture.rb +287 -0
- data/test-unit/test/{test_notification.rb → test-notification.rb} +4 -4
- data/test-unit/test/{test_omission.rb → test-omission.rb} +6 -6
- data/test-unit/test/{test_pending.rb → test-pending.rb} +12 -6
- data/test-unit/test/{test_priority.rb → test-priority.rb} +30 -0
- data/test-unit/test/{test_testcase.rb → test-testcase.rb} +100 -4
- data/test-unit/test/test_assertions.rb +462 -73
- data/test-unit/test/{testunit_test_util.rb → testunit-test-util.rb} +4 -2
- data/test-unit/test/ui/test_testrunmediator.rb +1 -1
- data/test-unit/test/util/test-method-owner-finder.rb +38 -0
- metadata +69 -79
- data/test-unit/test/test_fixture.rb +0 -275
@@ -0,0 +1,56 @@
|
|
1
|
+
class TestUnitColorScheme < Test::Unit::TestCase
|
2
|
+
def test_default
|
3
|
+
assert_equal({
|
4
|
+
"success" => color("green", :bold => true),
|
5
|
+
"failure" => color("red", :bold => true),
|
6
|
+
"pending" => color("magenta", :bold => true),
|
7
|
+
"omission" => color("blue", :bold => true),
|
8
|
+
"notification" => color("cyan", :bold => true),
|
9
|
+
"error" => color("yellow", :bold => true) +
|
10
|
+
color("black", :foreground => false),
|
11
|
+
},
|
12
|
+
Test::Unit::ColorScheme.default.to_hash)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_register
|
16
|
+
inverted_scheme_spec = {
|
17
|
+
"success" => {:name => "red"},
|
18
|
+
"failure" => {:name => "green"},
|
19
|
+
}
|
20
|
+
Test::Unit::ColorScheme["inverted"] = inverted_scheme_spec
|
21
|
+
assert_equal({
|
22
|
+
"success" => color("red"),
|
23
|
+
"failure" => color("green"),
|
24
|
+
},
|
25
|
+
Test::Unit::ColorScheme["inverted"].to_hash)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_new_with_colors
|
29
|
+
scheme = Test::Unit::ColorScheme.new(:success => color("blue"),
|
30
|
+
"failure" => color("green",
|
31
|
+
:underline => true))
|
32
|
+
assert_equal({
|
33
|
+
"success" => color("blue"),
|
34
|
+
"failure" => color("green", :underline => true),
|
35
|
+
},
|
36
|
+
scheme.to_hash)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_new_with_spec
|
40
|
+
scheme = Test::Unit::ColorScheme.new(:success => {
|
41
|
+
:name => "blue",
|
42
|
+
:bold => true
|
43
|
+
},
|
44
|
+
"failure" => {:name => "green"})
|
45
|
+
assert_equal({
|
46
|
+
"success" => color("blue", :bold => true),
|
47
|
+
"failure" => color("green"),
|
48
|
+
},
|
49
|
+
scheme.to_hash)
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
def color(name, options={})
|
54
|
+
Test::Unit::Color.new(name, options)
|
55
|
+
end
|
56
|
+
end
|
@@ -20,6 +20,16 @@ class TestUnitColor < Test::Unit::TestCase
|
|
20
20
|
color("none", :underline => true))
|
21
21
|
end
|
22
22
|
|
23
|
+
def test_equal
|
24
|
+
red = color("red")
|
25
|
+
red_bold = color("red", :bold => true)
|
26
|
+
|
27
|
+
assert_operator(red, :==, red)
|
28
|
+
assert_not_equal(red, nil)
|
29
|
+
assert_equal(red, color("red"))
|
30
|
+
assert_not_equal(red, red_bold)
|
31
|
+
end
|
32
|
+
|
23
33
|
private
|
24
34
|
def color(name, options={})
|
25
35
|
Test::Unit::Color.new(name, options)
|
File without changes
|
File without changes
|
@@ -0,0 +1,287 @@
|
|
1
|
+
class TestUnitFixture < Test::Unit::TestCase
|
2
|
+
module EmptyModule
|
3
|
+
end
|
4
|
+
|
5
|
+
def test_setup_without_option
|
6
|
+
expected_setup_calls = [:setup,
|
7
|
+
:custom_setup_method0,
|
8
|
+
:custom_setup_method1,
|
9
|
+
:custom_setup_method3]
|
10
|
+
test_case = assert_setup(expected_setup_calls, [])
|
11
|
+
assert_inherited_setup(expected_setup_calls, test_case)
|
12
|
+
|
13
|
+
assert_inherited_setup([:setup], nil)
|
14
|
+
assert_called_fixtures(expected_setup_calls, test_case)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_setup_with_before_option
|
18
|
+
expected_setup_calls = [:custom_setup_method3,
|
19
|
+
:custom_setup_method0,
|
20
|
+
:custom_setup_method1,
|
21
|
+
:setup]
|
22
|
+
test_case = assert_setup(expected_setup_calls,
|
23
|
+
[[{:before => :append}],
|
24
|
+
[{:before => :append}],
|
25
|
+
[{:before => :prepend}],
|
26
|
+
[{:before => :prepend}]])
|
27
|
+
assert_inherited_setup(expected_setup_calls, test_case)
|
28
|
+
|
29
|
+
assert_inherited_setup([:setup], nil)
|
30
|
+
assert_called_fixtures(expected_setup_calls, test_case)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_setup_with_after_option
|
34
|
+
expected_setup_calls = [:setup,
|
35
|
+
:custom_setup_method3,
|
36
|
+
:custom_setup_method0,
|
37
|
+
:custom_setup_method1]
|
38
|
+
test_case = assert_setup(expected_setup_calls,
|
39
|
+
[[{:after => :append}],
|
40
|
+
[{:after => :append}],
|
41
|
+
[{:after => :prepend}],
|
42
|
+
[{:after => :prepend}]])
|
43
|
+
assert_inherited_setup(expected_setup_calls, test_case)
|
44
|
+
|
45
|
+
assert_inherited_setup([:setup], nil)
|
46
|
+
assert_called_fixtures(expected_setup_calls, test_case)
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_setup_with_invalid_option
|
50
|
+
assert_invalid_setup_option(:unknown => true)
|
51
|
+
assert_invalid_setup_option(:before => :unknown)
|
52
|
+
assert_invalid_setup_option(:after => :unknown)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_setup_with_option_to_inherited
|
56
|
+
expected_setup_calls = [:setup]
|
57
|
+
test_case = assert_setup(expected_setup_calls, nil)
|
58
|
+
assert_inherited_setup([:setup,
|
59
|
+
:custom_setup_method0,
|
60
|
+
:custom_setup_method1,
|
61
|
+
:custom_setup_method3],
|
62
|
+
test_case,
|
63
|
+
[])
|
64
|
+
|
65
|
+
assert_inherited_setup([:setup], nil)
|
66
|
+
assert_called_fixtures(expected_setup_calls, test_case)
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_teardown_without_option
|
70
|
+
expected_teardown_calls = [:custom_teardown_method3,
|
71
|
+
:custom_teardown_method1,
|
72
|
+
:custom_teardown_method0,
|
73
|
+
:teardown]
|
74
|
+
test_case = assert_teardown(expected_teardown_calls, [])
|
75
|
+
assert_inherited_teardown(expected_teardown_calls, test_case)
|
76
|
+
|
77
|
+
assert_inherited_teardown([:teardown], nil)
|
78
|
+
assert_called_fixtures(expected_teardown_calls, test_case)
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_teardown_with_before_option
|
82
|
+
expected_teardown_calls = [:custom_teardown_method3,
|
83
|
+
:custom_teardown_method0,
|
84
|
+
:custom_teardown_method1,
|
85
|
+
:teardown]
|
86
|
+
test_case = assert_teardown(expected_teardown_calls,
|
87
|
+
[[{:before => :append}],
|
88
|
+
[{:before => :append}],
|
89
|
+
[{:before => :prepend}],
|
90
|
+
[{:before => :prepend}]])
|
91
|
+
assert_inherited_teardown(expected_teardown_calls, test_case)
|
92
|
+
|
93
|
+
assert_inherited_teardown([:teardown], nil)
|
94
|
+
assert_called_fixtures(expected_teardown_calls, test_case)
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_teardown_with_after_option
|
98
|
+
expected_teardown_calls = [:teardown,
|
99
|
+
:custom_teardown_method3,
|
100
|
+
:custom_teardown_method0,
|
101
|
+
:custom_teardown_method1]
|
102
|
+
test_case = assert_teardown(expected_teardown_calls,
|
103
|
+
[[{:after => :append}],
|
104
|
+
[{:after => :append}],
|
105
|
+
[{:after => :prepend}],
|
106
|
+
[{:after => :prepend}]])
|
107
|
+
assert_inherited_teardown(expected_teardown_calls, test_case)
|
108
|
+
|
109
|
+
assert_inherited_teardown([:teardown], nil)
|
110
|
+
assert_called_fixtures(expected_teardown_calls, test_case)
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_teardown_with_invalid_option
|
114
|
+
assert_invalid_teardown_option(:unknown => true)
|
115
|
+
assert_invalid_teardown_option(:before => :unknown)
|
116
|
+
assert_invalid_teardown_option(:after => :unknown)
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_teardown_with_option_to_inherited
|
120
|
+
expected_teardown_calls = [:teardown]
|
121
|
+
test_case = assert_teardown(expected_teardown_calls, nil)
|
122
|
+
assert_inherited_teardown([:custom_teardown_method3,
|
123
|
+
:custom_teardown_method1,
|
124
|
+
:custom_teardown_method0,
|
125
|
+
:teardown],
|
126
|
+
test_case, [])
|
127
|
+
|
128
|
+
assert_inherited_teardown([:teardown], nil)
|
129
|
+
assert_called_fixtures(expected_teardown_calls, test_case)
|
130
|
+
end
|
131
|
+
|
132
|
+
private
|
133
|
+
def assert_called_fixtures(expected, test_case)
|
134
|
+
test = test_case.new("test_nothing")
|
135
|
+
test.run(Test::Unit::TestResult.new) {}
|
136
|
+
assert_equal(expected, test.called_ids)
|
137
|
+
end
|
138
|
+
|
139
|
+
def assert_setup_customizable(expected, parent, options)
|
140
|
+
test_case = Class.new(parent || Test::Unit::TestCase) do
|
141
|
+
yield(self, :before) if block_given?
|
142
|
+
|
143
|
+
def called_ids
|
144
|
+
@called_ids ||= []
|
145
|
+
end
|
146
|
+
|
147
|
+
def called(id)
|
148
|
+
called_ids << id
|
149
|
+
end
|
150
|
+
|
151
|
+
def setup
|
152
|
+
called(:setup)
|
153
|
+
end
|
154
|
+
|
155
|
+
setup(*(options[0] || [])) if options
|
156
|
+
def custom_setup_method0
|
157
|
+
called(:custom_setup_method0)
|
158
|
+
end
|
159
|
+
|
160
|
+
def custom_setup_method1
|
161
|
+
called(:custom_setup_method1)
|
162
|
+
end
|
163
|
+
setup(*[:custom_setup_method1, *(options[1] || [])]) if options
|
164
|
+
|
165
|
+
setup(*(options[2] || [])) if options
|
166
|
+
def custom_setup_method2
|
167
|
+
called(:custom_setup_method2)
|
168
|
+
end
|
169
|
+
unregister_setup(:custom_setup_method2) if options
|
170
|
+
|
171
|
+
setup(*(options[3] || [])) if options
|
172
|
+
def custom_setup_method3
|
173
|
+
called(:custom_setup_method3)
|
174
|
+
end
|
175
|
+
|
176
|
+
def test_nothing
|
177
|
+
end
|
178
|
+
|
179
|
+
yield(self, :after) if block_given?
|
180
|
+
end
|
181
|
+
|
182
|
+
assert_called_fixtures(expected, test_case)
|
183
|
+
test_case
|
184
|
+
end
|
185
|
+
|
186
|
+
def assert_setup(expected, options)
|
187
|
+
_test_case = assert_setup_customizable(expected, nil, options)
|
188
|
+
assert_setup_customizable(expected, nil, options) do |test_case, tag|
|
189
|
+
test_case.send(:include, EmptyModule) if tag == :before
|
190
|
+
end
|
191
|
+
_test_case
|
192
|
+
end
|
193
|
+
|
194
|
+
def assert_inherited_setup(expected, parent, options=nil)
|
195
|
+
_test_case = assert_setup_customizable(expected, parent, options)
|
196
|
+
assert_setup_customizable(expected, parent, options) do |test_case, tag|
|
197
|
+
test_case.send(:include, EmptyModule) if tag == :before
|
198
|
+
end
|
199
|
+
_test_case
|
200
|
+
end
|
201
|
+
|
202
|
+
def assert_teardown_customizable(expected, parent, options)
|
203
|
+
test_case = Class.new(parent || Test::Unit::TestCase) do
|
204
|
+
yield(self, :before) if block_given?
|
205
|
+
|
206
|
+
def called_ids
|
207
|
+
@called_ids ||= []
|
208
|
+
end
|
209
|
+
|
210
|
+
def called(id)
|
211
|
+
called_ids << id
|
212
|
+
end
|
213
|
+
|
214
|
+
def teardown
|
215
|
+
called(:teardown)
|
216
|
+
end
|
217
|
+
|
218
|
+
teardown(*(options[0] || [])) if options
|
219
|
+
def custom_teardown_method0
|
220
|
+
called(:custom_teardown_method0)
|
221
|
+
end
|
222
|
+
|
223
|
+
def custom_teardown_method1
|
224
|
+
called(:custom_teardown_method1)
|
225
|
+
end
|
226
|
+
teardown(*[:custom_teardown_method1, *(options[1] || [])]) if options
|
227
|
+
|
228
|
+
teardown(*(options[2] || [])) if options
|
229
|
+
def custom_teardown_method2
|
230
|
+
called(:custom_teardown_method2)
|
231
|
+
end
|
232
|
+
unregister_teardown(:custom_teardown_method2) if options
|
233
|
+
|
234
|
+
teardown(*(options[3] || [])) if options
|
235
|
+
def custom_teardown_method3
|
236
|
+
called(:custom_teardown_method3)
|
237
|
+
end
|
238
|
+
|
239
|
+
def test_nothing
|
240
|
+
end
|
241
|
+
|
242
|
+
yield(self, :after) if block_given?
|
243
|
+
end
|
244
|
+
|
245
|
+
assert_called_fixtures(expected, test_case)
|
246
|
+
test_case
|
247
|
+
end
|
248
|
+
|
249
|
+
def assert_teardown(expected, options)
|
250
|
+
assert_teardown_customizable(expected, nil, options)
|
251
|
+
assert_teardown_customizable(expected, nil, options) do |test_case, tag|
|
252
|
+
test_case.send(:include, EmptyModule) if tag == :before
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
def assert_inherited_teardown(expected, parent, options=nil)
|
257
|
+
assert_teardown_customizable(expected, parent, options)
|
258
|
+
assert_teardown_customizable(expected, parent, options) do |test_case, tag|
|
259
|
+
test_case.send(:include, EmptyModule) if tag == :before
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
def assert_invalid_option(fixture_type, option)
|
264
|
+
exception = assert_raise(ArgumentError) do
|
265
|
+
Class.new(Test::Unit::TestCase) do
|
266
|
+
def test_nothing
|
267
|
+
end
|
268
|
+
|
269
|
+
send(fixture_type, option)
|
270
|
+
def fixture
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
274
|
+
assert_equal("must be {:before => :prepend}, {:before => :append}, " +
|
275
|
+
"{:after => :prepend} or {:after => :append}" +
|
276
|
+
": #{option.inspect}",
|
277
|
+
exception.message)
|
278
|
+
end
|
279
|
+
|
280
|
+
def assert_invalid_setup_option(option)
|
281
|
+
assert_invalid_option(:setup, option)
|
282
|
+
end
|
283
|
+
|
284
|
+
def assert_invalid_teardown_option(option)
|
285
|
+
assert_invalid_option(:teardown, option)
|
286
|
+
end
|
287
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'test/unit'
|
2
|
-
require '
|
2
|
+
require 'testunit-test-util'
|
3
3
|
|
4
|
-
class
|
4
|
+
class TestUnitNotification < Test::Unit::TestCase
|
5
5
|
include TestUnitTestUtil
|
6
6
|
|
7
7
|
class TestCase < Test::Unit::TestCase
|
@@ -18,7 +18,7 @@ class TestNotification < Test::Unit::TestCase
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_notify
|
21
|
-
result =
|
21
|
+
result = _run_test("test_notify")
|
22
22
|
assert_equal("1 tests, 0 assertions, 0 failures, 0 errors, 0 pendings, " \
|
23
23
|
"0 omissions, 2 notifications",
|
24
24
|
result.to_s)
|
@@ -27,7 +27,7 @@ class TestNotification < Test::Unit::TestCase
|
|
27
27
|
end
|
28
28
|
|
29
29
|
private
|
30
|
-
def
|
30
|
+
def _run_test(name)
|
31
31
|
super(TestCase, name)
|
32
32
|
end
|
33
33
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'test/unit'
|
2
|
-
require '
|
2
|
+
require 'testunit-test-util'
|
3
3
|
|
4
4
|
class TestUnitOmission < Test::Unit::TestCase
|
5
5
|
include TestUnitTestUtil
|
@@ -43,7 +43,7 @@ class TestUnitOmission < Test::Unit::TestCase
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def test_omit
|
46
|
-
result =
|
46
|
+
result = _run_test("test_omit")
|
47
47
|
assert_equal("1 tests, 0 assertions, 0 failures, 0 errors, 0 pendings, " \
|
48
48
|
"1 omissions, 0 notifications",
|
49
49
|
result.to_s)
|
@@ -51,7 +51,7 @@ class TestUnitOmission < Test::Unit::TestCase
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def test_omit_with_condition
|
54
|
-
result =
|
54
|
+
result = _run_test("test_omit_with_condition")
|
55
55
|
assert_equal("1 tests, 0 assertions, 0 failures, 0 errors, 0 pendings, " \
|
56
56
|
"1 omissions, 0 notifications",
|
57
57
|
result.to_s)
|
@@ -59,7 +59,7 @@ class TestUnitOmission < Test::Unit::TestCase
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def test_omit_with_block
|
62
|
-
result =
|
62
|
+
result = _run_test("test_omit_with_block")
|
63
63
|
assert_equal("1 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, " \
|
64
64
|
"1 omissions, 0 notifications",
|
65
65
|
result.to_s)
|
@@ -67,7 +67,7 @@ class TestUnitOmission < Test::Unit::TestCase
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def test_omit_with_condition_and_block
|
70
|
-
result =
|
70
|
+
result = _run_test("test_omit_with_block_and_condition")
|
71
71
|
assert_equal("1 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, " \
|
72
72
|
"1 omissions, 0 notifications",
|
73
73
|
result.to_s)
|
@@ -75,7 +75,7 @@ class TestUnitOmission < Test::Unit::TestCase
|
|
75
75
|
end
|
76
76
|
|
77
77
|
private
|
78
|
-
def
|
78
|
+
def _run_test(name)
|
79
79
|
super(TestCase, name)
|
80
80
|
end
|
81
81
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'test/unit'
|
2
|
-
require '
|
2
|
+
require 'testunit-test-util'
|
3
3
|
|
4
4
|
class TestUnitPending < Test::Unit::TestCase
|
5
5
|
include TestUnitTestUtil
|
@@ -33,32 +33,38 @@ class TestUnitPending < Test::Unit::TestCase
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_pend
|
36
|
-
|
36
|
+
test = nil
|
37
|
+
result = _run_test("test_pend") {|t| test = t}
|
37
38
|
assert_equal("1 tests, 0 assertions, 0 failures, 0 errors, 1 pendings, " \
|
38
39
|
"0 omissions, 0 notifications",
|
39
40
|
result.to_s)
|
40
41
|
assert_fault_messages(["1st pend"], result.pendings)
|
42
|
+
assert_true(test.interrupted?)
|
41
43
|
end
|
42
44
|
|
43
45
|
def test_pend_with_failure_in_block
|
44
|
-
|
46
|
+
test = nil
|
47
|
+
result = _run_test("test_pend_with_failure_in_block") {|t| test = t}
|
45
48
|
assert_equal("1 tests, 1 assertions, 0 failures, 0 errors, 1 pendings, " \
|
46
49
|
"0 omissions, 0 notifications",
|
47
50
|
result.to_s)
|
48
51
|
assert_fault_messages(["Wait a minute"], result.pendings)
|
52
|
+
assert_false(test.interrupted?)
|
49
53
|
end
|
50
54
|
|
51
55
|
def test_pend_with_no_failure_in_block
|
52
|
-
|
56
|
+
test = nil
|
57
|
+
result = _run_test("test_pend_with_no_failure_in_block") {|t| test = t}
|
53
58
|
assert_equal("1 tests, 1 assertions, 1 failures, 0 errors, 0 pendings, " \
|
54
59
|
"0 omissions, 0 notifications",
|
55
60
|
result.to_s)
|
56
61
|
assert_fault_messages(["Pending block should not be passed: Wait a minute."],
|
57
62
|
result.failures)
|
63
|
+
assert_true(test.interrupted?)
|
58
64
|
end
|
59
65
|
|
60
66
|
private
|
61
|
-
def
|
62
|
-
super(TestCase, name)
|
67
|
+
def _run_test(name, &block)
|
68
|
+
super(TestCase, name, &block)
|
63
69
|
end
|
64
70
|
end
|
@@ -86,4 +86,34 @@ class TestUnitPriority < Test::Unit::TestCase
|
|
86
86
|
end
|
87
87
|
assert_in_delta(expected, n_need_to_run.to_f / n, delta)
|
88
88
|
end
|
89
|
+
|
90
|
+
class SpecialNameTestCase < Test::Unit::TestCase
|
91
|
+
class << self
|
92
|
+
def suite
|
93
|
+
Test::Unit::TestSuite.new(name)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_question?
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_exclamation!
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_equal=
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_escaped?
|
108
|
+
assert_escaped_name("test_question.predicate", "test_question?")
|
109
|
+
assert_escaped_name("test_exclamation.destructive", "test_exclamation!")
|
110
|
+
assert_escaped_name("test_equal.equal", "test_equal=")
|
111
|
+
end
|
112
|
+
|
113
|
+
def assert_escaped_name(expected, test_method_name)
|
114
|
+
checker = Checker.new(SpecialNameTestCase.new(test_method_name))
|
115
|
+
passed_file = checker.send(:passed_file)
|
116
|
+
method_name_component = File.basename(File.dirname(passed_file))
|
117
|
+
assert_equal(expected, method_name_component)
|
118
|
+
end
|
89
119
|
end
|
@@ -6,7 +6,7 @@ require 'test/unit'
|
|
6
6
|
|
7
7
|
module Test
|
8
8
|
module Unit
|
9
|
-
class
|
9
|
+
class TestTestCase < TestCase
|
10
10
|
def test_creation
|
11
11
|
tc = Class.new(TestCase) do
|
12
12
|
def test_with_arguments(arg1, arg2)
|
@@ -267,7 +267,7 @@ module Test
|
|
267
267
|
def test_re_raise_exception
|
268
268
|
test_case = Class.new(TestCase) do
|
269
269
|
def test_raise_interrupt
|
270
|
-
raise Interrupt
|
270
|
+
raise Interrupt, "from test"
|
271
271
|
end
|
272
272
|
end
|
273
273
|
|
@@ -342,7 +342,7 @@ module Test
|
|
342
342
|
test_case = Class.new(TestCase) do
|
343
343
|
class << self
|
344
344
|
def startup
|
345
|
-
raise Interrupt
|
345
|
+
raise Interrupt, "from startup"
|
346
346
|
end
|
347
347
|
end
|
348
348
|
|
@@ -383,7 +383,7 @@ module Test
|
|
383
383
|
test_case = Class.new(TestCase) do
|
384
384
|
class << self
|
385
385
|
def shutdown
|
386
|
-
raise Interrupt
|
386
|
+
raise Interrupt, "from shutdown"
|
387
387
|
end
|
388
388
|
end
|
389
389
|
|
@@ -401,11 +401,107 @@ module Test
|
|
401
401
|
end
|
402
402
|
end
|
403
403
|
|
404
|
+
def test_interrupted
|
405
|
+
test_case = Class.new(TestCase) do
|
406
|
+
def test_fail
|
407
|
+
flunk
|
408
|
+
end
|
409
|
+
|
410
|
+
def test_nothing
|
411
|
+
end
|
412
|
+
end
|
413
|
+
|
414
|
+
failed_test = test_case.new(:test_fail)
|
415
|
+
failed_test.run(TestResult.new) {}
|
416
|
+
check("Should be interrupted", failed_test.interrupted?)
|
417
|
+
|
418
|
+
success_test = test_case.new(:test_nothing)
|
419
|
+
success_test.run(TestResult.new) {}
|
420
|
+
check("Should not be interrupted", !success_test.interrupted?)
|
421
|
+
end
|
422
|
+
|
423
|
+
def test_inherited_test_should_be_ignored
|
424
|
+
test_case = Class.new(TestCase) do
|
425
|
+
def test_nothing
|
426
|
+
end
|
427
|
+
end
|
428
|
+
|
429
|
+
sub_test_case = Class.new(test_case) do
|
430
|
+
def test_fail
|
431
|
+
flunk
|
432
|
+
end
|
433
|
+
end
|
434
|
+
|
435
|
+
assert_nothing_thrown do
|
436
|
+
test_case.new("test_nothing")
|
437
|
+
end
|
438
|
+
|
439
|
+
assert_nothing_thrown do
|
440
|
+
sub_test_case.new("test_fail")
|
441
|
+
end
|
442
|
+
|
443
|
+
assert_throw(:invalid_test) do
|
444
|
+
sub_test_case.new("test_nothing")
|
445
|
+
end
|
446
|
+
end
|
447
|
+
|
448
|
+
def test_mixin_test_should_not_be_ignored
|
449
|
+
test_module = Module.new do
|
450
|
+
def test_nothing
|
451
|
+
end
|
452
|
+
end
|
453
|
+
|
454
|
+
test_case = Class.new(Test::Unit::TestCase) do
|
455
|
+
include test_module
|
456
|
+
|
457
|
+
def test_fail
|
458
|
+
flunk
|
459
|
+
end
|
460
|
+
end
|
461
|
+
|
462
|
+
assert_nothing_thrown do
|
463
|
+
test_case.new("test_nothing")
|
464
|
+
end
|
465
|
+
|
466
|
+
assert_nothing_thrown do
|
467
|
+
test_case.new("test_fail")
|
468
|
+
end
|
469
|
+
end
|
470
|
+
|
471
|
+
def test_defined_order
|
472
|
+
keep_test_order do
|
473
|
+
test_case = Class.new(Test::Unit::TestCase) do
|
474
|
+
def test_z
|
475
|
+
end
|
476
|
+
|
477
|
+
def test_1
|
478
|
+
end
|
479
|
+
|
480
|
+
def test_a
|
481
|
+
end
|
482
|
+
end
|
483
|
+
|
484
|
+
assert_equal(["test_1", "test_a", "test_z"],
|
485
|
+
test_case.suite.tests.collect {|test| test.method_name})
|
486
|
+
|
487
|
+
test_case.test_order = :defined
|
488
|
+
assert_equal(["test_z", "test_1", "test_a"],
|
489
|
+
test_case.suite.tests.collect {|test| test.method_name})
|
490
|
+
end
|
491
|
+
end
|
492
|
+
|
404
493
|
private
|
405
494
|
def check(message, passed)
|
406
495
|
add_assertion
|
407
496
|
raise AssertionFailedError.new(message) unless passed
|
408
497
|
end
|
498
|
+
|
499
|
+
def keep_test_order
|
500
|
+
order = TestCase.test_order
|
501
|
+
yield
|
502
|
+
ensure
|
503
|
+
TestCase.test_order = order
|
504
|
+
end
|
409
505
|
end
|
410
506
|
end
|
411
507
|
end
|