activeldap 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +17 -0
- data/README +7 -1
- data/Rakefile +2 -1
- data/benchmark/bench-al.rb +3 -3
- data/examples/al-admin/app/helpers/users_helper.rb +1 -1
- data/examples/al-admin/config/environment.rb +4 -3
- data/examples/al-admin/config/initializers/gettext.rb +1 -0
- data/examples/al-admin/config/session_secret.txt +1 -1
- data/examples/al-admin/po/al-admin.pot +344 -0
- data/examples/al-admin/public/images/active-ldap.png +0 -0
- data/examples/al-admin/vendor/locale_rails/.gitignore +6 -0
- data/examples/al-admin/vendor/locale_rails/COPYING +56 -0
- data/examples/al-admin/vendor/locale_rails/ChangeLog +35 -0
- data/examples/al-admin/vendor/locale_rails/README.rdoc +62 -0
- data/examples/al-admin/vendor/locale_rails/Rakefile +73 -0
- data/examples/al-admin/vendor/locale_rails/lib/locale_rails.rb +18 -0
- data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_controller.rb +15 -0
- data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_controller/base.rb +82 -0
- data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_controller/caching.rb +51 -0
- data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_controller/test_process.rb +44 -0
- data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_view.rb +53 -0
- data/examples/al-admin/vendor/locale_rails/lib/locale_rails/i18n.rb +67 -0
- data/examples/al-admin/vendor/locale_rails/lib/locale_rails/version.rb +4 -0
- data/examples/al-admin/vendor/locale_rails/sample/README +22 -0
- data/examples/al-admin/vendor/locale_rails/sample/Rakefile +10 -0
- data/examples/al-admin/vendor/locale_rails/sample/app/controllers/application.rb +42 -0
- data/examples/al-admin/vendor/locale_rails/sample/app/controllers/samples_controller.rb +30 -0
- data/examples/al-admin/vendor/locale_rails/sample/app/helpers/application_helper.rb +3 -0
- data/examples/al-admin/vendor/locale_rails/sample/app/views/layouts/samples.html.erb +20 -0
- data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/_part.html.erb +68 -0
- data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/_part_nl.html.erb +2 -0
- data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/cached_action.html.erb +6 -0
- data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/index.html.erb +33 -0
- data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/index.pt.html.erb +16 -0
- data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/index_uz_UZ.html.erb +16 -0
- data/examples/al-admin/vendor/locale_rails/sample/config/boot.rb +109 -0
- data/examples/al-admin/vendor/locale_rails/sample/config/environment.rb +25 -0
- data/examples/al-admin/vendor/locale_rails/sample/config/environments/development.rb +17 -0
- data/examples/al-admin/vendor/locale_rails/sample/config/environments/production.rb +24 -0
- data/examples/al-admin/vendor/locale_rails/sample/config/environments/test.rb +22 -0
- data/examples/al-admin/vendor/locale_rails/sample/config/initializers/inflections.rb +10 -0
- data/examples/al-admin/vendor/locale_rails/sample/config/initializers/mime_types.rb +5 -0
- data/examples/al-admin/vendor/locale_rails/sample/config/initializers/new_rails_defaults.rb +17 -0
- data/examples/al-admin/vendor/locale_rails/sample/config/locales/en.yml +2 -0
- data/examples/al-admin/vendor/locale_rails/sample/config/locales/ja.yml +2 -0
- data/examples/al-admin/vendor/locale_rails/sample/config/routes.rb +13 -0
- data/examples/al-admin/vendor/locale_rails/sample/db/schema.rb +10 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/404.html +30 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/422.html +30 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/500.html +33 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/dispatch.cgi +10 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/dispatch.fcgi +24 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/dispatch.rb +10 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/favicon.ico +0 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/images/rails.png +0 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/application.js +2 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/controls.js +963 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/dragdrop.js +972 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/effects.js +1120 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/prototype.js +4221 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/robots.txt +5 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/stylesheets/locale.css +81 -0
- data/examples/al-admin/vendor/locale_rails/sample/public/stylesheets/scaffold.css +74 -0
- data/examples/al-admin/vendor/locale_rails/sample/script/about +4 -0
- data/examples/al-admin/vendor/locale_rails/sample/script/console +3 -0
- data/examples/al-admin/vendor/locale_rails/sample/script/dbconsole +3 -0
- data/examples/al-admin/vendor/locale_rails/sample/script/destroy +3 -0
- data/examples/al-admin/vendor/locale_rails/sample/script/generate +3 -0
- data/examples/al-admin/vendor/locale_rails/sample/script/performance/benchmarker +3 -0
- data/examples/al-admin/vendor/locale_rails/sample/script/performance/profiler +3 -0
- data/examples/al-admin/vendor/locale_rails/sample/script/performance/request +3 -0
- data/examples/al-admin/vendor/locale_rails/sample/script/plugin +3 -0
- data/examples/al-admin/vendor/locale_rails/sample/script/process/inspector +3 -0
- data/examples/al-admin/vendor/locale_rails/sample/script/process/reaper +3 -0
- data/examples/al-admin/vendor/locale_rails/sample/script/process/spawner +3 -0
- data/examples/al-admin/vendor/locale_rails/sample/script/runner +3 -0
- data/examples/al-admin/vendor/locale_rails/sample/script/server +3 -0
- data/examples/al-admin/vendor/locale_rails/sample/test/performance/browsing_test.rb +9 -0
- data/examples/al-admin/vendor/locale_rails/sample/test/test_helper.rb +38 -0
- data/examples/al-admin/vendor/locale_rails/test/README +243 -0
- data/examples/al-admin/vendor/locale_rails/test/Rakefile +10 -0
- data/examples/al-admin/vendor/locale_rails/test/app/controllers/application_controller.rb +10 -0
- data/examples/al-admin/vendor/locale_rails/test/app/controllers/articles_controller.rb +17 -0
- data/examples/al-admin/vendor/locale_rails/test/app/helpers/application_helper.rb +3 -0
- data/examples/al-admin/vendor/locale_rails/test/app/views/articles/index.html.erb +1 -0
- data/examples/al-admin/vendor/locale_rails/test/app/views/articles/index_de.html.erb +1 -0
- data/examples/al-admin/vendor/locale_rails/test/app/views/articles/index_fr_FR.html.erb +1 -0
- data/examples/al-admin/vendor/locale_rails/test/app/views/articles/index_ja.html.erb +1 -0
- data/examples/al-admin/vendor/locale_rails/test/app/views/articles/list.html.erb +1 -0
- data/examples/al-admin/vendor/locale_rails/test/app/views/articles/show.html.erb +0 -0
- data/examples/al-admin/vendor/locale_rails/test/app/views/articles/show.js.rjs +0 -0
- data/examples/al-admin/vendor/locale_rails/test/config/boot.rb +110 -0
- data/examples/al-admin/vendor/locale_rails/test/config/environment.rb +42 -0
- data/examples/al-admin/vendor/locale_rails/test/config/environments/development.rb +17 -0
- data/examples/al-admin/vendor/locale_rails/test/config/environments/production.rb +28 -0
- data/examples/al-admin/vendor/locale_rails/test/config/environments/test.rb +35 -0
- data/examples/al-admin/vendor/locale_rails/test/config/initializers/backtrace_silencers.rb +7 -0
- data/examples/al-admin/vendor/locale_rails/test/config/initializers/inflections.rb +10 -0
- data/examples/al-admin/vendor/locale_rails/test/config/initializers/mime_types.rb +5 -0
- data/examples/al-admin/vendor/locale_rails/test/config/initializers/new_rails_defaults.rb +19 -0
- data/examples/al-admin/vendor/locale_rails/test/config/initializers/session_store.rb +15 -0
- data/examples/al-admin/vendor/locale_rails/test/config/locales/en.yml +5 -0
- data/examples/al-admin/vendor/locale_rails/test/config/routes.rb +46 -0
- data/examples/al-admin/vendor/locale_rails/test/db/schema.rb +0 -0
- data/examples/al-admin/vendor/locale_rails/test/public/404.html +30 -0
- data/examples/al-admin/vendor/locale_rails/test/public/422.html +30 -0
- data/examples/al-admin/vendor/locale_rails/test/public/500.html +30 -0
- data/examples/al-admin/vendor/locale_rails/test/public/favicon.ico +0 -0
- data/examples/al-admin/vendor/locale_rails/test/public/images/rails.png +0 -0
- data/examples/al-admin/vendor/locale_rails/test/public/index.html +275 -0
- data/examples/al-admin/vendor/locale_rails/test/public/javascripts/application.js +2 -0
- data/examples/al-admin/vendor/locale_rails/test/public/javascripts/controls.js +963 -0
- data/examples/al-admin/vendor/locale_rails/test/public/javascripts/dragdrop.js +973 -0
- data/examples/al-admin/vendor/locale_rails/test/public/javascripts/effects.js +1128 -0
- data/examples/al-admin/vendor/locale_rails/test/public/javascripts/prototype.js +4320 -0
- data/examples/al-admin/vendor/locale_rails/test/public/robots.txt +5 -0
- data/examples/al-admin/vendor/locale_rails/test/script/about +4 -0
- data/examples/al-admin/vendor/locale_rails/test/script/console +3 -0
- data/examples/al-admin/vendor/locale_rails/test/script/dbconsole +3 -0
- data/examples/al-admin/vendor/locale_rails/test/script/destroy +3 -0
- data/examples/al-admin/vendor/locale_rails/test/script/generate +3 -0
- data/examples/al-admin/vendor/locale_rails/test/script/performance/benchmarker +3 -0
- data/examples/al-admin/vendor/locale_rails/test/script/performance/profiler +3 -0
- data/examples/al-admin/vendor/locale_rails/test/script/plugin +3 -0
- data/examples/al-admin/vendor/locale_rails/test/script/runner +3 -0
- data/examples/al-admin/vendor/locale_rails/test/script/server +3 -0
- data/examples/al-admin/vendor/locale_rails/test/test/functional/articles_controller_test.rb +161 -0
- data/examples/al-admin/vendor/locale_rails/test/test/performance/browsing_test.rb +9 -0
- data/examples/al-admin/vendor/locale_rails/test/test/test_helper.rb +38 -0
- data/lib/active_ldap.rb +9 -4
- data/lib/active_ldap/adapter/base.rb +3 -3
- data/lib/active_ldap/adapter/jndi.rb +1 -1
- data/lib/active_ldap/adapter/jndi_connection.rb +1 -3
- data/lib/active_ldap/adapter/ldap.rb +11 -11
- data/lib/active_ldap/adapter/ldap_ext.rb +25 -3
- data/lib/active_ldap/adapter/net_ldap.rb +9 -2
- data/lib/active_ldap/association/collection.rb +14 -2
- data/lib/active_ldap/base.rb +13 -5
- data/lib/active_ldap/configuration.rb +1 -0
- data/lib/active_ldap/ldap_error.rb +3 -3
- data/lib/active_ldap/ldif.rb +1 -1
- data/lib/active_ldap/operations.rb +2 -0
- data/lib/active_ldap/schema/syntaxes.rb +2 -2
- data/lib/active_ldap/validations.rb +37 -26
- data/lib/active_ldap/xml.rb +2 -0
- data/po/active-ldap.pot +38 -58
- data/test-unit/COPYING +56 -0
- data/test-unit/GPL +340 -0
- data/test-unit/History.txt +65 -3
- data/test-unit/Manifest.txt +5 -0
- data/test-unit/PSFL +271 -0
- data/test-unit/README.txt +6 -1
- data/test-unit/lib/test/unit.rb +6 -1
- data/test-unit/lib/test/unit/assertions.rb +129 -13
- data/test-unit/lib/test/unit/autorunner.rb +21 -16
- data/test-unit/lib/test/unit/collector.rb +1 -8
- data/test-unit/lib/test/unit/collector/dir.rb +1 -1
- data/test-unit/lib/test/unit/collector/load.rb +15 -7
- data/test-unit/lib/test/unit/color-scheme.rb +6 -2
- data/test-unit/lib/test/unit/diff.rb +17 -1
- data/test-unit/lib/test/unit/error.rb +4 -0
- data/test-unit/lib/test/unit/failure.rb +4 -0
- data/test-unit/lib/test/unit/notification.rb +8 -4
- data/test-unit/lib/test/unit/omission.rb +4 -0
- data/test-unit/lib/test/unit/pending.rb +4 -0
- data/test-unit/lib/test/unit/priority.rb +2 -3
- data/test-unit/lib/test/unit/testcase.rb +18 -7
- data/test-unit/lib/test/unit/ui/console/testrunner.rb +5 -3
- data/test-unit/lib/test/unit/util/backtracefilter.rb +1 -0
- data/test-unit/lib/test/unit/util/output.rb +31 -0
- data/test-unit/lib/test/unit/version.rb +1 -1
- data/test-unit/test/collector/test-descendant.rb +2 -4
- data/test-unit/test/collector/test-load.rb +121 -8
- data/test-unit/test/collector/test_objectspace.rb +7 -5
- data/test-unit/test/test-color-scheme.rb +4 -2
- data/test-unit/test/test-testcase.rb +48 -38
- data/test-unit/test/test_assertions.rb +87 -5
- data/test-unit/test/util/test-output.rb +11 -0
- data/test/al-test-utils.rb +6 -1
- data/test/fixtures/lower_case_object_class_schema.rb +802 -0
- data/test/test_associations.rb +20 -1
- data/test/test_base.rb +50 -3
- data/test/test_ldif.rb +10 -1
- data/test/test_syntax.rb +12 -0
- data/test/test_validation.rb +0 -2
- metadata +225 -56
@@ -117,27 +117,21 @@ module Test
|
|
117
117
|
if File.exist?(config_file)
|
118
118
|
load_config(config_file)
|
119
119
|
else
|
120
|
-
|
121
|
-
load_config(global_config_file) if File.exist?(global_config_file)
|
120
|
+
load_global_config
|
122
121
|
end
|
123
122
|
yield(self) if block_given?
|
124
123
|
end
|
125
124
|
|
126
125
|
def process_args(args = ARGV)
|
127
|
-
default_arguments = @default_arguments.dup
|
128
126
|
begin
|
129
|
-
|
130
|
-
options.order!(
|
127
|
+
args.unshift(*@default_arguments)
|
128
|
+
options.order!(args) {|arg| @to_run << arg}
|
131
129
|
rescue OptionParser::ParseError => e
|
132
130
|
puts e
|
133
131
|
puts options
|
134
132
|
exit(false)
|
135
|
-
else
|
136
|
-
@filters << proc{false} unless(@filters.empty?)
|
137
133
|
end
|
138
134
|
not @to_run.empty?
|
139
|
-
ensure
|
140
|
-
@default_arguments = default_arguments
|
141
135
|
end
|
142
136
|
|
143
137
|
def options
|
@@ -186,9 +180,9 @@ module Test
|
|
186
180
|
n = (%r{\A/(.*)/\Z} =~ n ? Regexp.new($1) : n)
|
187
181
|
case n
|
188
182
|
when Regexp
|
189
|
-
@filters << proc{|t| n =~ t.method_name ? true :
|
183
|
+
@filters << proc{|t| n =~ t.method_name ? true : false}
|
190
184
|
else
|
191
|
-
@filters << proc{|t| n == t.method_name
|
185
|
+
@filters << proc{|t| n == t.method_name}
|
192
186
|
end
|
193
187
|
end
|
194
188
|
|
@@ -198,17 +192,17 @@ module Test
|
|
198
192
|
n = (%r{\A/(.*)/\Z} =~ n ? Regexp.new($1) : n)
|
199
193
|
case n
|
200
194
|
when Regexp
|
201
|
-
@filters << proc{|t| n =~ t.class.name ? true :
|
195
|
+
@filters << proc{|t| n =~ t.class.name ? true : false}
|
202
196
|
else
|
203
|
-
@filters << proc{|t| n == t.class.name
|
197
|
+
@filters << proc{|t| n == t.class.name}
|
204
198
|
end
|
205
199
|
end
|
206
200
|
|
207
201
|
priority_filter = Proc.new do |test|
|
208
|
-
if @filters
|
209
|
-
|
202
|
+
if @filters == [priority_filter]
|
203
|
+
Priority::Checker.new(test).need_to_run?
|
210
204
|
else
|
211
|
-
|
205
|
+
nil
|
212
206
|
end
|
213
207
|
end
|
214
208
|
o.on("--[no-]priority-mode",
|
@@ -346,6 +340,17 @@ module Test
|
|
346
340
|
def default_collector
|
347
341
|
self.class.collector(@standalone ? :load : :descendant)
|
348
342
|
end
|
343
|
+
|
344
|
+
def global_config_file
|
345
|
+
File.expand_path("~/.test-unit.yml")
|
346
|
+
rescue ArgumentError
|
347
|
+
nil
|
348
|
+
end
|
349
|
+
|
350
|
+
def load_global_config
|
351
|
+
file = global_config_file
|
352
|
+
load_config(file) if file and File.exist?(file)
|
353
|
+
end
|
349
354
|
end
|
350
355
|
end
|
351
356
|
end
|
@@ -23,14 +23,7 @@ module Test
|
|
23
23
|
def include?(test)
|
24
24
|
return true if(@filters.empty?)
|
25
25
|
@filters.each do |filter|
|
26
|
-
|
27
|
-
if(result.nil?)
|
28
|
-
next
|
29
|
-
elsif(!result)
|
30
|
-
return false
|
31
|
-
else
|
32
|
-
return true
|
33
|
-
end
|
26
|
+
return false if filter[test] == false
|
34
27
|
end
|
35
28
|
true
|
36
29
|
end
|
@@ -60,7 +60,7 @@ module Test
|
|
60
60
|
next if(e == '.' || e == '..')
|
61
61
|
e_name = dir_name ? @file.join(dir_name, e) : e
|
62
62
|
if @file.directory?(realdir(e_name))
|
63
|
-
next if /\A(?:CVS|\.svn)\z/ =~ e
|
63
|
+
next if /\A(?:CVS|\.svn|\.git)\z/ =~ e
|
64
64
|
sub_suite = recursive_collect(e_name, already_gathered)
|
65
65
|
sub_suites << sub_suite unless(sub_suite.empty?)
|
66
66
|
else
|
@@ -14,8 +14,8 @@ module Test
|
|
14
14
|
def initialize
|
15
15
|
super
|
16
16
|
@system_excludes = [/~\z/, /\A\.\#/]
|
17
|
-
@system_directory_excludes = [/\A(?:CVS|\.svn)\z/]
|
18
|
-
@patterns = [/\Atest[_\-].+\.rb\z/m]
|
17
|
+
@system_directory_excludes = [/\A(?:CVS|\.svn|\.git)\z/]
|
18
|
+
@patterns = [/\Atest[_\-].+\.rb\z/m, /[_\-]test\.rb\z/]
|
19
19
|
@excludes = []
|
20
20
|
@base = nil
|
21
21
|
end
|
@@ -28,11 +28,17 @@ module Test
|
|
28
28
|
def collect(*froms)
|
29
29
|
add_load_path(@base) do
|
30
30
|
froms = ["."] if froms.empty?
|
31
|
-
test_suites =
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
test_suites = []
|
32
|
+
already_gathered = find_test_cases
|
33
|
+
froms.each do |from|
|
34
|
+
from = resolve_path(from)
|
35
|
+
if from.directory?
|
36
|
+
test_suite = collect_recursive(from, already_gathered)
|
37
|
+
test_suites << test_suite unless test_suite.tests.empty?
|
38
|
+
else
|
39
|
+
collect_file(from, test_suites, already_gathered)
|
40
|
+
end
|
41
|
+
end
|
36
42
|
|
37
43
|
if test_suites.size > 1
|
38
44
|
test_suite = TestSuite.new("[#{froms.join(', ')}]")
|
@@ -88,6 +94,8 @@ module Test
|
|
88
94
|
end
|
89
95
|
|
90
96
|
def collect_file(path, test_suites, already_gathered)
|
97
|
+
@program_file ||= File.expand_path($0)
|
98
|
+
return if @program_file == path.to_s
|
91
99
|
add_load_path(path.expand_path.dirname) do
|
92
100
|
require(path.to_s)
|
93
101
|
find_test_cases(already_gathered).each do |test_case|
|
@@ -8,8 +8,12 @@ module Test
|
|
8
8
|
class << self
|
9
9
|
@@default = nil
|
10
10
|
def default
|
11
|
-
@@default ||= new("success" =>
|
12
|
-
|
11
|
+
@@default ||= new("success" =>
|
12
|
+
Color.new("green", :foreground => false) +
|
13
|
+
Color.new("white", :bold => true),
|
14
|
+
"failure" =>
|
15
|
+
Color.new("red", :foreground => false) +
|
16
|
+
Color.new("white", :bold => true),
|
13
17
|
"pending" => Color.new("magenta", :bold => true),
|
14
18
|
"omission" => Color.new("blue", :bold => true),
|
15
19
|
"notification" => Color.new("cyan", :bold => true),
|
@@ -1,4 +1,11 @@
|
|
1
1
|
# port of Python's difflib.
|
2
|
+
#
|
3
|
+
# Copyright (c) 2001-2008 Python Software Foundation; All Rights Reserved
|
4
|
+
# Copyright (c) 2008-2010 Kouhei Sutou; All Rights Reserved
|
5
|
+
#
|
6
|
+
# It is free software, and is distributed under the Ruby
|
7
|
+
# license and/or the PSF license. See the COPYING file and
|
8
|
+
# PSFL file.
|
2
9
|
|
3
10
|
module Test
|
4
11
|
module Unit
|
@@ -717,7 +724,16 @@ module Test
|
|
717
724
|
|
718
725
|
def diff(differ_class, from, to, options={})
|
719
726
|
differ = differ_class.new(from.split(/\r?\n/), to.split(/\r?\n/))
|
720
|
-
differ.diff(options)
|
727
|
+
lines = differ.diff(options)
|
728
|
+
if Object.const_defined?(:EncodingError)
|
729
|
+
begin
|
730
|
+
lines.join("\n")
|
731
|
+
rescue EncodingError
|
732
|
+
lines.collect {|line| line.force_encoding("ASCII-8BIT")}.join("\n")
|
733
|
+
end
|
734
|
+
else
|
735
|
+
lines.join("\n")
|
736
|
+
end
|
721
737
|
end
|
722
738
|
end
|
723
739
|
end
|
@@ -41,6 +41,10 @@ module Test
|
|
41
41
|
def to_s
|
42
42
|
long_display
|
43
43
|
end
|
44
|
+
|
45
|
+
def critical?
|
46
|
+
false
|
47
|
+
end
|
44
48
|
end
|
45
49
|
|
46
50
|
class NotifiedError < StandardError
|
@@ -79,16 +83,16 @@ module Test
|
|
79
83
|
module NotificationHandler
|
80
84
|
class << self
|
81
85
|
def included(base)
|
82
|
-
base.exception_handler(:
|
86
|
+
base.exception_handler(:handle_notified_error)
|
83
87
|
end
|
84
88
|
end
|
85
89
|
|
86
90
|
private
|
87
|
-
def
|
91
|
+
def handle_notified_error(exception)
|
88
92
|
return false unless exception.is_a?(NotifiedError)
|
89
93
|
notification = Notification.new(name,
|
90
|
-
|
91
|
-
|
94
|
+
filter_backtrace(exception.backtrace),
|
95
|
+
exception.message)
|
92
96
|
add_notification(notification)
|
93
97
|
true
|
94
98
|
end
|
@@ -19,6 +19,7 @@ require 'test/unit/priority'
|
|
19
19
|
require 'test/unit/testsuite'
|
20
20
|
require 'test/unit/assertionfailederror'
|
21
21
|
require 'test/unit/util/backtracefilter'
|
22
|
+
require 'test/unit/util/output'
|
22
23
|
require 'test/unit/util/method-owner-finder'
|
23
24
|
|
24
25
|
module Test
|
@@ -82,6 +83,7 @@ module Test
|
|
82
83
|
include Priority
|
83
84
|
include Assertions
|
84
85
|
include Util::BacktraceFilter
|
86
|
+
include Util::Output
|
85
87
|
|
86
88
|
STARTED = name + "::STARTED" # :nodoc:
|
87
89
|
FINISHED = name + "::FINISHED" # :nodoc:
|
@@ -94,10 +96,15 @@ module Test
|
|
94
96
|
DESCENDANTS << sub_class
|
95
97
|
end
|
96
98
|
|
97
|
-
@@added_methods =
|
99
|
+
@@added_methods = {}
|
98
100
|
def method_added(name) # :nodoc:
|
99
101
|
super
|
100
|
-
@@added_methods
|
102
|
+
added_methods = (@@added_methods[self] ||= [])
|
103
|
+
stringified_name = name.to_s
|
104
|
+
if added_methods.include?(stringified_name)
|
105
|
+
attribute(:redefined, true, {}, stringified_name)
|
106
|
+
end
|
107
|
+
added_methods << stringified_name
|
101
108
|
end
|
102
109
|
|
103
110
|
# Rolls up all of the test* methods in the fixture into
|
@@ -191,12 +198,12 @@ module Test
|
|
191
198
|
def shutdown
|
192
199
|
end
|
193
200
|
|
194
|
-
@@
|
201
|
+
@@test_orders = {}
|
195
202
|
|
196
203
|
# Returns the current test order. This returns
|
197
204
|
# +:alphabetic+ by default.
|
198
205
|
def test_order
|
199
|
-
@@
|
206
|
+
@@test_orders[self] || AVAILABLE_ORDERS.first
|
200
207
|
end
|
201
208
|
|
202
209
|
# Sets the current test order.
|
@@ -209,7 +216,7 @@ module Test
|
|
209
216
|
# [:defined]
|
210
217
|
# Tests are sorted in defined order.
|
211
218
|
def test_order=(order)
|
212
|
-
@@
|
219
|
+
@@test_orders[self] = order
|
213
220
|
end
|
214
221
|
|
215
222
|
# Defines a test in declarative syntax.
|
@@ -266,9 +273,10 @@ module Test
|
|
266
273
|
end
|
267
274
|
|
268
275
|
def sort_test_names_in_defined_order(test_names)
|
276
|
+
added_methods = @@added_methods[self]
|
269
277
|
test_names.sort do |test1, test2|
|
270
|
-
test1_defined_order =
|
271
|
-
test2_defined_order =
|
278
|
+
test1_defined_order = added_methods.index(test1)
|
279
|
+
test2_defined_order = added_methods.index(test2)
|
272
280
|
if test1_defined_order and test2_defined_order
|
273
281
|
test1_defined_order <=> test2_defined_order
|
274
282
|
elsif test1_defined_order
|
@@ -438,6 +446,9 @@ module Test
|
|
438
446
|
end
|
439
447
|
|
440
448
|
def run_test
|
449
|
+
if self.class.get_attribute(@method_name, :redefined)
|
450
|
+
notify("#{self.class}\##{@method_name} was redefined")
|
451
|
+
end
|
441
452
|
__send__(@method_name)
|
442
453
|
end
|
443
454
|
|
@@ -39,6 +39,7 @@ module Test
|
|
39
39
|
@progress_row_max ||= guess_progress_row_max
|
40
40
|
@already_outputted = false
|
41
41
|
@n_successes = 0
|
42
|
+
@n_omissions = 0
|
42
43
|
@indent = 0
|
43
44
|
@top_level = true
|
44
45
|
@faults = []
|
@@ -84,7 +85,8 @@ module Test
|
|
84
85
|
def add_fault(fault)
|
85
86
|
@faults << fault
|
86
87
|
output_progress(fault.single_character_display, fault_color(fault))
|
87
|
-
@
|
88
|
+
@n_omissions += 1 if fault.is_a?(Omission)
|
89
|
+
@already_outputted = true if fault.critical?
|
88
90
|
end
|
89
91
|
|
90
92
|
def started(result)
|
@@ -107,7 +109,7 @@ module Test
|
|
107
109
|
output("Finished in #{elapsed_time} seconds.")
|
108
110
|
nl
|
109
111
|
output(@result, result_color)
|
110
|
-
n_tests = @result.run_count
|
112
|
+
n_tests = @result.run_count - @n_omissions
|
111
113
|
if n_tests.zero?
|
112
114
|
pass_percentage = 0
|
113
115
|
else
|
@@ -186,7 +188,7 @@ module Test
|
|
186
188
|
right_space = 8 * 2
|
187
189
|
left_space = @progress_row_max - right_space
|
188
190
|
left_space = left_space - indent.size - name.size
|
189
|
-
tab_stop = "\t" * (
|
191
|
+
tab_stop = "\t" * ([left_space - 1, 0].max / 8)
|
190
192
|
output_single("#{indent}#{name}:#{tab_stop}", nil, VERBOSE)
|
191
193
|
@test_start = Time.now
|
192
194
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Test
|
2
|
+
module Unit
|
3
|
+
module Util
|
4
|
+
module Output
|
5
|
+
##
|
6
|
+
# Returns output for standard output and standard
|
7
|
+
# error as string.
|
8
|
+
#
|
9
|
+
# Example:
|
10
|
+
# capture_output do
|
11
|
+
# puts("stdout")
|
12
|
+
# warn("stderr")
|
13
|
+
# end # -> ["stdout\n", "stderr\n"]
|
14
|
+
def capture_output
|
15
|
+
require 'stringio'
|
16
|
+
|
17
|
+
output = StringIO.new
|
18
|
+
error = StringIO.new
|
19
|
+
stdout_save, stderr_save = $stdout, $stderr
|
20
|
+
$stdout, $stderr = output, error
|
21
|
+
begin
|
22
|
+
yield
|
23
|
+
[output.string, error.string]
|
24
|
+
ensure
|
25
|
+
$stdout, $stderr = stdout_save, stderr_save
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|