activeldap 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +34 -0
- data/README +13 -0
- data/Rakefile +2 -1
- data/TODO +6 -0
- data/benchmark/bench-al.rb +68 -17
- data/examples/al-admin/app/helpers/application_helper.rb +3 -5
- data/examples/al-admin/app/views/layouts/_footer.html.erb +2 -0
- data/examples/al-admin/config/boot.rb +7 -7
- data/examples/al-admin/config/environment.rb +27 -12
- data/examples/al-admin/config/environments/development.rb +0 -1
- data/examples/al-admin/config/environments/production.rb +6 -1
- data/examples/al-admin/config/environments/test.rb +1 -1
- data/examples/al-admin/config/initializers/gettext.rb +15 -1
- data/examples/al-admin/po/en/al-admin.po +1 -1
- data/examples/al-admin/po/ja/al-admin.po +1 -1
- data/examples/al-admin/po/nl/al-admin.po +1 -1
- data/examples/al-admin/public/dispatch.cgi +0 -0
- data/examples/al-admin/public/dispatch.fcgi +0 -0
- data/examples/al-admin/public/dispatch.rb +0 -0
- data/examples/al-admin/public/javascripts/controls.js +73 -73
- data/examples/al-admin/public/javascripts/dragdrop.js +166 -165
- data/examples/al-admin/public/javascripts/effects.js +174 -166
- data/examples/al-admin/public/javascripts/prototype.js +362 -267
- data/examples/al-admin/script/about +0 -0
- data/examples/al-admin/script/console +0 -0
- data/examples/al-admin/script/dbconsole +3 -0
- data/examples/al-admin/script/destroy +0 -0
- data/examples/al-admin/script/generate +0 -0
- data/examples/al-admin/script/performance/benchmarker +0 -0
- data/examples/al-admin/script/performance/profiler +0 -0
- data/examples/al-admin/script/performance/request +0 -0
- data/examples/al-admin/script/plugin +0 -0
- data/examples/al-admin/script/process/inspector +0 -0
- data/examples/al-admin/script/process/reaper +0 -0
- data/examples/al-admin/script/process/spawner +0 -0
- data/examples/al-admin/script/runner +0 -0
- data/examples/al-admin/script/server +0 -0
- data/examples/al-admin/test/run-test.sh +0 -0
- data/examples/groupadd +0 -0
- data/examples/groupdel +0 -0
- data/examples/groupls +0 -0
- data/examples/groupmod +0 -0
- data/examples/lpasswd +0 -0
- data/examples/ouadd +0 -0
- data/examples/useradd +0 -0
- data/examples/useradd-binary +0 -0
- data/examples/userdel +0 -0
- data/examples/userls +0 -0
- data/examples/usermod +0 -0
- data/examples/usermod-binary-add +0 -0
- data/examples/usermod-binary-add-time +0 -0
- data/examples/usermod-binary-del +0 -0
- data/examples/usermod-lang-add +0 -0
- data/lib/active_ldap.rb +10 -4
- data/lib/active_ldap/action_controller/ldap_benchmarking.rb +28 -9
- data/lib/active_ldap/adapter/base.rb +30 -17
- data/lib/active_ldap/adapter/jndi.rb +5 -1
- data/lib/active_ldap/adapter/ldap.rb +5 -1
- data/lib/active_ldap/association/has_many_utils.rb +7 -1
- data/lib/active_ldap/associations.rb +10 -5
- data/lib/active_ldap/attributes.rb +6 -1
- data/lib/active_ldap/base.rb +154 -52
- data/lib/active_ldap/configuration.rb +1 -1
- data/lib/active_ldap/connection.rb +7 -4
- data/lib/active_ldap/get_text.rb +11 -3
- data/lib/active_ldap/ldif.rb +16 -4
- data/lib/active_ldap/operations.rb +13 -5
- data/lib/active_ldap/schema.rb +6 -2
- data/lib/active_ldap/schema/syntaxes.rb +15 -3
- data/lib/active_ldap/user_password.rb +4 -4
- data/lib/active_ldap/validations.rb +32 -44
- data/lib/active_ldap/xml.rb +125 -0
- data/po/en/active-ldap.po +740 -85
- data/po/ja/active-ldap.po +748 -547
- data/rails/README +54 -0
- data/rails/init.rb +33 -0
- data/rails/plugin/active_ldap/generators/README +2 -0
- data/rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb +1 -1
- data/rails/plugin/active_ldap/init.rb +3 -0
- data/rails_generators/model_active_ldap/USAGE +17 -0
- data/rails_generators/model_active_ldap/model_active_ldap_generator.rb +69 -0
- data/rails_generators/model_active_ldap/templates/model_active_ldap.rb +3 -0
- data/rails_generators/model_active_ldap/templates/unit_test.rb +8 -0
- data/rails_generators/scaffold_active_ldap/scaffold_active_ldap_generator.rb +7 -0
- data/rails_generators/scaffold_active_ldap/templates/ldap.yml +18 -0
- data/rails_generators/scaffold_al/scaffold_al_generator.rb +20 -0
- data/test-unit/History.txt +50 -1
- data/test-unit/Manifest.txt +22 -12
- data/test-unit/README.txt +31 -12
- data/test-unit/Rakefile +14 -1
- data/test-unit/TODO +5 -0
- data/test-unit/bin/testrb +0 -0
- data/test-unit/lib/test/unit.rb +62 -0
- data/test-unit/lib/test/unit/assertions.rb +419 -75
- data/test-unit/lib/test/unit/autorunner.rb +70 -13
- data/test-unit/lib/test/unit/collector.rb +1 -1
- data/test-unit/lib/test/unit/collector/load.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 +17 -2
- data/test-unit/lib/test/unit/runner/console.rb +8 -2
- data/test-unit/lib/test/unit/testcase.rb +188 -2
- data/test-unit/lib/test/unit/ui/console/testrunner.rb +51 -26
- 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/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/run-test.rb +0 -0
- 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_assertions.rb +411 -69
- data/test-unit/test/test_testcase.rb +70 -3
- 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
- data/test/run-test.rb +0 -0
- data/test/test_adapter.rb +3 -0
- data/test/test_associations.rb +50 -7
- data/test/test_base.rb +193 -11
- data/test/test_connection_per_dn.rb +1 -1
- data/test/test_ldif.rb +86 -0
- data/test/test_load.rb +7 -0
- data/test/test_schema.rb +31 -1
- data/test/test_syntax.rb +20 -0
- data/test/test_user_password.rb +22 -14
- data/test/test_validation.rb +70 -29
- metadata +99 -77
- data/data/locale/en/LC_MESSAGES/active-ldap.mo +0 -0
- data/data/locale/ja/LC_MESSAGES/active-ldap.mo +0 -0
- data/examples/al-admin/config/initializers/ralative_url_support.rb +0 -1
- data/examples/al-admin/lib/accept_http_rails_relative_url_root.rb +0 -9
- data/test-unit-ext/misc/rd2html.rb +0 -42
- data/test-unit/test/test_fixture.rb +0 -275
@@ -56,6 +56,20 @@ module Test
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
+
# Omit the test of part of the test.
|
60
|
+
#
|
61
|
+
# Example:
|
62
|
+
# def test_omission
|
63
|
+
# omit
|
64
|
+
# # Not reached here
|
65
|
+
# end
|
66
|
+
#
|
67
|
+
# def test_omission_with_here
|
68
|
+
# omit do
|
69
|
+
# # Not ran here
|
70
|
+
# end
|
71
|
+
# # Reached here
|
72
|
+
# end
|
59
73
|
def omit(message=nil, &block)
|
60
74
|
message ||= "omitted."
|
61
75
|
if block_given?
|
@@ -56,6 +56,22 @@ module Test
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
+
# Marks the test or part of the test is pending.
|
60
|
+
#
|
61
|
+
# Example:
|
62
|
+
# def test_pending
|
63
|
+
# pend
|
64
|
+
# # Not reached here
|
65
|
+
# end
|
66
|
+
#
|
67
|
+
# def test_pending_with_here
|
68
|
+
# pend do
|
69
|
+
# # Ran here
|
70
|
+
# # Fails if the block doesn't raise any error.
|
71
|
+
# # Because it means the block is passed unexpectedly.
|
72
|
+
# end
|
73
|
+
# # Reached here
|
74
|
+
# end
|
59
75
|
def pend(message=nil, &block)
|
60
76
|
message ||= "pended."
|
61
77
|
if block_given?
|
@@ -13,6 +13,19 @@ module Test
|
|
13
13
|
teardown :priority_teardown, :after => :append
|
14
14
|
end
|
15
15
|
end
|
16
|
+
|
17
|
+
@@enabled = false
|
18
|
+
def enabled?
|
19
|
+
@@enabled
|
20
|
+
end
|
21
|
+
|
22
|
+
def enable
|
23
|
+
@@enabled = true
|
24
|
+
end
|
25
|
+
|
26
|
+
def disable
|
27
|
+
@@enabled = false
|
28
|
+
end
|
16
29
|
end
|
17
30
|
|
18
31
|
class Checker
|
@@ -90,7 +103,7 @@ module Test
|
|
90
103
|
def result_dir
|
91
104
|
components = [".test-result",
|
92
105
|
@test.class.name || "AnonymousTestCase",
|
93
|
-
|
106
|
+
escaped_method_name]
|
94
107
|
parent_directories = [File.dirname($0), Dir.pwd]
|
95
108
|
if Process.respond_to?(:uid)
|
96
109
|
parent_directories << File.join(Dir.tmpdir, Process.uid.to_s)
|
@@ -112,7 +125,7 @@ module Test
|
|
112
125
|
end
|
113
126
|
|
114
127
|
def escaped_method_name
|
115
|
-
@method_name.to_s.gsub(/[!?=]$/) do |matched|
|
128
|
+
@test.method_name.to_s.gsub(/[!?=]$/) do |matched|
|
116
129
|
case matched
|
117
130
|
when "!"
|
118
131
|
".destructive"
|
@@ -135,10 +148,12 @@ module Test
|
|
135
148
|
end
|
136
149
|
|
137
150
|
def priority_setup
|
151
|
+
return unless Priority.enabled?
|
138
152
|
Checker.new(self).setup
|
139
153
|
end
|
140
154
|
|
141
155
|
def priority_teardown
|
156
|
+
return unless Priority.enabled?
|
142
157
|
Checker.new(self).teardown
|
143
158
|
end
|
144
159
|
end
|
@@ -31,8 +31,8 @@ module Test
|
|
31
31
|
["true", true],
|
32
32
|
]
|
33
33
|
opts.on("--[no-]use-color=[auto]", use_color_options,
|
34
|
-
"
|
35
|
-
"(default is auto") do |use_color|
|
34
|
+
"Uses color output",
|
35
|
+
"(default is auto)") do |use_color|
|
36
36
|
case use_color
|
37
37
|
when nil
|
38
38
|
use_color = true
|
@@ -41,6 +41,12 @@ module Test
|
|
41
41
|
end
|
42
42
|
auto_runner.runner_options[:use_color] = use_color
|
43
43
|
end
|
44
|
+
|
45
|
+
opts.on("--progress-row-max=MAX", Integer,
|
46
|
+
"Uses MAX as max terminal width for progress mark",
|
47
|
+
"(default is auto)") do |max|
|
48
|
+
auto_runner.runner_options[:progress_row_max] = max
|
49
|
+
end
|
44
50
|
end
|
45
51
|
end
|
46
52
|
end
|
@@ -17,6 +17,7 @@ require 'test/unit/priority'
|
|
17
17
|
require 'test/unit/testsuite'
|
18
18
|
require 'test/unit/assertionfailederror'
|
19
19
|
require 'test/unit/util/backtracefilter'
|
20
|
+
require 'test/unit/util/method-owner-finder'
|
20
21
|
|
21
22
|
module Test
|
22
23
|
module Unit
|
@@ -26,6 +27,47 @@ module Test
|
|
26
27
|
# wrapping those tests into a suite. It also does the
|
27
28
|
# nitty-gritty of actually running an individual test and
|
28
29
|
# collecting its results into a Test::Unit::TestResult object.
|
30
|
+
#
|
31
|
+
# You can run two hooks before/after a TestCase run.
|
32
|
+
#
|
33
|
+
# Example:
|
34
|
+
# class TestMyClass < Test::Unit::TestCase
|
35
|
+
# class << self
|
36
|
+
# def startup
|
37
|
+
# ...
|
38
|
+
# end
|
39
|
+
#
|
40
|
+
# def shutdown
|
41
|
+
# ...
|
42
|
+
# end
|
43
|
+
# end
|
44
|
+
#
|
45
|
+
# def setup
|
46
|
+
# ...
|
47
|
+
# end
|
48
|
+
#
|
49
|
+
# def teardown
|
50
|
+
# ...
|
51
|
+
# end
|
52
|
+
#
|
53
|
+
# def test_my_method1
|
54
|
+
# ...
|
55
|
+
# end
|
56
|
+
#
|
57
|
+
# def test_my_method2
|
58
|
+
# ...
|
59
|
+
# end
|
60
|
+
# end
|
61
|
+
#
|
62
|
+
# Here is a call order:
|
63
|
+
# * startup
|
64
|
+
# * setup
|
65
|
+
# * test_my_method1
|
66
|
+
# * teardown
|
67
|
+
# * setup
|
68
|
+
# * test_my_method2
|
69
|
+
# * teardown
|
70
|
+
# * shutdown
|
29
71
|
class TestCase
|
30
72
|
include Attribute
|
31
73
|
include Fixture
|
@@ -68,6 +110,79 @@ module Test
|
|
68
110
|
end
|
69
111
|
suite
|
70
112
|
end
|
113
|
+
|
114
|
+
# Called before every test case runs. Can be used
|
115
|
+
# to set up fixture information used in test case
|
116
|
+
# scope.
|
117
|
+
#
|
118
|
+
# Here is an example test case:
|
119
|
+
# class TestMyClass < Test::Unit::TestCase
|
120
|
+
# class << self
|
121
|
+
# def startup
|
122
|
+
# ...
|
123
|
+
# end
|
124
|
+
# end
|
125
|
+
#
|
126
|
+
# def setup
|
127
|
+
# ...
|
128
|
+
# end
|
129
|
+
#
|
130
|
+
# def test_my_class1
|
131
|
+
# ...
|
132
|
+
# end
|
133
|
+
#
|
134
|
+
# def test_my_class2
|
135
|
+
# ...
|
136
|
+
# end
|
137
|
+
# end
|
138
|
+
#
|
139
|
+
# Here is a call order:
|
140
|
+
# * startup
|
141
|
+
# * setup
|
142
|
+
# * test_my_class1 (or test_my_class2)
|
143
|
+
# * setup
|
144
|
+
# * test_my_class2 (or test_my_class1)
|
145
|
+
#
|
146
|
+
# Note that you should not assume test order. Tests
|
147
|
+
# should be worked in any order.
|
148
|
+
def startup
|
149
|
+
end
|
150
|
+
|
151
|
+
# Called after every test case runs. Can be used to tear
|
152
|
+
# down fixture information used in test case scope.
|
153
|
+
#
|
154
|
+
# Here is an example test case:
|
155
|
+
# class TestMyClass < Test::Unit::TestCase
|
156
|
+
# class << self
|
157
|
+
# def shutdown
|
158
|
+
# ...
|
159
|
+
# end
|
160
|
+
# end
|
161
|
+
#
|
162
|
+
# def teardown
|
163
|
+
# ...
|
164
|
+
# end
|
165
|
+
#
|
166
|
+
# def test_my_class1
|
167
|
+
# ...
|
168
|
+
# end
|
169
|
+
#
|
170
|
+
# def test_my_class2
|
171
|
+
# ...
|
172
|
+
# end
|
173
|
+
# end
|
174
|
+
#
|
175
|
+
# Here is a call order:
|
176
|
+
# * test_my_class1 (or test_my_class2)
|
177
|
+
# * teardown
|
178
|
+
# * test_my_class2 (or test_my_class1)
|
179
|
+
# * teardown
|
180
|
+
# * shutdown
|
181
|
+
#
|
182
|
+
# Note that you should not assume test order. Tests
|
183
|
+
# should be worked in any order.
|
184
|
+
def shutdown
|
185
|
+
end
|
71
186
|
end
|
72
187
|
|
73
188
|
attr_reader :method_name
|
@@ -76,9 +191,15 @@ module Test
|
|
76
191
|
# test represented by test_method_name.
|
77
192
|
def initialize(test_method_name)
|
78
193
|
throw :invalid_test unless respond_to?(test_method_name)
|
79
|
-
|
194
|
+
test_method = method(test_method_name)
|
195
|
+
throw :invalid_test if test_method.arity > 0
|
196
|
+
owner = Util::MethodOwnerFinder.find(self, test_method_name)
|
197
|
+
if owner.class != Module and self.class != owner
|
198
|
+
throw :invalid_test
|
199
|
+
end
|
80
200
|
@method_name = test_method_name
|
81
201
|
@test_passed = true
|
202
|
+
@interrupted = false
|
82
203
|
end
|
83
204
|
|
84
205
|
# Runs the individual test method represented by this
|
@@ -90,8 +211,9 @@ module Test
|
|
90
211
|
yield(STARTED, name)
|
91
212
|
begin
|
92
213
|
run_setup
|
93
|
-
|
214
|
+
run_test
|
94
215
|
rescue Exception
|
216
|
+
@interrupted = true
|
95
217
|
raise unless handle_exception($!)
|
96
218
|
ensure
|
97
219
|
begin
|
@@ -109,11 +231,67 @@ module Test
|
|
109
231
|
|
110
232
|
# Called before every test method runs. Can be used
|
111
233
|
# to set up fixture information.
|
234
|
+
#
|
235
|
+
# You can add additional setup tasks by the following
|
236
|
+
# code:
|
237
|
+
# class TestMyClass < Test::Unit::TestCase
|
238
|
+
# def setup
|
239
|
+
# ...
|
240
|
+
# end
|
241
|
+
#
|
242
|
+
# setup
|
243
|
+
# def my_setup1
|
244
|
+
# ...
|
245
|
+
# end
|
246
|
+
#
|
247
|
+
# setup
|
248
|
+
# def my_setup2
|
249
|
+
# ...
|
250
|
+
# end
|
251
|
+
#
|
252
|
+
# def test_my_class
|
253
|
+
# ...
|
254
|
+
# end
|
255
|
+
# end
|
256
|
+
#
|
257
|
+
# Here is a call order:
|
258
|
+
# * setup
|
259
|
+
# * my_setup1
|
260
|
+
# * my_setup2
|
261
|
+
# * test_my_class
|
112
262
|
def setup
|
113
263
|
end
|
114
264
|
|
115
265
|
# Called after every test method runs. Can be used to tear
|
116
266
|
# down fixture information.
|
267
|
+
#
|
268
|
+
# You can add additional teardown tasks by the following
|
269
|
+
# code:
|
270
|
+
# class TestMyClass < Test::Unit::TestCase
|
271
|
+
# def teardown
|
272
|
+
# ...
|
273
|
+
# end
|
274
|
+
#
|
275
|
+
# teardown
|
276
|
+
# def my_teardown1
|
277
|
+
# ...
|
278
|
+
# end
|
279
|
+
#
|
280
|
+
# teardown
|
281
|
+
# def my_teardown2
|
282
|
+
# ...
|
283
|
+
# end
|
284
|
+
#
|
285
|
+
# def test_my_class
|
286
|
+
# ...
|
287
|
+
# end
|
288
|
+
# end
|
289
|
+
#
|
290
|
+
# Here is a call order:
|
291
|
+
# * test_my_class
|
292
|
+
# * my_teardown2
|
293
|
+
# * my_teardown1
|
294
|
+
# * teardown
|
117
295
|
def teardown
|
118
296
|
end
|
119
297
|
|
@@ -143,11 +321,19 @@ module Test
|
|
143
321
|
self.class == other.class
|
144
322
|
end
|
145
323
|
|
324
|
+
def interrupted?
|
325
|
+
@interrupted
|
326
|
+
end
|
327
|
+
|
146
328
|
private
|
147
329
|
def current_result
|
148
330
|
@_result
|
149
331
|
end
|
150
332
|
|
333
|
+
def run_test
|
334
|
+
__send__(@method_name)
|
335
|
+
end
|
336
|
+
|
151
337
|
def handle_exception(exception)
|
152
338
|
self.class.exception_handlers.each do |handler|
|
153
339
|
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,31 +139,47 @@ 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
|
|
@@ -184,6 +190,25 @@ module Test
|
|
184
190
|
return true if ENV["EMACS"] == "t"
|
185
191
|
false
|
186
192
|
end
|
193
|
+
|
194
|
+
def guess_progress_row_max
|
195
|
+
term_width = guess_term_width
|
196
|
+
if term_width.zero?
|
197
|
+
if ENV["EMACS"] == "t"
|
198
|
+
-1
|
199
|
+
else
|
200
|
+
79
|
201
|
+
end
|
202
|
+
else
|
203
|
+
term_width
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
def guess_term_width
|
208
|
+
Integer(ENV["TERM_WIDTH"] || 0)
|
209
|
+
rescue ArgumentError
|
210
|
+
0
|
211
|
+
end
|
187
212
|
end
|
188
213
|
end
|
189
214
|
end
|