activesambaldap 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. data/NEWS.en +20 -18
  2. data/NEWS.ja +23 -21
  3. data/README.en +122 -95
  4. data/README.ja +125 -98
  5. data/Rakefile +29 -64
  6. data/bin/asl-groupadd +1 -1
  7. data/bin/asl-groupadd.help +1 -0
  8. data/bin/asl-groupdel +1 -1
  9. data/bin/asl-groupdel.help +1 -0
  10. data/bin/asl-groupmod +1 -1
  11. data/bin/asl-groupmod.help +1 -0
  12. data/bin/asl-groupshow +1 -1
  13. data/bin/asl-groupshow.help +1 -0
  14. data/bin/asl-passwd +1 -1
  15. data/bin/asl-passwd.help +1 -0
  16. data/bin/asl-populate +2 -2
  17. data/bin/asl-populate.help +1 -0
  18. data/bin/asl-purge +1 -1
  19. data/bin/asl-purge.help +1 -0
  20. data/bin/asl-samba-computeradd +1 -1
  21. data/bin/asl-samba-computeradd.help +1 -0
  22. data/bin/asl-samba-groupadd +1 -1
  23. data/bin/asl-samba-groupadd.help +1 -0
  24. data/bin/asl-samba-groupdel +1 -1
  25. data/bin/asl-samba-groupdel.help +1 -0
  26. data/bin/asl-samba-groupmod +1 -1
  27. data/bin/asl-samba-groupmod.help +1 -0
  28. data/bin/asl-samba-useradd +1 -1
  29. data/bin/asl-samba-useradd.help +1 -0
  30. data/bin/asl-samba-userdel +1 -1
  31. data/bin/asl-samba-userdel.help +1 -0
  32. data/bin/asl-samba-usermod +1 -1
  33. data/bin/asl-samba-usermod.help +1 -0
  34. data/bin/asl-useradd +1 -1
  35. data/bin/asl-useradd.help +6 -4
  36. data/bin/asl-userdel +1 -1
  37. data/bin/asl-userdel.help +1 -0
  38. data/bin/asl-usermod +1 -1
  39. data/bin/asl-usermod.help +2 -0
  40. data/bin/asl-usershow +1 -1
  41. data/bin/asl-usershow.help +1 -0
  42. data/data/locale/ja/LC_MESSAGES/active-samba-ldap.mo +0 -0
  43. data/lib/active_samba_ldap/version.rb +1 -1
  44. data/lib/active_samba_ldap.rb +1 -1
  45. data/po/ja/active-samba-ldap.po +5 -5
  46. data/rails/{plugin/active_samba_ldap/README → README} +0 -0
  47. data/rails/{plugin/active_samba_ldap/init.rb → init.rb} +1 -1
  48. data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/scaffold_active_samba_ldap_generator.rb +0 -0
  49. data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/computer.rb +0 -0
  50. data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/dc.rb +0 -0
  51. data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/group.rb +0 -0
  52. data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/idmap.rb +0 -0
  53. data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/ldap.yml +0 -0
  54. data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/ou.rb +0 -0
  55. data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/samba_controller.rb +0 -0
  56. data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/samba_helper.rb +0 -0
  57. data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/samba_index.rhtml +0 -0
  58. data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/samba_populate.rhtml +0 -0
  59. data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/samba_purge.rhtml +0 -0
  60. data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/unix_id_pool.rb +0 -0
  61. data/{rails/plugin/active_samba_ldap/generators → rails_generators}/scaffold_active_samba_ldap/templates/user.rb +0 -0
  62. data/test/asl-test-utils.rb +2 -2
  63. data/test/test_asl_usershow.rb +2 -2
  64. data/test/test_password.rb +2 -2
  65. data/test/test_user_home_directory.rb +2 -2
  66. data/test-unit/History.txt +76 -1
  67. data/test-unit/README.txt +32 -12
  68. data/test-unit/Rakefile +19 -1
  69. data/test-unit/TODO +5 -0
  70. data/test-unit/lib/test/unit/assertions.rb +515 -88
  71. data/test-unit/lib/test/unit/autorunner.rb +93 -14
  72. data/test-unit/lib/test/unit/collector/load.rb +1 -1
  73. data/test-unit/lib/test/unit/collector.rb +1 -1
  74. data/test-unit/lib/test/unit/color-scheme.rb +86 -0
  75. data/test-unit/lib/test/unit/color.rb +40 -5
  76. data/test-unit/lib/test/unit/diff.rb +14 -0
  77. data/test-unit/lib/test/unit/fixture.rb +7 -16
  78. data/test-unit/lib/test/unit/notification.rb +9 -0
  79. data/test-unit/lib/test/unit/omission.rb +14 -0
  80. data/test-unit/lib/test/unit/pending.rb +16 -0
  81. data/test-unit/lib/test/unit/priority.rb +38 -3
  82. data/test-unit/lib/test/unit/runner/console.rb +8 -2
  83. data/test-unit/lib/test/unit/testcase.rb +263 -12
  84. data/test-unit/lib/test/unit/ui/console/testrunner.rb +58 -30
  85. data/test-unit/lib/test/unit/util/method-owner-finder.rb +28 -0
  86. data/test-unit/lib/test/unit/version.rb +1 -1
  87. data/test-unit/lib/test/unit.rb +62 -0
  88. data/test-unit/sample/test_user.rb +22 -0
  89. data/test-unit/test/collector/{test_descendant.rb → test-descendant.rb} +0 -0
  90. data/test-unit/test/collector/{test_load.rb → test-load.rb} +1 -1
  91. data/test-unit/test/{test_attribute.rb → test-attribute.rb} +0 -0
  92. data/test-unit/test/test-color-scheme.rb +56 -0
  93. data/test-unit/test/{test_color.rb → test-color.rb} +10 -0
  94. data/test-unit/test/{test_diff.rb → test-diff.rb} +0 -0
  95. data/test-unit/test/{test_emacs_runner.rb → test-emacs-runner.rb} +0 -0
  96. data/test-unit/test/test-fixture.rb +287 -0
  97. data/test-unit/test/{test_notification.rb → test-notification.rb} +4 -4
  98. data/test-unit/test/{test_omission.rb → test-omission.rb} +6 -6
  99. data/test-unit/test/{test_pending.rb → test-pending.rb} +12 -6
  100. data/test-unit/test/{test_priority.rb → test-priority.rb} +30 -0
  101. data/test-unit/test/{test_testcase.rb → test-testcase.rb} +100 -4
  102. data/test-unit/test/test_assertions.rb +462 -73
  103. data/test-unit/test/{testunit_test_util.rb → testunit-test-util.rb} +4 -2
  104. data/test-unit/test/ui/test_testrunmediator.rb +1 -1
  105. data/test-unit/test/util/test-method-owner-finder.rb +38 -0
  106. metadata +69 -79
  107. data/test-unit/test/test_fixture.rb +0 -275
