activeldap 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. data/CHANGES +17 -0
  2. data/README +7 -1
  3. data/Rakefile +2 -1
  4. data/benchmark/bench-al.rb +3 -3
  5. data/examples/al-admin/app/helpers/users_helper.rb +1 -1
  6. data/examples/al-admin/config/environment.rb +4 -3
  7. data/examples/al-admin/config/initializers/gettext.rb +1 -0
  8. data/examples/al-admin/config/session_secret.txt +1 -1
  9. data/examples/al-admin/po/al-admin.pot +344 -0
  10. data/examples/al-admin/public/images/active-ldap.png +0 -0
  11. data/examples/al-admin/vendor/locale_rails/.gitignore +6 -0
  12. data/examples/al-admin/vendor/locale_rails/COPYING +56 -0
  13. data/examples/al-admin/vendor/locale_rails/ChangeLog +35 -0
  14. data/examples/al-admin/vendor/locale_rails/README.rdoc +62 -0
  15. data/examples/al-admin/vendor/locale_rails/Rakefile +73 -0
  16. data/examples/al-admin/vendor/locale_rails/lib/locale_rails.rb +18 -0
  17. data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_controller.rb +15 -0
  18. data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_controller/base.rb +82 -0
  19. data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_controller/caching.rb +51 -0
  20. data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_controller/test_process.rb +44 -0
  21. data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_view.rb +53 -0
  22. data/examples/al-admin/vendor/locale_rails/lib/locale_rails/i18n.rb +67 -0
  23. data/examples/al-admin/vendor/locale_rails/lib/locale_rails/version.rb +4 -0
  24. data/examples/al-admin/vendor/locale_rails/sample/README +22 -0
  25. data/examples/al-admin/vendor/locale_rails/sample/Rakefile +10 -0
  26. data/examples/al-admin/vendor/locale_rails/sample/app/controllers/application.rb +42 -0
  27. data/examples/al-admin/vendor/locale_rails/sample/app/controllers/samples_controller.rb +30 -0
  28. data/examples/al-admin/vendor/locale_rails/sample/app/helpers/application_helper.rb +3 -0
  29. data/examples/al-admin/vendor/locale_rails/sample/app/views/layouts/samples.html.erb +20 -0
  30. data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/_part.html.erb +68 -0
  31. data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/_part_nl.html.erb +2 -0
  32. data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/cached_action.html.erb +6 -0
  33. data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/index.html.erb +33 -0
  34. data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/index.pt.html.erb +16 -0
  35. data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/index_uz_UZ.html.erb +16 -0
  36. data/examples/al-admin/vendor/locale_rails/sample/config/boot.rb +109 -0
  37. data/examples/al-admin/vendor/locale_rails/sample/config/environment.rb +25 -0
  38. data/examples/al-admin/vendor/locale_rails/sample/config/environments/development.rb +17 -0
  39. data/examples/al-admin/vendor/locale_rails/sample/config/environments/production.rb +24 -0
  40. data/examples/al-admin/vendor/locale_rails/sample/config/environments/test.rb +22 -0
  41. data/examples/al-admin/vendor/locale_rails/sample/config/initializers/inflections.rb +10 -0
  42. data/examples/al-admin/vendor/locale_rails/sample/config/initializers/mime_types.rb +5 -0
  43. data/examples/al-admin/vendor/locale_rails/sample/config/initializers/new_rails_defaults.rb +17 -0
  44. data/examples/al-admin/vendor/locale_rails/sample/config/locales/en.yml +2 -0
  45. data/examples/al-admin/vendor/locale_rails/sample/config/locales/ja.yml +2 -0
  46. data/examples/al-admin/vendor/locale_rails/sample/config/routes.rb +13 -0
  47. data/examples/al-admin/vendor/locale_rails/sample/db/schema.rb +10 -0
  48. data/examples/al-admin/vendor/locale_rails/sample/public/404.html +30 -0
  49. data/examples/al-admin/vendor/locale_rails/sample/public/422.html +30 -0
  50. data/examples/al-admin/vendor/locale_rails/sample/public/500.html +33 -0
  51. data/examples/al-admin/vendor/locale_rails/sample/public/dispatch.cgi +10 -0
  52. data/examples/al-admin/vendor/locale_rails/sample/public/dispatch.fcgi +24 -0
  53. data/examples/al-admin/vendor/locale_rails/sample/public/dispatch.rb +10 -0
  54. data/examples/al-admin/vendor/locale_rails/sample/public/favicon.ico +0 -0
  55. data/examples/al-admin/vendor/locale_rails/sample/public/images/rails.png +0 -0
  56. data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/application.js +2 -0
  57. data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/controls.js +963 -0
  58. data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/dragdrop.js +972 -0
  59. data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/effects.js +1120 -0
  60. data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/prototype.js +4221 -0
  61. data/examples/al-admin/vendor/locale_rails/sample/public/robots.txt +5 -0
  62. data/examples/al-admin/vendor/locale_rails/sample/public/stylesheets/locale.css +81 -0
  63. data/examples/al-admin/vendor/locale_rails/sample/public/stylesheets/scaffold.css +74 -0
  64. data/examples/al-admin/vendor/locale_rails/sample/script/about +4 -0
  65. data/examples/al-admin/vendor/locale_rails/sample/script/console +3 -0
  66. data/examples/al-admin/vendor/locale_rails/sample/script/dbconsole +3 -0
  67. data/examples/al-admin/vendor/locale_rails/sample/script/destroy +3 -0
  68. data/examples/al-admin/vendor/locale_rails/sample/script/generate +3 -0
  69. data/examples/al-admin/vendor/locale_rails/sample/script/performance/benchmarker +3 -0
  70. data/examples/al-admin/vendor/locale_rails/sample/script/performance/profiler +3 -0
  71. data/examples/al-admin/vendor/locale_rails/sample/script/performance/request +3 -0
  72. data/examples/al-admin/vendor/locale_rails/sample/script/plugin +3 -0
  73. data/examples/al-admin/vendor/locale_rails/sample/script/process/inspector +3 -0
  74. data/examples/al-admin/vendor/locale_rails/sample/script/process/reaper +3 -0
  75. data/examples/al-admin/vendor/locale_rails/sample/script/process/spawner +3 -0
  76. data/examples/al-admin/vendor/locale_rails/sample/script/runner +3 -0
  77. data/examples/al-admin/vendor/locale_rails/sample/script/server +3 -0
  78. data/examples/al-admin/vendor/locale_rails/sample/test/performance/browsing_test.rb +9 -0
  79. data/examples/al-admin/vendor/locale_rails/sample/test/test_helper.rb +38 -0
  80. data/examples/al-admin/vendor/locale_rails/test/README +243 -0
  81. data/examples/al-admin/vendor/locale_rails/test/Rakefile +10 -0
  82. data/examples/al-admin/vendor/locale_rails/test/app/controllers/application_controller.rb +10 -0
  83. data/examples/al-admin/vendor/locale_rails/test/app/controllers/articles_controller.rb +17 -0
  84. data/examples/al-admin/vendor/locale_rails/test/app/helpers/application_helper.rb +3 -0
  85. data/examples/al-admin/vendor/locale_rails/test/app/views/articles/index.html.erb +1 -0
  86. data/examples/al-admin/vendor/locale_rails/test/app/views/articles/index_de.html.erb +1 -0
  87. data/examples/al-admin/vendor/locale_rails/test/app/views/articles/index_fr_FR.html.erb +1 -0
  88. data/examples/al-admin/vendor/locale_rails/test/app/views/articles/index_ja.html.erb +1 -0
  89. data/examples/al-admin/vendor/locale_rails/test/app/views/articles/list.html.erb +1 -0
  90. data/examples/al-admin/vendor/locale_rails/test/app/views/articles/show.html.erb +0 -0
  91. data/examples/al-admin/vendor/locale_rails/test/app/views/articles/show.js.rjs +0 -0
  92. data/examples/al-admin/vendor/locale_rails/test/config/boot.rb +110 -0
  93. data/examples/al-admin/vendor/locale_rails/test/config/environment.rb +42 -0
  94. data/examples/al-admin/vendor/locale_rails/test/config/environments/development.rb +17 -0
  95. data/examples/al-admin/vendor/locale_rails/test/config/environments/production.rb +28 -0
  96. data/examples/al-admin/vendor/locale_rails/test/config/environments/test.rb +35 -0
  97. data/examples/al-admin/vendor/locale_rails/test/config/initializers/backtrace_silencers.rb +7 -0
  98. data/examples/al-admin/vendor/locale_rails/test/config/initializers/inflections.rb +10 -0
  99. data/examples/al-admin/vendor/locale_rails/test/config/initializers/mime_types.rb +5 -0
  100. data/examples/al-admin/vendor/locale_rails/test/config/initializers/new_rails_defaults.rb +19 -0
  101. data/examples/al-admin/vendor/locale_rails/test/config/initializers/session_store.rb +15 -0
  102. data/examples/al-admin/vendor/locale_rails/test/config/locales/en.yml +5 -0
  103. data/examples/al-admin/vendor/locale_rails/test/config/routes.rb +46 -0
  104. data/examples/al-admin/vendor/locale_rails/test/db/schema.rb +0 -0
  105. data/examples/al-admin/vendor/locale_rails/test/public/404.html +30 -0
  106. data/examples/al-admin/vendor/locale_rails/test/public/422.html +30 -0
  107. data/examples/al-admin/vendor/locale_rails/test/public/500.html +30 -0
  108. data/examples/al-admin/vendor/locale_rails/test/public/favicon.ico +0 -0
  109. data/examples/al-admin/vendor/locale_rails/test/public/images/rails.png +0 -0
  110. data/examples/al-admin/vendor/locale_rails/test/public/index.html +275 -0
  111. data/examples/al-admin/vendor/locale_rails/test/public/javascripts/application.js +2 -0
  112. data/examples/al-admin/vendor/locale_rails/test/public/javascripts/controls.js +963 -0
  113. data/examples/al-admin/vendor/locale_rails/test/public/javascripts/dragdrop.js +973 -0
  114. data/examples/al-admin/vendor/locale_rails/test/public/javascripts/effects.js +1128 -0
  115. data/examples/al-admin/vendor/locale_rails/test/public/javascripts/prototype.js +4320 -0
  116. data/examples/al-admin/vendor/locale_rails/test/public/robots.txt +5 -0
  117. data/examples/al-admin/vendor/locale_rails/test/script/about +4 -0
  118. data/examples/al-admin/vendor/locale_rails/test/script/console +3 -0
  119. data/examples/al-admin/vendor/locale_rails/test/script/dbconsole +3 -0
  120. data/examples/al-admin/vendor/locale_rails/test/script/destroy +3 -0
  121. data/examples/al-admin/vendor/locale_rails/test/script/generate +3 -0
  122. data/examples/al-admin/vendor/locale_rails/test/script/performance/benchmarker +3 -0
  123. data/examples/al-admin/vendor/locale_rails/test/script/performance/profiler +3 -0
  124. data/examples/al-admin/vendor/locale_rails/test/script/plugin +3 -0
  125. data/examples/al-admin/vendor/locale_rails/test/script/runner +3 -0
  126. data/examples/al-admin/vendor/locale_rails/test/script/server +3 -0
  127. data/examples/al-admin/vendor/locale_rails/test/test/functional/articles_controller_test.rb +161 -0
  128. data/examples/al-admin/vendor/locale_rails/test/test/performance/browsing_test.rb +9 -0
  129. data/examples/al-admin/vendor/locale_rails/test/test/test_helper.rb +38 -0
  130. data/lib/active_ldap.rb +9 -4
  131. data/lib/active_ldap/adapter/base.rb +3 -3
  132. data/lib/active_ldap/adapter/jndi.rb +1 -1
  133. data/lib/active_ldap/adapter/jndi_connection.rb +1 -3
  134. data/lib/active_ldap/adapter/ldap.rb +11 -11
  135. data/lib/active_ldap/adapter/ldap_ext.rb +25 -3
  136. data/lib/active_ldap/adapter/net_ldap.rb +9 -2
  137. data/lib/active_ldap/association/collection.rb +14 -2
  138. data/lib/active_ldap/base.rb +13 -5
  139. data/lib/active_ldap/configuration.rb +1 -0
  140. data/lib/active_ldap/ldap_error.rb +3 -3
  141. data/lib/active_ldap/ldif.rb +1 -1
  142. data/lib/active_ldap/operations.rb +2 -0
  143. data/lib/active_ldap/schema/syntaxes.rb +2 -2
  144. data/lib/active_ldap/validations.rb +37 -26
  145. data/lib/active_ldap/xml.rb +2 -0
  146. data/po/active-ldap.pot +38 -58
  147. data/test-unit/COPYING +56 -0
  148. data/test-unit/GPL +340 -0
  149. data/test-unit/History.txt +65 -3
  150. data/test-unit/Manifest.txt +5 -0
  151. data/test-unit/PSFL +271 -0
  152. data/test-unit/README.txt +6 -1
  153. data/test-unit/lib/test/unit.rb +6 -1
  154. data/test-unit/lib/test/unit/assertions.rb +129 -13
  155. data/test-unit/lib/test/unit/autorunner.rb +21 -16
  156. data/test-unit/lib/test/unit/collector.rb +1 -8
  157. data/test-unit/lib/test/unit/collector/dir.rb +1 -1
  158. data/test-unit/lib/test/unit/collector/load.rb +15 -7
  159. data/test-unit/lib/test/unit/color-scheme.rb +6 -2
  160. data/test-unit/lib/test/unit/diff.rb +17 -1
  161. data/test-unit/lib/test/unit/error.rb +4 -0
  162. data/test-unit/lib/test/unit/failure.rb +4 -0
  163. data/test-unit/lib/test/unit/notification.rb +8 -4
  164. data/test-unit/lib/test/unit/omission.rb +4 -0
  165. data/test-unit/lib/test/unit/pending.rb +4 -0
  166. data/test-unit/lib/test/unit/priority.rb +2 -3
  167. data/test-unit/lib/test/unit/testcase.rb +18 -7
  168. data/test-unit/lib/test/unit/ui/console/testrunner.rb +5 -3
  169. data/test-unit/lib/test/unit/util/backtracefilter.rb +1 -0
  170. data/test-unit/lib/test/unit/util/output.rb +31 -0
  171. data/test-unit/lib/test/unit/version.rb +1 -1
  172. data/test-unit/test/collector/test-descendant.rb +2 -4
  173. data/test-unit/test/collector/test-load.rb +121 -8
  174. data/test-unit/test/collector/test_objectspace.rb +7 -5
  175. data/test-unit/test/test-color-scheme.rb +4 -2
  176. data/test-unit/test/test-testcase.rb +48 -38
  177. data/test-unit/test/test_assertions.rb +87 -5
  178. data/test-unit/test/util/test-output.rb +11 -0
  179. data/test/al-test-utils.rb +6 -1
  180. data/test/fixtures/lower_case_object_class_schema.rb +802 -0
  181. data/test/test_associations.rb +20 -1
  182. data/test/test_base.rb +50 -3
  183. data/test/test_ldif.rb +10 -1
  184. data/test/test_syntax.rb +12 -0
  185. data/test/test_validation.rb +0 -2
  186. 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
