test-unit 3.4.1 → 3.4.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -3
  3. data/Rakefile +0 -9
  4. data/doc/text/getting-started.md +1 -1
  5. data/doc/text/news.md +49 -0
  6. data/lib/test/unit/assertions.rb +206 -13
  7. data/lib/test/unit/testcase.rb +3 -2
  8. data/lib/test/unit/testsuite.rb +1 -1
  9. data/lib/test/unit/ui/console/testrunner.rb +26 -0
  10. data/lib/test/unit/util/memory-usage.rb +47 -0
  11. data/lib/test/unit/version.rb +1 -1
  12. data/lib/test/unit.rb +4 -4
  13. metadata +6 -83
  14. data/test/collector/test-descendant.rb +0 -182
  15. data/test/collector/test-load.rb +0 -475
  16. data/test/collector/test_dir.rb +0 -407
  17. data/test/collector/test_objectspace.rb +0 -102
  18. data/test/fixtures/header-label.csv +0 -3
  19. data/test/fixtures/header-label.tsv +0 -3
  20. data/test/fixtures/header.csv +0 -3
  21. data/test/fixtures/header.tsv +0 -3
  22. data/test/fixtures/no-header.csv +0 -2
  23. data/test/fixtures/no-header.tsv +0 -2
  24. data/test/fixtures/plus.csv +0 -3
  25. data/test/run-test.rb +0 -22
  26. data/test/test-assertions.rb +0 -2187
  27. data/test/test-attribute-matcher.rb +0 -38
  28. data/test/test-attribute.rb +0 -123
  29. data/test/test-code-snippet.rb +0 -79
  30. data/test/test-color-scheme.rb +0 -123
  31. data/test/test-color.rb +0 -47
  32. data/test/test-data.rb +0 -419
  33. data/test/test-diff.rb +0 -518
  34. data/test/test-emacs-runner.rb +0 -60
  35. data/test/test-error.rb +0 -26
  36. data/test/test-failure.rb +0 -33
  37. data/test/test-fault-location-detector.rb +0 -163
  38. data/test/test-fixture.rb +0 -713
  39. data/test/test-notification.rb +0 -33
  40. data/test/test-omission.rb +0 -81
  41. data/test/test-pending.rb +0 -70
  42. data/test/test-priority.rb +0 -184
  43. data/test/test-test-case.rb +0 -1284
  44. data/test/test-test-result.rb +0 -113
  45. data/test/test-test-suite-creator.rb +0 -97
  46. data/test/test-test-suite.rb +0 -151
  47. data/test/testunit-test-util.rb +0 -33
  48. data/test/ui/test_testrunmediator.rb +0 -20
  49. data/test/util/test-method-owner-finder.rb +0 -38
  50. data/test/util/test-output.rb +0 -11
  51. data/test/util/test_backtracefilter.rb +0 -52
  52. data/test/util/test_observable.rb +0 -102
  53. data/test/util/test_procwrapper.rb +0 -36