@@ -1,4 +1,4 @@
1
- require 'test/unit'
1
+ require 'test/unit/color-scheme'
2
2
  require 'optparse'
3
3
 
4
4
  module Test
@@ -11,10 +11,24 @@ module Test
11
11
  class << self
12
12
  def register_runner(id, runner_builder=Proc.new)
13
13
  RUNNERS[id] = runner_builder
14
+ RUNNERS[id.to_s] = runner_builder
15
+ end
16
+
17
+ def runner(id)
18
+ RUNNERS[id.to_s]
14
19
  end
15
20
 
16
21
  def register_collector(id, collector_builder=Proc.new)
17
22
  COLLECTORS[id] = collector_builder
23
+ COLLECTORS[id.to_s] = collector_builder
24
+ end
25
+
26
+ def collector(id)
27
+ COLLECTORS[id.to_s]
28
+ end
29
+
30
+ def register_color_scheme(id, scheme)
31
+ ColorScheme[id] = scheme
18
32
  end
19
33
 
20
34
  def setup_option(option_builder=Proc.new)
@@ -76,6 +90,7 @@ module Test
76
90
 
77
91
  attr_reader :suite, :runner_options
78
92
  attr_accessor :filters, :to_run, :pattern, :exclude, :base, :workdir
93
+ attr_accessor :color_scheme
79
94
  attr_writer :runner, :collector
80
95
 
81
96
  def initialize(standalone)
@@ -85,8 +100,11 @@ module Test
85
100
  @collector = default_collector
86
101
  @filters = []
87
102
  @to_run = []
103
+ @color_scheme = ColorScheme.default
88
104
  @runner_options = {}
89
105
  @workdir = nil