- global_config_file = File.expand_path("~/.test-unit.xml")
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
- @default_arguments.concat(args)
130
- options.order!(@default_arguments) {|arg| @to_run << arg}
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 : nil}
183
+ @filters << proc{|t| n =~ t.method_name ? true : false}
190
184
  else
191
- @filters << proc{|t| n == t.method_name ? true : nil}
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 : nil}
195
+ @filters << proc{|t| n =~ t.class.name ? true : false}
202
196
  else
203
- @filters << proc{|t| n == t.class.name ? true : nil}
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.size > 2
209
- nil
202
+ if @filters == [priority_filter]
203
+ Priority::Checker.new(test).need_to_run?
210
204
  else
211
- Priority::Checker.new(test).need_to_run? or nil
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
- result = filter[test]
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 = froms.collect do |from|
32
- test_suite = collect_recursive(resolve_path(from), find_test_cases)
33
- test_suite = nil if test_suite.tests.empty?
34
- test_suite
35
- end.compact
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" => Color.new("green", :bold => true),
12
- "failure" => Color.new("red", :bold => true),
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).join("\n")
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
@@ -60,6 +60,10 @@ module Test
60
60
  def to_s
61
61
  long_display
62
62
  end
63
+
64
+ def critical?
65
+ true
66
+ end
63
67
  end