@@ -1,475 +0,0 @@
1
- require 'tmpdir'
2
- require 'pathname'
3
-
4
- require 'test/unit'
5
- require 'test/unit/collector/load'
6
-
7
- class TestUnitCollectorLoad < Test::Unit::TestCase
8
- def setup
9
- @previous_descendants = Test::Unit::TestCase::DESCENDANTS.dup
10
- Test::Unit::TestCase::DESCENDANTS.clear
11
-
12
- @temporary_test_cases_module_name = "TempTestCases"
13
- ::Object.const_set(@temporary_test_cases_module_name, Module.new)
14
-
15
- @test_dir = Pathname(Dir.tmpdir) + "test-unit"
16
- @extra_test_dir = Pathname(Dir.tmpdir) + "test-unit-extra"
17
- ensure_clean_directory(@test_dir)
18
- ensure_clean_directory(@extra_test_dir)
19
- end
20
-
21
- setup
22
- def setup_top_level_test_cases
23
- @test_case1_base_name = "test_case1.rb"
24
-
25
- @test_case1 = @test_dir + @test_case1_base_name
26
- @test_case2 = @test_dir + "test_case2.rb"
27
- @no_load_test_case3 = @test_dir + "case3.rb"
28
-
29
- @test_case1.open("w") do |test_case|
30
- test_case.puts(<<-EOT)
31
- module #{@temporary_test_cases_module_name}
32
- class TestCase1 < Test::Unit::TestCase
33
- def test1_1
34
- end
35
-
36
- def test1_2
37
- end
38
- end
39
- end
40
- EOT
41
- end
42
-
43
- @test_case2.open("w") do |test_case|
44
- test_case.puts(<<-EOT)
45
- module #{@temporary_test_cases_module_name}
46
- class TestCase2 < Test::Unit::TestCase
47
- def test2
48
- end
49
- end
50
- end
51
- EOT
52
- end
53
-
54
- @no_load_test_case3.open("w") do |test_case|
55
- test_case.puts(<<-EOT)
56
- module #{@temporary_test_cases_module_name}
57
- class NoLoadTestCase3 < Test::Unit::TestCase
58
- def test3
59
- end
60
- end
61
- end
62
- EOT
63
- end
64
- end
65
-
66
- setup
67
- def setup_sub_level_test_cases
68
- @sub_test_dir = @test_dir + "sub"
69
- @sub_test_dir.mkpath
70
-
71
- @sub_test_case1 = @sub_test_dir + @test_case1_base_name
72
- @sub_test_case4 = @sub_test_dir + "test_case4.rb"
73
- @no_load_sub_test_case5 = @sub_test_dir + "case5.rb"
74
- @sub_test_case6 = @sub_test_dir + "test_case6.rb"
75
-
76
- @sub_test_case1.open("w") do |test_case|
77
- test_case.puts(<<-TEST_CASE)
78
- module #{@temporary_test_cases_module_name}
79
- class SubTestCase1 < Test::Unit::TestCase
80
- def test1_1
81
- end
82
-
83
- def test1_2
84
- end
85
- end
86
- end
87
- TEST_CASE
88
- end
89
-
90
- @sub_test_case4.open("w") do |test_case|
91
- test_case.puts(<<-EOT)
92
- module #{@temporary_test_cases_module_name}
93
- class SubTestCase4 < Test::Unit::TestCase
94
- def test4_1
95
- end
96
-
97
- def test4_2
98
- end
99
- end
100
- end
101
- EOT
102
- end
103
-
104
- @no_load_sub_test_case5.open("w") do |test_case|
105
- test_case.puts(<<-EOT)
106
- module #{@temporary_test_cases_module_name}
107
- class NoLoadSubTestCase5 < Test::Unit::TestCase
108
- def test5_1
109
- end
110
-
111
- def test5_2
112
- end
113
- end
114
- end
115
- EOT
116
- end
117
-
118
- @sub_test_case6.open("w") do |test_case|
119
- test_case.puts(<<-EOT)
120
- module #{@temporary_test_cases_module_name}
121
- class SubTestCase6 < Test::Unit::TestCase
122
- def test6
123
- end
124
- end
125
- end
126
- EOT
127
- end
128
- end
129
-
130
- setup
131
- def setup_sub_level_test_cases2
132
- @sub2_test_dir = @test_dir + "sub2"
133
- @sub2_test_dir.mkpath
134
-
135
- @no_load_sub2_test_case7 = @sub2_test_dir + "case7.rb"
136
- @sub2_test_case8 = @sub2_test_dir + "test_case8.rb"
137
- @sub2_test_case9 = @sub2_test_dir + "test_case9.rb"
138
-
139
- @no_load_sub2_test_case7.open("w") do |test_case|
140
- test_case.puts(<<-EOT)
141
- module #{@temporary_test_cases_module_name}
142
- class NoLoadSub2TestCase7 < Test::Unit::TestCase
143
- def test7_1
144
- end
145
-
146
- def test7_2
147
- end
148
- end
149
- end
150
- EOT
151
- end
152
-
153
- @sub2_test_case8.open("w") do |test_case|
154
- test_case.puts(<<-EOT)
155
- module #{@temporary_test_cases_module_name}
156
- class Sub2TestCase8 < Test::Unit::TestCase
157
- def test8_1
158
- end
159
-
160
- def test8_2
161
- end
162
- end
163
- end
164
- EOT
165
- end
166
-
167
- @sub2_test_case9.open("w") do |test_case|
168
- test_case.puts(<<-EOT)
169
- module #{@temporary_test_cases_module_name}
170
- class Sub2TestCase9 < Test::Unit::TestCase
171
- def test9
172
- end
173
- end
174
- end
175
- EOT
176
- end
177
- end
178
-
179
- setup
180
- def setup_svn_test_cases
181
- @svn_test_dir = @test_dir + ".svn"
182
- @svn_test_dir.mkpath
183
-
184
- @svn_test_case10 = @svn_test_dir + "test_case10.rb"
185
-
186
- @svn_test_case10.open("w") do |test_case|
187
- test_case.puts(<<-EOT)
188
- module #{@temporary_test_cases_module_name}
189
- class SvnTestCase10 < Test::Unit::TestCase
190
- def test7
191
- end
192
- end
193
- end
194
- EOT
195
- end
196
- end
197
-
198
- setup
199
- def setup_sub_cvs_test_cases
200
- @sub_cvs_test_dir = @sub_test_dir + "CVS"
201
- @sub_cvs_test_dir.mkpath
202
-
203
- @sub_cvs_test_case11 = @sub_cvs_test_dir + "test_case11.rb"
204
-
205
- @sub_cvs_test_case11.open("w") do |test_case|
206
- test_case.puts(<<-EOT)
207
- module #{@temporary_test_cases_module_name}
208
- class SubCVSTestCase11 < Test::Unit::TestCase
209
- def test11
210
- end
211
- end
212
- end
213
- EOT
214
- end
215
- end
216
-
217
- setup
218
- def setup_sub_git_test_cases
219
- @sub_git_test_dir = @sub_test_dir + ".git"
220
- @sub_git_test_dir.mkpath
221
-
222
- @sub_git_test_case11 = @sub_git_test_dir + "test_case11.rb"
223
-
224
- @sub_git_test_case11.open("w") do |test_case|
225
- test_case.puts(<<-EOT)
226
- module #{@temporary_test_cases_module_name}
227
- class SubGitTestCase11 < Test::Unit::TestCase
228
- def test11
229
- end
230
- end
231
- end
232
- EOT
233
- end
234
- end
235
-
236
- setup
237
- def setup_extra_top_level_test_cases
238
- @test_cases12 = @extra_test_dir + "test_cases12.rb"
239
- @test_cases12.open("w") do |test_case|
240
- test_case.puts(<<-EOT)
241
- module #{@temporary_test_cases_module_name}
242
- class TestCase121 < Test::Unit::TestCase
243
- def test121_1
244
- end
245
-
246
- def test121_2
247
- end
248
- end
249
-
250
- class TestCase122 < Test::Unit::TestCase
251
- def test122_1
252
- end
253
-
254
- def test122_2
255
- end
256
- end
257
- end
258
- EOT
259
- end
260
- end
261
-
262
- setup
263
- def setup_sub_level_extra_test_cases
264
- @sub_extra_test_dir = @extra_test_dir + "sub"
265
- @sub_extra_test_dir.mkpath
266
-
267
- @cases13_test = @sub_extra_test_dir + "13cases_test.rb"
268
- @cases13_test.open("w") do |test_case|
269
- test_case.puts(<<-EOT)
270
- module #{@temporary_test_cases_module_name}
271
- class SubTestCase13 < Test::Unit::TestCase
272
- def test13_1
273
- end
274
-
275
- def test13_2
276
- end
277
- end
278
- end
279
- EOT
280
- end
281
- end
282
-
283
- def teardown
284
- @test_dir.rmtree if @test_dir.exist?
285
- ::Object.send(:remove_const, @temporary_test_cases_module_name)
286
- Test::Unit::TestCase::DESCENDANTS.replace(@previous_descendants)
287
- end
288
-
289
- def test_simple_collect
290
- assert_collect([:suite, {:name => @sub_test_dir.basename.to_s},
291
- [:suite, {:name => _test_case_name("SubTestCase1")},
292
- [:test, {:name => "test1_1"}],
293
- [:test, {:name => "test1_2"}]],
294
- [:suite, {:name => _test_case_name("SubTestCase4")},
295
- [:test, {:name => "test4_1"}],
296
- [:test, {:name => "test4_2"}]],
297
- [:suite, {:name => _test_case_name("SubTestCase6")},
298
- [:test, {:name => "test6"}]]],
299
- @sub_test_dir.to_s)
300
- end
301
-
302
- def test_simple_collect_test_suffix
303
- assert_collect([:suite, {:name => @extra_test_dir.basename.to_s},
304
- [:suite, {:name => _test_case_name("TestCase121")},
305
- [:test, {:name => "test121_1"}],
306
- [:test, {:name => "test121_2"}]],
307
- [:suite, {:name => _test_case_name("TestCase122")},
308
- [:test, {:name => "test122_1"}],
309
- [:test, {:name => "test122_2"}]],
310
- [:suite, {:name => @sub_extra_test_dir.basename.to_s},
311
- [:suite, {:name => _test_case_name("SubTestCase13")},
312
- [:test, {:name => "test13_1"}],
313
- [:test, {:name => "test13_2"}]]]],
314
- @extra_test_dir.to_s)
315
- end
316
-
317
- def test_multilevel_collect
318
- assert_collect([:suite, {:name => "."},
319
- [:suite, {:name => _test_case_name("TestCase1")},
320
- [:test, {:name => "test1_1"}],
321
- [:test, {:name => "test1_2"}]],
322
- [:suite, {:name => _test_case_name("TestCase2")},
323
- [:test, {:name => "test2"}]],
324
- [:suite, {:name => @sub_test_dir.basename.to_s},
325
- [:suite, {:name => _test_case_name("SubTestCase1")},
326
- [:test, {:name => "test1_1"}],
327
- [:test, {:name => "test1_2"}]],
328
- [:suite, {:name => _test_case_name("SubTestCase4")},
329
- [:test, {:name => "test4_1"}],
330
- [:test, {:name => "test4_2"}]],
331
- [:suite, {:name => _test_case_name("SubTestCase6")},
332
- [:test, {:name => "test6"}]]],
333
- [:suite, {:name => @sub2_test_dir.basename.to_s},
334
- [:suite, {:name => _test_case_name("Sub2TestCase8")},
335
- [:test, {:name => "test8_1"}],
336
- [:test, {:name => "test8_2"}]],
337
- [:suite, {:name => _test_case_name("Sub2TestCase9")},
338
- [:test, {:name => "test9"}]]]])
339
- end
340
-
341
- def test_collect_file
342
- assert_collect([:suite, {:name => _test_case_name("TestCase1")},
343
- [:test, {:name => "test1_1"}],
344
- [:test, {:name => "test1_2"}]],
345
- @test_case1.to_s)
346
- end
347
-
348
- def test_collect_file_no_pattern_match_file_name
349
- assert_collect([:suite, {:name => _test_case_name("NoLoadSubTestCase5")},
350
- [:test, {:name => "test5_1"}],
351
- [:test, {:name => "test5_2"}]],
352
- @no_load_sub_test_case5.to_s)
353
- end
354
-
355
- def test_collect_file_test_cases
356
- assert_collect([:suite, {:name => "[#{@test_cases12}]"},
357
- [:suite, {:name => _test_case_name("TestCase121")},
358
- [:test, {:name => "test121_1"}],
359
- [:test, {:name => "test121_2"}]],
360
- [:suite, {:name => _test_case_name("TestCase122")},
361
- [:test, {:name => "test122_1"}],
362
- [:test, {:name => "test122_2"}]]],
363
- @test_cases12.to_s)
364
- end
365
-
366
- def test_collect_files
367
- assert_collect([:suite,
368
- {:name => "[#{@test_case1}, #{@test_case2}]"},
369
- [:suite, {:name => _test_case_name("TestCase1")},
370
- [:test, {:name => "test1_1"}],
371
- [:test, {:name => "test1_2"}]],
372
- [:suite, {:name => _test_case_name("TestCase2")},
373
- [:test, {:name => "test2"}]]],
374
- @test_case1.to_s, @test_case2.to_s)
375
- end
376
-
377
- def test_nil_pattern
378
- assert_collect([:suite, {:name => @sub_test_dir.basename.to_s},
379
- [:suite, {:name => _test_case_name("NoLoadSubTestCase5")},
380
- [:test, {:name => "test5_1"}],
381
- [:test, {:name => "test5_2"}]],
382
- [:suite, {:name => _test_case_name("SubTestCase1")},
383
- [:test, {:name => "test1_1"}],
384
- [:test, {:name => "test1_2"}]],
385
- [:suite, {:name => _test_case_name("SubTestCase4")},
386
- [:test, {:name => "test4_1"}],
387
- [:test, {:name => "test4_2"}]],
388
- [:suite, {:name => _test_case_name("SubTestCase6")},
389
- [:test, {:name => "test6"}]]],
390
- @sub_test_dir.to_s) do |collector|
391
- collector.patterns.clear
392
- end
393
- end
394
-
395
- def test_filtering
396
- assert_collect([:suite, {:name => "."},
397
- [:suite, {:name => _test_case_name("TestCase1")},
398
- [:test, {:name => "test1_1"}],
399
- [:test, {:name => "test1_2"}]],
400
- [:suite, {:name => @sub_test_dir.basename.to_s},
401
- [:suite, {:name => _test_case_name("SubTestCase1")},
402
- [:test, {:name => "test1_1"}],
403
- [:test, {:name => "test1_2"}]]]]) do |collector|
404
- collector.filter = Proc.new do |test|
405
- !/\Atest1/.match(test.method_name).nil?
406
- end
407
- end
408
- end
409
-
410
- def test_collect_multi
411
- test_dirs = [@sub_test_dir.to_s, @sub2_test_dir.to_s]
412
- assert_collect([:suite, {:name => "[#{test_dirs.join(', ')}]"},
413
- [:suite, {:name => @sub_test_dir.basename.to_s},
414
- [:suite, {:name => _test_case_name("SubTestCase1")},
415
- [:test, {:name => "test1_1"}],
416
- [:test, {:name => "test1_2"}]],
417
- [:suite, {:name => _test_case_name("SubTestCase4")},
418
- [:test, {:name => "test4_1"}],
419
- [:test, {:name => "test4_2"}]],
420
- [:suite, {:name => _test_case_name("SubTestCase6")},
421
- [:test, {:name => "test6"}]]],
422
- [:suite, {:name => @sub2_test_dir.basename.to_s},
423
- [:suite, {:name => _test_case_name("Sub2TestCase8")},
424
- [:test, {:name => "test8_1"}],
425
- [:test, {:name => "test8_2"}]],
426
- [:suite, {:name => _test_case_name("Sub2TestCase9")},
427
- [:test, {:name => "test9"}]]]],
428
- *test_dirs)
429
- end
430
-
431
- private
432
- def assert_collect(expected, *collect_args)
433
- keep_required_files do
434
- Dir.chdir(@test_dir.to_s) do
435
- collector = Test::Unit::Collector::Load.new
436
- yield(collector) if block_given?
437
- actual = inspect_test_object(collector.send(:collect, *collect_args))
438
- assert_equal(expected, actual)
439
- end
440
- end
441
- end
442
-
443
- def ensure_clean_directory(directory)
444
- directory.rmtree if directory.exist?
445
- directory.mkpath
446
- end
447
-
448
- def keep_required_files
449
- required_files = $".dup
450
- yield
451
- ensure
452
- $".replace(required_files)
453
- end
454
-
455
- def _test_case_name(test_case_class_name)
456
- "#{@temporary_test_cases_module_name}::#{test_case_class_name}"
457
- end
458
-
459
- def inspect_test_object(test_object)
460
- return nil if test_object.nil?
461
- case test_object
462
- when Test::Unit::TestSuite
463
- sub_tests = test_object.tests.collect do |test|
464
- inspect_test_object(test)
465
- end.sort_by do |type, attributes, *children|
466
- attributes[:name]
467
- end
468
- [:suite, {:name => test_object.name}, *sub_tests]
469
- when Test::Unit::TestCase
470
- [:test, {:name => test_object.method_name}]
471
- else
472
- raise "unexpected test object: #{test_object.inspect}"
473
- end
474
- end
475
- end