106
+ default_config_file = "test-unit.yml"
107
+ load_config(default_config_file) if File.exist?(default_config_file)
90
108
  yield(self) if block_given?
91
109
  end
92
110
 
@@ -96,8 +114,7 @@ module Test
96
114
  rescue OptionParser::ParseError => e
97
115
  puts e
98
116
  puts options
99
- $! = nil
100
- abort
117
+ exit(false)
101
118
  else
102
119
  @filters << proc{false} unless(@filters.empty?)
103
120
  end
@@ -116,7 +133,7 @@ module Test
116
133
  @runner = r
117
134
  end
118
135
 
119
- if(@standalone)
136
+ if (@standalone)
120
137
  o.on('-b', '--basedir=DIR', "Base directory of test suites.") do |b|
121
138
  @base = b
122
139
  end
@@ -169,22 +186,53 @@ module Test
169
186
  end
170
187
 
171
188
  priority_filter = Proc.new do |test|
172
- Priority::Checker.new(test).need_to_run? or nil
189
+ if @filters.size > 2
190
+ nil
191
+ else
192
+ Priority::Checker.new(test).need_to_run? or nil
193
+ end
173
194
  end
174
195
  o.on("--[no-]priority-mode",
175
196
  "Runs some tests based on their priority.") do |priority_mode|
176
197
  if priority_mode
198
+ Priority.enable
177
199
  @filters |= [priority_filter]
178
200
  else
201
+ Priority.disable
179
202
  @filters -= [priority_filter]
180
203
  end
181
204
  end
182
205
 
206
+ o.on("--default-priority=PRIORITY",
207
+ Priority.available_values,
208
+ "Uses PRIORITY as default priority",
209
+ "(#{keyword_display(Priority.available_values)})") do |priority|
210
+ Priority.default = priority
211
+ end
212
+
183
213
  o.on('-I', "--load-path=DIR[#{File::PATH_SEPARATOR}DIR...]",
184
214
  "Appends directory list to $LOAD_PATH.") do |dirs|
185
215
  $LOAD_PATH.concat(dirs.split(File::PATH_SEPARATOR))
186
216
  end
187
217
 
218
+ color_schemes = ColorScheme.all
219
+ o.on("--color-scheme=SCHEME", color_schemes,
220
+ "Use SCHEME as color scheme.",
221
+ "(#{keyword_display(color_schemes)})") do |scheme|
222
+ @color_scheme = scheme
223
+ end
224
+
225
+ o.on("--config=FILE",
226
+ "Use YAML fomat FILE content as configuration file.") do |file|
227
+ load_config(file)
228
+ end
229
+
230
+ o.on("--order=ORDER", TestCase::AVAILABLE_ORDERS,
231
+ "Run tests in a test case in ORDER order.",
232
+ "(#{keyword_display(TestCase::AVAILABLE_ORDERS)})") do |order|
233
+ TestCase.test_order = order
234
+ end
235
+
188
236
  ADDITIONAL_OPTIONS.each do |option_builder|
189
237
  option_builder.call(self, o)
190
238
  end
@@ -201,13 +249,13 @@ module Test
201
249
 
202
250
  o.on_tail('--console', 'Console runner (use --runner).') do
203
251
  warn("Deprecated option (--console).")
204
- @runner = RUNNERS[:console]
252
+ @runner = self.class.runner(:console)
205
253
  end
206
254
 
207
255
  if RUNNERS[:fox]
208
256
  o.on_tail('--fox', 'Fox runner (use --runner).') do
209
257
  warn("Deprecated option (--fox).")
210
- @runner = RUNNERS[:fox]
258
+ @runner = self.class.runner(:fox)
211
259
  end
212
260
  end
213
261
 
@@ -215,10 +263,22 @@ module Test
215
263
  end
216
264
  end
217
265
 
