activesambaldap 0.0.6 → 0.0.7
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/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
@@ -1,7 +1,9 @@
|
|
1
1
|
#--
|
2
2
|
#
|
3
3
|
# Author:: Nathaniel Talbott.
|
4
|
-
# Copyright::
|
4
|
+
# Copyright::
|
5
|
+
# * Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved.
|
6
|
+
# * Copyright (c) 2008-2009 Kouhei Sutou <tt><kou@clear-code.com></tt>
|
5
7
|
# License:: Ruby license.
|
6
8
|
|
7
9
|
require 'test/unit/attribute'
|
@@ -17,6 +19,7 @@ require 'test/unit/priority'
|
|
17
19
|
require 'test/unit/testsuite'
|
18
20
|
require 'test/unit/assertionfailederror'
|
19
21
|
require 'test/unit/util/backtracefilter'
|
22
|
+
require 'test/unit/util/method-owner-finder'
|
20
23
|
|
21
24
|
module Test
|
22
25
|
module Unit
|
@@ -26,6 +29,47 @@ module Test
|
|
26
29
|
# wrapping those tests into a suite. It also does the
|
27
30
|
# nitty-gritty of actually running an individual test and
|
28
31
|
# collecting its results into a Test::Unit::TestResult object.
|
32
|
+
#
|
33
|
+
# You can run two hooks before/after a TestCase run.
|
34
|
+
#
|
35
|
+
# Example:
|
36
|
+
# class TestMyClass < Test::Unit::TestCase
|
37
|
+
# class << self
|
38
|
+
# def startup
|
39
|
+
# ...
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
# def shutdown
|
43
|
+
# ...
|
44
|
+
# end
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
# def setup
|
48
|
+
# ...
|
49
|
+
# end
|
50
|
+
#
|
51
|
+
# def teardown
|
52
|
+
# ...
|
53
|
+
# end
|
54
|
+
#
|
55
|
+
# def test_my_method1
|
56
|
+
# ...
|
57
|
+
# end
|
58
|
+
#
|
59
|
+
# def test_my_method2
|
60
|
+
# ...
|
61
|
+
# end
|
62
|
+
# end
|
63
|
+
#
|
64
|
+
# Here is a call order:
|
65
|
+
# * startup
|
66
|
+
# * setup
|
67
|
+
# * test_my_method1
|
68
|
+
# * teardown
|
69
|
+
# * setup
|
70
|
+
# * test_my_method2
|
71
|
+
# * teardown
|
72
|
+
# * shutdown
|
29
73
|
class TestCase
|
30
74
|
include Attribute
|
31
75
|
include Fixture
|
@@ -39,24 +83,29 @@ module Test
|
|
39
83
|
include Assertions
|
40
84
|
include Util::BacktraceFilter
|
41
85
|
|
42
|
-
STARTED = name + "::STARTED"
|
43
|
-
FINISHED = name + "::FINISHED"
|
86
|
+
STARTED = name + "::STARTED" # :nodoc:
|
87
|
+
FINISHED = name + "::FINISHED" # :nodoc:
|
44
88
|
|
45
|
-
DESCENDANTS = []
|
89
|
+
DESCENDANTS = [] # :nodoc:
|
90
|
+
AVAILABLE_ORDERS = [:alphabetic, :random, :defined] # :nodoc:
|
46
91
|
|
47
92
|
class << self
|
48
|
-
def inherited(sub_class)
|
93
|
+
def inherited(sub_class) # :nodoc:
|
49
94
|
DESCENDANTS << sub_class
|
50
95
|
end
|
51
96
|
|
97
|
+
@@added_methods = []
|
98
|
+
def method_added(name) # :nodoc:
|
99
|
+
super
|
100
|
+
@@added_methods << name.to_s
|
101
|
+
end
|
102
|
+
|
52
103
|
# Rolls up all of the test* methods in the fixture into
|
53
104
|
# one suite, creating a new instance of the fixture for
|
54
105
|
# each method.
|
55
106
|
def suite
|
56
|
-
method_names = public_instance_methods(true).collect {|name| name.to_s}
|
57
|
-
tests = method_names.delete_if {|method_name| method_name !~ /^test./}
|
58
107
|
suite = TestSuite.new(name, self)
|
59
|
-
|
108
|
+
collect_test_names.each do |test|
|
60
109
|
catch(:invalid_test) do
|
61
110
|
suite << new(test)
|
62
111
|
end
|
@@ -68,6 +117,137 @@ module Test
|
|
68
117
|
end
|
69
118
|
suite
|
70
119
|
end
|
120
|
+
|
121
|
+
# Called before every test case runs. Can be used
|
122
|
+
# to set up fixture information used in test case
|
123
|
+
# scope.
|
124
|
+
#
|
125
|
+
# Here is an example test case:
|
126
|
+
# class TestMyClass < Test::Unit::TestCase
|
127
|
+
# class << self
|
128
|
+
# def startup
|
129
|
+
# ...
|
130
|
+
# end
|
131
|
+
# end
|
132
|
+
#
|
133
|
+
# def setup
|
134
|
+
# ...
|
135
|
+
# end
|
136
|
+
#
|
137
|
+
# def test_my_class1
|
138
|
+
# ...
|
139
|
+
# end
|
140
|
+
#
|
141
|
+
# def test_my_class2
|
142
|
+
# ...
|
143
|
+
# end
|
144
|
+
# end
|
145
|
+
#
|
146
|
+
# Here is a call order:
|
147
|
+
# * startup
|
148
|
+
# * setup
|
149
|
+
# * test_my_class1 (or test_my_class2)
|
150
|
+
# * setup
|
151
|
+
# * test_my_class2 (or test_my_class1)
|
152
|
+
#
|
153
|
+
# Note that you should not assume test order. Tests
|
154
|
+
# should be worked in any order.
|
155
|
+
def startup
|
156
|
+
end
|
157
|
+
|
158
|
+
# Called after every test case runs. Can be used to tear
|
159
|
+
# down fixture information used in test case scope.
|
160
|
+
#
|
161
|
+
# Here is an example test case:
|
162
|
+
# class TestMyClass < Test::Unit::TestCase
|
163
|
+
# class << self
|
164
|
+
# def shutdown
|
165
|
+
# ...
|
166
|
+
# end
|
167
|
+
# end
|
168
|
+
#
|
169
|
+
# def teardown
|
170
|
+
# ...
|
171
|
+
# end
|
172
|
+
#
|
173
|
+
# def test_my_class1
|
174
|
+
# ...
|
175
|
+
# end
|
176
|
+
#
|
177
|
+
# def test_my_class2
|
178
|
+
# ...
|
179
|
+
# end
|
180
|
+
# end
|
181
|
+
#
|
182
|
+
# Here is a call order:
|
183
|
+
# * test_my_class1 (or test_my_class2)
|
184
|
+
# * teardown
|
185
|
+
# * test_my_class2 (or test_my_class1)
|
186
|
+
# * teardown
|
187
|
+
# * shutdown
|
188
|
+
#
|
189
|
+
# Note that you should not assume test order. Tests
|
190
|
+
# should be worked in any order.
|
191
|
+
def shutdown
|
192
|
+
end
|
193
|
+
|
194
|
+
@@test_order = AVAILABLE_ORDERS.first
|
195
|
+
|
196
|
+
# Returns the current test order. This returns
|
197
|
+
# +:alphabetic+ by default.
|
198
|
+
def test_order
|
199
|
+
@@test_order
|
200
|
+
end
|
201
|
+
|
202
|
+
# Sets the current test order.
|
203
|
+
#
|
204
|
+
# Here are the available _order_:
|
205
|
+
# [:alphabetic]
|
206
|
+
# Default. Tests are sorted in alphabetic order.
|
207
|
+
# [:random]
|
208
|
+
# Tests are sorted in random order.
|
209
|
+
# [:defined]
|
210
|
+
# Tests are sorted in defined order.
|
211
|
+
def test_order=(order)
|
212
|
+
@@test_order = order
|
213
|
+
end
|
214
|
+
|
215
|
+
# :stopdoc:
|
216
|
+
private
|
217
|
+
def collect_test_names
|
218
|
+
method_names = public_instance_methods(true).collect do |name|
|
219
|
+
name.to_s
|
220
|
+
end
|
221
|
+
test_names = method_names.find_all do |method_name|
|
222
|
+
method_name =~ /^test./
|
223
|
+
end
|
224
|
+
send("sort_test_names_in_#{test_order}_order", test_names)
|
225
|
+
end
|
226
|
+
|
227
|
+
def sort_test_names_in_alphabetic_order(test_names)
|
228
|
+
test_names.sort
|
229
|
+
end
|
230
|
+
|
231
|
+
def sort_test_names_in_random_order(test_names)
|
232
|
+
test_names.sort_by {rand(test_names.size)}
|
233
|
+
end
|
234
|
+
|
235
|
+
def sort_test_names_in_defined_order(test_names)
|
236
|
+
test_names.sort do |test1, test2|
|
237
|
+
test1_defined_order = @@added_methods.index(test1)
|
238
|
+
test2_defined_order = @@added_methods.index(test2)
|
239
|
+
if test1_defined_order and test2_defined_order
|
240
|
+
test1_defined_order <=> test2_defined_order
|
241
|
+
elsif test1_defined_order
|
242
|
+
1
|
243
|
+
elsif test2_defined_order
|
244
|
+
-1
|
245
|
+
else
|
246
|
+
test1 <=> test2
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
250
|
+
# :startdoc:
|
71
251
|
end
|
72
252
|
|
73
253
|
attr_reader :method_name
|
@@ -76,9 +256,15 @@ module Test
|
|
76
256
|
# test represented by test_method_name.
|
77
257
|
def initialize(test_method_name)
|
78
258
|
throw :invalid_test unless respond_to?(test_method_name)
|
79
|
-
|
259
|
+
test_method = method(test_method_name)
|
260
|
+
throw :invalid_test if test_method.arity > 0
|
261
|
+
owner = Util::MethodOwnerFinder.find(self, test_method_name)
|
262
|
+
if owner.class != Module and self.class != owner
|
263
|
+
throw :invalid_test
|
264
|
+
end
|
80
265
|
@method_name = test_method_name
|
81
266
|
@test_passed = true
|
267
|
+
@interrupted = false
|
82
268
|
end
|
83
269
|
|
84
270
|
# Runs the individual test method represented by this
|
@@ -90,8 +276,9 @@ module Test
|
|
90
276
|
yield(STARTED, name)
|
91
277
|
begin
|
92
278
|
run_setup
|
93
|
-
|
279
|
+
run_test
|
94
280
|
rescue Exception
|
281
|
+
@interrupted = true
|
95
282
|
raise unless handle_exception($!)
|
96
283
|
ensure
|
97
284
|
begin
|
@@ -103,20 +290,76 @@ module Test
|
|
103
290
|
result.add_run
|
104
291
|
yield(FINISHED, name)
|
105
292
|
ensure
|
106
|
-
@_result = nil
|
293
|
+
# @_result = nil # For test-spec's after_all :<
|
107
294
|
end
|
108
295
|
end
|
109
296
|
|
110
297
|
# Called before every test method runs. Can be used
|
111
298
|
# to set up fixture information.
|
299
|
+
#
|
300
|
+
# You can add additional setup tasks by the following
|
301
|
+
# code:
|
302
|
+
# class TestMyClass < Test::Unit::TestCase
|
303
|
+
# def setup
|
304
|
+
# ...
|
305
|
+
# end
|
306
|
+
#
|
307
|
+
# setup
|
308
|
+
# def my_setup1
|
309
|
+
# ...
|
310
|
+
# end
|
311
|
+
#
|
312
|
+
# setup
|
313
|
+
# def my_setup2
|
314
|
+
# ...
|
315
|
+
# end
|
316
|
+
#
|
317
|
+
# def test_my_class
|
318
|
+
# ...
|
319
|
+
# end
|
320
|
+
# end
|
321
|
+
#
|
322
|
+
# Here is a call order:
|
323
|
+
# * setup
|
324
|
+
# * my_setup1
|
325
|
+
# * my_setup2
|
326
|
+
# * test_my_class
|
112
327
|
def setup
|
113
328
|
end
|
114
329
|
|
115
330
|
# Called after every test method runs. Can be used to tear
|
116
331
|
# down fixture information.
|
332
|
+
#
|
333
|
+
# You can add additional teardown tasks by the following
|
334
|
+
# code:
|
335
|
+
# class TestMyClass < Test::Unit::TestCase
|
336
|
+
# def teardown
|
337
|
+
# ...
|
338
|
+
# end
|
339
|
+
#
|
340
|
+
# teardown
|
341
|
+
# def my_teardown1
|
342
|
+
# ...
|
343
|
+
# end
|
344
|
+
#
|
345
|
+
# teardown
|
346
|
+
# def my_teardown2
|
347
|
+
# ...
|
348
|
+
# end
|
349
|
+
#
|
350
|
+
# def test_my_class
|
351
|
+
# ...
|
352
|
+
# end
|
353
|
+
# end
|
354
|
+
#
|
355
|
+
# Here is a call order:
|
356
|
+
# * test_my_class
|
357
|
+
# * my_teardown2
|
358
|
+
# * my_teardown1
|
359
|
+
# * teardown
|
117
360
|
def teardown
|
118
361
|
end
|
119
|
-
|
362
|
+
|
120
363
|
def default_test
|
121
364
|
flunk("No tests were specified")
|
122
365
|
end
|
@@ -143,11 +386,19 @@ module Test
|
|
143
386
|
self.class == other.class
|
144
387
|
end
|
145
388
|
|
389
|
+
def interrupted?
|
390
|
+
@interrupted
|
391
|
+
end
|
392
|
+
|
146
393
|
private
|
147
394
|
def current_result
|
148
395
|
@_result
|
149
396
|
end
|
150
397
|
|
398
|
+
def run_test
|
399
|
+
__send__(@method_name)
|
400
|
+
end
|
401
|
+
|
151
402
|
def handle_exception(exception)
|
152
403
|
self.class.exception_handlers.each do |handler|
|
153
404
|
return true if send(handler, exception)
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved.
|
5
5
|
# License:: Ruby license.
|
6
6
|
|
7
|
-
require 'test/unit/color'
|
7
|
+
require 'test/unit/color-scheme'
|
8
8
|
require 'test/unit/ui/testrunner'
|
9
9
|
require 'test/unit/ui/testrunnermediator'
|
10
10
|
require 'test/unit/ui/console/outputlevel'
|
@@ -18,17 +18,6 @@ module Test
|
|
18
18
|
class TestRunner < UI::TestRunner
|
19
19
|
include OutputLevel
|
20
20
|
|
21
|
-
COLOR_SCHEMES = {
|
22
|
-
:default => {
|
23
|
-
"success" => Color.new("green", :bold => true),
|
24
|
-
"failure" => Color.new("red", :bold => true),
|
25
|
-
"pending" => Color.new("magenta", :bold => true),
|
26
|
-
"omission" => Color.new("blue", :bold => true),
|
27
|
-
"notification" => Color.new("cyan", :bold => true),
|
28
|
-
"error" => Color.new("yellow", :bold => true),
|
29
|
-
},
|
30
|
-
}
|
31
|
-
|
32
21
|
# Creates a new TestRunner for running the passed
|
33
22
|
# suite. If quiet_mode is true, the output while
|
34
23
|
# running is limited to progress dots, errors and
|
@@ -41,8 +30,11 @@ module Test
|
|
41
30
|
@output = @options[:output] || STDOUT
|
42
31
|
@use_color = @options[:use_color]
|
43
32
|
@use_color = guess_color_availability if @use_color.nil?
|
44
|
-
@color_scheme =
|
33
|
+
@color_scheme = @options[:color_scheme] || ColorScheme.default
|
45
34
|
@reset_color = Color.new("reset")
|
35
|
+
@progress_row = 0
|
36
|
+
@progress_row_max = @options[:progress_row_max]
|
37
|
+
@progress_row_max ||= guess_progress_row_max
|
46
38
|
@already_outputted = false
|
47
39
|
@faults = []
|
48
40
|
end
|
@@ -84,9 +76,7 @@ module Test
|
|
84
76
|
|
85
77
|
def add_fault(fault)
|
86
78
|
@faults << fault
|
87
|
-
|
88
|
-
fault_color(fault),
|
89
|
-
PROGRESS_ONLY)
|
79
|
+
output_progress(fault.single_character_display, fault_color(fault))
|
90
80
|
@already_outputted = true
|
91
81
|
end
|
92
82
|
|
@@ -124,7 +114,7 @@ module Test
|
|
124
114
|
|
125
115
|
def test_finished(name)
|
126
116
|
unless @already_outputted
|
127
|
-
|
117
|
+
output_progress(".", color("success"))
|
128
118
|
end
|
129
119
|
nl(VERBOSE)
|
130
120
|
@already_outputted = false
|
@@ -141,7 +131,7 @@ module Test
|
|
141
131
|
end
|
142
132
|
|
143
133
|
def output_single(something, color=nil, level=NORMAL)
|
144
|
-
return unless output?(level)
|
134
|
+
return false unless output?(level)
|
145
135
|
if @use_color and color
|
146
136
|
something = "%s%s%s" % [color.escape_sequence,
|
147
137
|
something,
|
@@ -149,40 +139,78 @@ module Test
|
|
149
139
|
end
|
150
140
|
@output.write(something)
|
151
141
|
@output.flush
|
142
|
+
true
|
152
143
|
end
|
153
|
-
|
144
|
+
|
145
|
+
def output_progress(mark, color=nil)
|
146
|
+
if output_single(mark, color, PROGRESS_ONLY)
|
147
|
+
return unless @progress_row_max > 0
|
148
|
+
@progress_row += mark.size
|
149
|
+
if @progress_row >= @progress_row_max
|
150
|
+
nl unless @output_level == VERBOSE
|
151
|
+
@progress_row = 0
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
154
156
|
def output?(level)
|
155
157
|
level <= @output_level
|
156
158
|
end
|
157
159
|
|
160
|
+
def color(name)
|
161
|
+
@color_scheme[name] || ColorScheme.default[name]
|
162
|
+
end
|
163
|
+
|
158
164
|
def fault_color(fault)
|
159
|
-
|
165
|
+
color(fault.class.name.split(/::/).last.downcase)
|
160
166
|
end
|
161
167
|
|
162
168
|
def result_color
|
163
169
|
if @result.passed?
|
164
170
|
if @result.pending_count > 0
|
165
|
-
|
171
|
+
color("pending")
|
166
172
|
elsif @result.omission_count > 0
|
167
|
-
|
173
|
+
color("omission")
|
168
174
|
elsif @result.notification_count > 0
|
169
|
-
|
175
|
+
color("notification")
|
170
176
|
else
|
171
|
-
|
177
|
+
color("success")
|
172
178
|
end
|
173
179
|
elsif @result.error_count > 0
|
174
|
-
|
180
|
+
color("error")
|
175
181
|
elsif @result.failure_count > 0
|
176
|
-
|
182
|
+
color("failure")
|
177
183
|
end
|
178
184
|
end
|
179
185
|
|
180
186
|
def guess_color_availability
|
181
187
|
return false unless @output.tty?
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
188
|
+
case ENV["TERM"]
|
189
|
+
when /term(?:-color)?\z/, "screen"
|
190
|
+
true
|
191
|
+
else
|
192
|
+
return true if ENV["EMACS"] == "t"
|
193
|
+
false
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
def guess_progress_row_max
|
198
|
+
term_width = guess_term_width
|
199
|
+
if term_width.zero?
|
200
|
+
if ENV["EMACS"] == "t"
|
201
|
+
-1
|
202
|
+
else
|
203
|
+
79
|
204
|
+
end
|
205
|
+
else
|
206
|
+
term_width
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
def guess_term_width
|
211
|
+
Integer(ENV["TERM_WIDTH"] || 0)
|
212
|
+
rescue ArgumentError
|
213
|
+
0
|
186
214
|
end
|
187
215
|
end
|
188
216
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Test
|
2
|
+
module Unit
|
3
|
+
module Util
|
4
|
+
module MethodOwnerFinder
|
5
|
+
module_function
|
6
|
+
def find(object, method_name)
|
7
|
+
method = object.method(method_name)
|
8
|
+
return method.owner if method.respond_to?(:owner)
|
9
|
+
|
10
|
+
if /\((.+?)\)\#/ =~ method.to_s
|
11
|
+
owner_name = $1
|
12
|
+
if /\A#</ =~ owner_name
|
13
|
+
ObjectSpace.each_object(Module) do |mod|
|
14
|
+
return mod if mod.to_s == owner_name
|
15
|
+
end
|
16
|
+
else
|
17
|
+
owner_name.split(/::/).inject(Object) do |parent, name|
|
18
|
+
parent.const_get(name)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
else
|
22
|
+
object.class
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/test-unit/lib/test/unit.rb
CHANGED
@@ -253,6 +253,68 @@ module Test # :nodoc:
|
|
253
253
|
# the dynamic suite using the console TestRunner.
|
254
254
|
#
|
255
255
|
#
|
256
|
+
# == Configuration file
|
257
|
+
#
|
258
|
+
# Test::Unit reads 'test-unit.yml' in the current working
|
259
|
+
# directory as Test::Unit's configuration file. It can
|
260
|
+
# contain the following configurations:
|
261
|
+
#
|
262
|
+
# * color scheme definitions
|
263
|
+
# * test runner to be used
|
264
|
+
# * test runner options
|
265
|
+
# * test collector to be used
|
266
|
+
#
|
267
|
+
# Except color scheme definitions, all of them are
|
268
|
+
# specified by command line option.
|
269
|
+
#
|
270
|
+
# Here are sample color scheme definitions:
|
271
|
+
#
|
272
|
+
# color_schemes:
|
273
|
+
# inverted:
|
274
|
+
# success:
|
275
|
+
# name: red
|
276
|
+
# bold: true
|
277
|
+
# failure:
|
278
|
+
# name: green
|
279
|
+
# bold: true
|
280
|
+
# other_scheme:
|
281
|
+
# ...
|
282
|
+
#
|
283
|
+
# Here are the syntax of color scheme definitions:
|
284
|
+
#
|
285
|
+
# color_schemes:
|
286
|
+
# SCHEME_NAME:
|
287
|
+
# EVENT_NAME:
|
288
|
+
# name: COLOR_NAME
|
289
|
+
# intensity: BOOLEAN
|
290
|
+
# bold: BOOLEAN
|
291
|
+
# italic: BOOLEAN
|
292
|
+
# underline: BOOLEAN
|
293
|
+
# ...
|
294
|
+
# ...
|
295
|
+
#
|
296
|
+
# SCHEME_NAME:: the name of the color scheme
|
297
|
+
# EVENT_NAME:: one of [success, failure, pending,
|
298
|
+
# omission, notification, error]
|
299
|
+
# COLOR_NAME:: one of [black, red, green, yellow, blue,
|
300
|
+
# magenta, cyan, white]
|
301
|
+
# BOOLEAN:: true or false
|
302
|
+
#
|
303
|
+
# You can use the above 'inverted' color scheme with the
|
304
|
+
# following configuration:
|
305
|
+
#
|
306
|
+
# runner: console
|
307
|
+
# console_options:
|
308
|
+
# color_scheme: inverted
|
309
|
+
# color_schemes:
|
310
|
+
# inverted:
|
311
|
+
# success:
|
312
|
+
# name: red
|
313
|
+
# bold: true
|
314
|
+
# failure:
|
315
|
+
# name: green
|
316
|
+
# bold: true
|
317
|
+
#
|
256
318
|
# == Questions?
|
257
319
|
#
|
258
320
|
# I'd really like to get feedback from all levels of Ruby
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# nested test case example.
|
2
|
+
|
3
|
+
class UserTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@user = "me"
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_full_name
|
9
|
+
assert_equal("me", @user)
|
10
|
+
end
|
11
|
+
|
12
|
+
class ProfileTest < UserTest
|
13
|
+
setup
|
14
|
+
def setup_profile
|
15
|
+
@user += ": profile"
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_has_profile
|
19
|
+
assert_match(/: profile/, @user)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
File without changes
|
File without changes
|