64
68
 
65
69
  module ErrorHandler
@@ -59,6 +59,10 @@ module Test
59
59
  long_display
60
60
  end
61
61
 
62
+ def critical?
63
+ true
64
+ end
65
+
62
66
  def diff
63
67
  @diff ||= compute_diff
64
68
  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(:handle_Notified_error)
86
+ base.exception_handler(:handle_notified_error)
83
87
  end
84
88
  end
85
89
 
86
90
  private
87
- def handle_Notified_error(exception)
91
+ def handle_notified_error(exception)
88
92
  return false unless exception.is_a?(NotifiedError)
89
93
  notification = Notification.new(name,
90
- filter_backtrace(exception.backtrace),
91
- exception.message)
94
+ filter_backtrace(exception.backtrace),
95
+ exception.message)
92
96
  add_notification(notification)
93
97
  true
94
98
  end
@@ -41,6 +41,10 @@ module Test
41
41
  def to_s
42
42
  long_display
43
43
  end
44
+
45
+ def critical?
46
+ true
47
+ end
44
48
  end
45
49
 
46
50
  class OmittedError < StandardError
@@ -41,6 +41,10 @@ module Test
41
41
  def to_s
42
42
  long_display
43
43
  end
44
+
45
+ def critical?
46
+ true
47
+ end
44
48
  end
45
49
 
46
50
  class PendedError < StandardError
@@ -1,6 +1,3 @@
1
- require "fileutils"
2
- require "tmpdir"
3
-
4
1
  module Test
5
2
  module Unit
6
3
  module Priority
@@ -20,6 +17,8 @@ module Test
20
17
  end
21
18
 
22
19
  def enable
20
+ require "fileutils"
21
+ require "tmpdir"
23
22
  @@enabled = true
24
23
  end
25
24
 
@@ -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 << name.to_s
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
- @@test_order = AVAILABLE_ORDERS.first
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
- @@test_order
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
- @@test_order = order
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 = @@added_methods.index(test1)
271
- test2_defined_order = @@added_methods.index(test2)
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
- @already_outputted = true
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" * ((left_space - 1) / 8)
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
@@ -9,6 +9,7 @@ module Test
9
9
  module_function
10
10
  def filter_backtrace(backtrace, prefix=nil)
11
11
  return ["No backtrace"] unless(backtrace)
12
+ return backtrace if ENV["TEST_UNIT_ALL_BACKTRACE"]
12
13
  split_p = if(prefix)
13
14
  prefix.split(TESTUNIT_FILE_SEPARATORS)
14
15
  else
@@ -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