218
- def keyword_display(array)
219
- list = array.collect {|e, *| e.to_s}
220
- Array === array or list.sort!
221
- list.collect {|e| e.sub(/^(.)([A-Za-z]+)(?=\w*$)/, '\\1[\\2]')}.join(", ")
266
+ def keyword_display(keywords)
267
+ keywords = keywords.collect do |keyword, _|
268
+ keyword.to_s
269
+ end.uniq.sort
270
+
271
+ i = 0
272
+ keywords.collect do |keyword|
273
+ if (i > 0 and keyword[0] == keywords[i - 1][0]) or
274
+ ((i < keywords.size - 1) and (keyword[0] == keywords[i + 1][0]))
275
+ n = 2
276
+ else
277
+ n = 1
278
+ end
279
+ i += 1
280
+ keyword.sub(/^(.{#{n}})([A-Za-z]+)(?=\w*$)/, '\\1[\\2]')
281
+ end.join(", ")
222
282
  end
223
283
 
224
284
  def run
@@ -226,21 +286,40 @@ module Test
226
286
  return false if suite.nil?
227
287
  runner = @runner[self]
228
288
  return false if runner.nil?
289
+ @runner_options[:color_scheme] ||= @color_scheme
229
290
  Dir.chdir(@workdir) if @workdir
230
291
  runner.run(suite, @runner_options).passed?
231
292
  end
232
293
 
294
+ def load_config(file)
295
+ require 'yaml'
296
+ config = YAML.load(File.read(file))
297
+ runner_name = config["runner"]
298
+ @runner = self.class.runner(runner_name) || @runner
299
+ @collector = self.class.collector(config["collector"]) || @collector
300
+ (config["color_schemes"] || {}).each do |name, options|
301
+ ColorScheme[name] = options
302
+ end
303
+ runner_options = {}
304
+ (config["#{runner_name}_options"] || {}).each do |key, value|
305
+ key = key.to_sym
306
+ value = ColorScheme[value] if key == :color_scheme
307
+ runner_options[key.to_sym] = value
308
+ end
309
+ @runner_options = @runner_options.merge(runner_options)
310
+ end
311
+
233
312
  private
234
313
  def default_runner
235
314
  if ENV["EMACS"] == "t"
236
- RUNNERS[:emacs]
315
+ self.class.runner(:emacs)
237
316
  else
238
- RUNNERS[:console]
317
+ self.class.runner(:console)
239
318
  end
240
319
  end
241
320
 
242
321
  def default_collector
243
- COLLECTORS[@standalone ? :load : :descendant]
322
+ self.class.collector(@standalone ? :load : :descendant)
244
323
  end
245
324
  end
246
325
  end
@@ -15,7 +15,7 @@ module Test
15
15
  super
16
16
  @system_excludes = [/~\z/, /\A\.\#/]
17
17
  @system_directory_excludes = [/\A(?:CVS|\.svn)\z/]
18
- @patterns = [/\Atest_.+\.rb\z/m]
18
+ @patterns = [/\Atest[_\-].+\.rb\z/m]
19
19
  @excludes = []
20
20
  @base = nil
21
21
  end
@@ -36,7 +36,7 @@ module Test
36
36
  end
37
37
 
38
38
  def sort(suites)
39
- suites.sort_by{|s| s.name}
39
+ suites.sort_by {|suite| suite.name || suite.to_s}
40
40
  end
41
41
  end
42
42
  end
@@ -0,0 +1,86 @@
1
+ require 'test/unit/color'
2
+
3
+ module Test
4
+ module Unit
5
+ class ColorScheme
6
+ include Enumerable
7
+
8
+ class << self
9
+ @@default = nil
10
+ def default
11
+ @@default ||= new("success" => Color.new("green", :bold => true),
12
+ "failure" => Color.new("red", :bold => true),
13
+ "pending" => Color.new("magenta", :bold => true),
14
+ "omission" => Color.new("blue", :bold => true),
15
+ "notification" => Color.new("cyan", :bold => true),
16
+ "error" => Color.new("yellow", :bold => true) +
17
+ Color.new("black", :foreground => false))
18
+ end
19
+
20
+ @@schemes = {}
21
+ def all
22
+ @@schemes.merge("default" => default)
23
+ end
24
+
25
+ def [](id)
26
+ @@schemes[id.to_s]
27
+ end
28
+
29
+ def []=(id, scheme_or_spec)
30
+ if scheme_or_spec.is_a?(self)
31
+ scheme = scheme_or_spec
32
+ else
33
+ scheme = new(scheme_or_spec)
34
+ end
35
+ @@schemes[id.to_s] = scheme
36
+ end
37
+ end
38
+
39
+ def initialize(scheme_spec)
40
+ @scheme = {}
41
+ scheme_spec.each do |key, color_spec|
42
+ self[key] = color_spec
43
+ end
44
+ end
45
+
46
+ def [](name)
47
+ @scheme[name.to_s]
48
+ end
49
+
50
+ def []=(name, color_spec)
51
+ @scheme[name.to_s] = make_color(color_spec)
52
+ end
53
+
54
+ def each(&block)
55
+ @scheme.each(&block)
56
+ end
57
+
58
+ def to_hash
59
+ hash = {}
60
+ @scheme.each do |key, color|
61
+ hash[key] = color
62
+ end
63
+ hash
64
+ end
65
+
66
+ private
67
+ def make_color(color_spec)
68
+ if color_spec.is_a?(Color) or color_spec.is_a?(MixColor)
69
+ color_spec
70
+ else
71
+ color_name = nil
72
+ normalized_color_spec = {}
73
+ color_spec.each do |key, value|
74
+ key = key.to_sym
75
+ if key == :name
76
+ color_name = value
77
+ else
78
+ normalized_color_spec[key] = value
79
+ end
80
+ end
81
+ Color.new(color_name, normalized_color_spec)
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
@@ -3,6 +3,8 @@ module Test
3
3
  class Color
4
4
  NAMES = ["black", "red", "green", "yellow",
5
5
  "blue", "magenta", "cyan", "white"]
6
+
7
+ attr_reader :name
6
8
  def initialize(name, options={})
7
9
  @name = name
8
10
  @foreground = options[:foreground]
@@ -13,19 +15,47 @@ module Test
13
15
  @underline = options[:underline]
14
16
  end
15
17
 
18
+ def foreground?
19
+ @foreground
20
+ end
21
+
22
+ def intensity?
23
+ @intensity
24
+ end
25
+
26
+ def bold?
27
+ @bold
28
+ end
29
+
30
+ def italic?
31
+ @italic
32
+ end
33
+
34
+ def underline?
35
+ @underline
36
+ end
37
+
38
+ def ==(other)
39
+ self.class === other and
40
+ [name, foreground?, intensity?,
41
+ bold?, italic?, underline?] ==
42
+ [other.name, other.foreground?, other.intensity?,
43
+ other.bold?, other.italic?, other.underline?]
44
+ end
45
+
16
46
  def sequence
17
47
  sequence = []
18
48
  if @name == "none"
19
49
  elsif @name == "reset"
20
50
  sequence << "0"
21
51
  else
22
- foreground_parameter = @foreground ? 3 : 4
23
- foreground_parameter += 6 if @intensity
52
+ foreground_parameter = foreground? ? 3 : 4
53
+ foreground_parameter += 6 if intensity?
24
54
  sequence << "#{foreground_parameter}#{NAMES.index(@name)}"
25
55
  end
26
- sequence << "1" if @bold
27
- sequence << "3" if @italic
28
- sequence << "4" if @underline
56
+ sequence << "1" if bold?
57
+ sequence << "3" if italic?
58
+ sequence << "4" if underline?
29
59
  sequence
30
60
  end
31
61
 
@@ -39,6 +69,7 @@ module Test
39
69
  end
40
70
 
41
71
  class MixColor
72
+ attr_reader :colors
42
73
  def initialize(colors)
43
74
  @colors = colors
44
75
  end
@@ -56,6 +87,10 @@ module Test
56
87
  def +(other)
57
88
  self.class.new([self, other])
58
89
  end
90
+
91
+ def ==(other)
92
+ self.class === other and colors == other.colors
93
+ end
59
94
  end
60
95
  end
61
96
  end
@@ -507,6 +507,20 @@ module Test
507
507
  end
508
508
 
509
509
  module_function
510
+ def need_fold?(diff)
511
+ /^[-+].{79}/ =~ diff
512
+ end
513
+
514
+ def fold(string)
515
+ string.split(/\r?\n/).collect do |line|
516
+ line.gsub(/(.{78})/, "\\1\n")
517
+ end.join("\n")
518
+ end
519
+
520
+ def folded_readable(from, to, options={})
521
+ readable(fold(from), fold(to), options)
522
+ end
523
+
510
524
  def readable(from, to, options={})
511
525
  diff(ReadableDiffer, from, to, options)
512
526
  end
@@ -90,17 +90,14 @@ module Test
90
90
  end
91
91
 
92
92
  def add_fixture_method_name(how, variable_name, method_name)
93
- unless self.instance_variable_defined?(variable_name)
94
- self.instance_variable_set(variable_name, [])
95
- end
96
- methods = self.instance_variable_get(variable_name)
93
+ methods = instance_eval("#{variable_name} ||= []")
97
94
 
98
95
  if how == :prepend
99
96
  methods = [method_name] | methods
100
97
  else
101
98
  methods = methods | [method_name]
102
99
  end
103
- self.instance_variable_set(variable_name, methods)
100
+ instance_variable_set(variable_name, methods)
104
101
  end
105
102
 
106
103
  def registered_methods_variable_name(fixture, order)
@@ -144,19 +141,13 @@ module Test
144
141
  interested_ancestors.inject([]) do |result, ancestor|
145
142
  if ancestor.is_a?(Class)
146
143
  ancestor.class_eval do
147
- methods = []
148
- unregistered_methods = []
149
- if instance_variable_defined?(methods_variable)
150
- methods = instance_variable_get(methods_variable)
151
- end
152
- if instance_variable_defined?(unregistered_methods_variable)
153
- unregistered_methods =
154
- instance_variable_get(unregistered_methods_variable)
155
- end
156
- result + methods - unregistered_methods
144
+ methods = instance_eval("#{methods_variable} ||= []")
145
+ unregistered_methods =
146
+ instance_eval("#{unregistered_methods_variable} ||= []")
147
+ (result | methods) - unregistered_methods
157
148
  end
158
149
  else
159
- []
150
+ result
160
151
  end
161
152
  end
162
153
  end
@@ -56,6 +56,15 @@ module Test
56
56
  end
57
57
  end
58
58
 
59
+ # Notify some information.
60
+ #
61
+ # Example:
62
+ # def test_notification
63
+ # notify("I'm here!")
64
+ # # Reached here
65
+ # notify("Special!") if special_case?
66
+ # # Reached here too
67
+ # end
59
68
  def notify(message, &block)
60
69
  notification = Notification.new(name, filter_backtrace(caller), message)
61
70
  add_notification(notification)
@@ -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,32 @@ 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
29
+
30
+ @@default = :normal
31
+ def default
32
+ @@default || :normal
33
+ end
34
+
35
+ def default=(default)
36
+ @@default = default
37
+ end
38
+
39
+ def available_values
40
+ Checker.available_priorities
41
+ end
16
42
  end
17
43
 
18
44
  class Checker
@@ -23,7 +49,7 @@ module Test
23
49
  end
24
50
 
25
51
  def need_to_run?(test)
26
- priority = test[:priority] || :normal
52
+ priority = test[:priority] || Priority.default
27
53
  if have_priority?(priority)
28
54
  send(priority_check_method_name(priority), test)
29
55
  else
@@ -31,6 +57,13 @@ module Test
31
57
  end
32
58
  end
33
59
 
60
+ def available_priorities
61
+ methods(false).collect do |name|
62
+ /\Arun_priority_(.+)\?\z/ =~ name.to_s
63
+ $1
64
+ end.compact
65
+ end
66
+
34
67
  def run_priority_must?(test)
35
68
  true
36
69
  end
@@ -90,7 +123,7 @@ module Test
90
123
  def result_dir
91
124
  components = [".test-result",
92
125
  @test.class.name || "AnonymousTestCase",
93
- @test.method_name.to_s]
126
+ escaped_method_name]
94
127
  parent_directories = [File.dirname($0), Dir.pwd]
95
128
  if Process.respond_to?(:uid)
96
129
  parent_directories << File.join(Dir.tmpdir, Process.uid.to_s)
@@ -112,7 +145,7 @@ module Test
112
145
  end
113
146
 
114
147
  def escaped_method_name
115
- @method_name.to_s.gsub(/[!?=]$/) do |matched|
148
+ @test.method_name.to_s.gsub(/[!?=]$/) do |matched|
116
149
  case matched
117
150
  when "!"
118
151
  ".destructive"
@@ -135,10 +168,12 @@ module Test
135
168
  end
136
169
 
137
170
  def priority_setup
171
+ return unless Priority.enabled?
138
172
  Checker.new(self).setup
139
173
  end
140
174
 
141
175
  def priority_teardown
176
+ return unless Priority.enabled?
142
177
  Checker.new(self).teardown
143
178
  end
144
179
  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
- "Use color output",
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