test-unit 3.4.1 → 3.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -77,7 +77,7 @@ module Test
77
77
  @tests -= tests
78
78
  end
79
79
 
80
- # Retuns the rolled up number of tests in this suite;
80
+ # Returns the rolled up number of tests in this suite;
81
81
  # i.e. if the suite contains other suites, it counts the
82
82
  # tests within those suites, not the suites themselves.
83
83
  def size
@@ -660,6 +660,7 @@ module Test
660
660
 
661
661
  def diff_line(from_line, to_line)
662
662
  to_operations = []
663
+ mark_operations = []
663
664
  from_line, to_line, _operations = line_operations(from_line, to_line)
664
665
 
665
666
  no_replace = true
@@ -689,11 +690,22 @@ module Test
689
690
  output_single(" " * (from_width - to_width))
690
691
  end
691
692
  end
693
+ mark_operations << Proc.new do
694
+ output_single("?" * from_width,
695
+ color("diff-difference-tag"))
696
+ if (to_width < from_width)
697
+ output_single(" " * (from_width - to_width))
698
+ end
699
+ end
692
700
  when :delete
693
701
  output_single(from_line[from_start...from_end],
694
702
  color("diff-deleted"))
695
703
  unless no_replace
696
704
  to_operations << Proc.new {output_single(" " * from_width)}
705
+ mark_operations << Proc.new do
706
+ output_single("-" * from_width,
707
+ color("diff-deleted"))
708
+ end
697
709
  end
698
710
  when :insert
699
711
  if no_replace
@@ -705,11 +717,16 @@ module Test
705
717
  output_single(to_line[to_start...to_end],
706
718
  color("diff-inserted"))
707
719
  end
720
+ mark_operations << Proc.new do
721
+ output_single("+" * to_width,
722
+ color("diff-inserted"))
723
+ end
708
724
  end
709
725
  when :equal
710
726
  output_single(from_line[from_start...from_end])
711
727
  unless no_replace
712
728
  to_operations << Proc.new {output_single(" " * to_width)}
729
+ mark_operations << Proc.new {output_single(" " * to_width)}
713
730
  end
714
731
  else
715
732
  raise "unknown tag: #{tag}"
@@ -725,6 +742,15 @@ module Test
725
742
  end
726
743
  output("")
727
744
  end
745
+
746
+ unless mark_operations.empty?
747
+ output_single("?", color("diff-difference-tag"))
748
+ output_single(" ")
749
+ mark_operations.each do |operation|
750
+ operation.call
751
+ end
752
+ output("")
753
+ end
728
754
  end
729
755
  end
730
756
  end
@@ -0,0 +1,47 @@
1
+ module Test
2
+ module Unit
3
+ module Util
4
+ class MemoryUsage
5
+ attr_reader :virtual
6
+ attr_reader :physical
7
+ def initialize
8
+ @virtual = nil
9
+ @physical = nil
10
+ collect_data
11
+ end
12
+
13
+ def collected?
14
+ return false if @virtual.nil?
15
+ return false if @physical.nil?
16
+ true
17
+ end
18
+
19
+ private
20
+ def collect_data
21
+ collect_data_proc
22
+ end
23
+
24
+ def collect_data_proc
25
+ status_file = "/proc/self/status"
26
+ return false unless File.exist?(status_file)
27
+
28
+ data = File.binread(status_file)
29
+ data.each_line do |line|
30
+ case line
31
+ when /\AVm(Size|RSS):\s*(\d+)\s*kB/
32
+ name = $1
33
+ value = Integer($2, 10) * 1024
34
+ case name
35
+ when "Size"
36
+ @virtual = value
37
+ when "RSS"
38
+ @physical = value
39
+ end
40
+ end
41
+ end
42
+ collected?
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,5 +1,5 @@
1
1
  module Test
2
2
  module Unit
3
- VERSION = "3.4.1"
3
+ VERSION = "3.4.5"
4
4
  end
5
5
  end
data/lib/test/unit.rb CHANGED
@@ -324,14 +324,14 @@ module Test # :nodoc:
324
324
  # Set true when Test::Unit has run. If set to true Test::Unit
325
325
  # will not automatically run at exit.
326
326
  #
327
- # @deprecated Use Test::Unit::AutoRunner.need_auto_run= instead.
327
+ # @deprecated Use {Test::Unit::AutoRunner.need_auto_run=} instead.
328
328
  def run=(have_run)
329
329
  AutoRunner.need_auto_run = (not have_run)
330
330
  end
331
331
 
332
332
  # Already tests have run?
333
333
  #
334
- # @deprecated Use Test::Unit::AutoRunner.need_auto_run? instead.
334
+ # @deprecated Use {Test::Unit::AutoRunner.need_auto_run?} instead.
335
335
  def run?
336
336
  not AutoRunner.need_auto_run?
337
337
  end
@@ -339,7 +339,7 @@ module Test # :nodoc:
339
339
  # @api private
340
340
  @@at_start_hooks = []
341
341
 
342
- # Regsiter a hook that is run before running tests.
342
+ # Register a hook that is run before running tests.
343
343
  # To register multiple hooks, call this method multiple times.
344
344
  #
345
345
  # Here is an example test case:
@@ -425,7 +425,7 @@ module Test # :nodoc:
425
425
  # @api private
426
426
  @@at_exit_hooks = []
427
427
 
428
- # Regsiter a hook that is run after running tests.
428
+ # Register a hook that is run after running tests.
429
429
  # To register multiple hooks, call this method multiple times.
430
430
  #
431
431
  # Here is an example test case:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-unit
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.1
4
+ version: 3.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-04-19 00:00:00.000000000 Z
12
+ date: 2021-09-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: power_assert
@@ -159,6 +159,7 @@ files:
159
159
  - lib/test/unit/ui/testrunnerutilities.rb
160
160
  - lib/test/unit/ui/xml/testrunner.rb
161
161
  - lib/test/unit/util/backtracefilter.rb
162
+ - lib/test/unit/util/memory-usage.rb
162
163
  - lib/test/unit/util/method-owner-finder.rb
163
164
  - lib/test/unit/util/observable.rb
164
165
  - lib/test/unit/util/output.rb
@@ -170,46 +171,6 @@ files:
170
171
  - sample/test_adder.rb
171
172
  - sample/test_subtracter.rb
172
173
  - sample/test_user.rb
173
- - test/collector/test-descendant.rb
174
- - test/collector/test-load.rb
175
- - test/collector/test_dir.rb
176
- - test/collector/test_objectspace.rb
177
- - test/fixtures/header-label.csv
178
- - test/fixtures/header-label.tsv
179
- - test/fixtures/header.csv
180
- - test/fixtures/header.tsv
181
- - test/fixtures/no-header.csv
182
- - test/fixtures/no-header.tsv
183
- - test/fixtures/plus.csv
184
- - test/run-test.rb
185
- - test/test-assertions.rb
186
- - test/test-attribute-matcher.rb
187
- - test/test-attribute.rb
188
- - test/test-code-snippet.rb
189
- - test/test-color-scheme.rb
190
- - test/test-color.rb
191
- - test/test-data.rb
192
- - test/test-diff.rb
193
- - test/test-emacs-runner.rb
194
- - test/test-error.rb
195
- - test/test-failure.rb
196
- - test/test-fault-location-detector.rb
197
- - test/test-fixture.rb
198
- - test/test-notification.rb
199
- - test/test-omission.rb
200
- - test/test-pending.rb
201
- - test/test-priority.rb
202
- - test/test-test-case.rb
203
- - test/test-test-result.rb
204
- - test/test-test-suite-creator.rb
205
- - test/test-test-suite.rb
206
- - test/testunit-test-util.rb
207
- - test/ui/test_testrunmediator.rb
208
- - test/util/test-method-owner-finder.rb
209
- - test/util/test-output.rb
210
- - test/util/test_backtracefilter.rb
211
- - test/util/test_observable.rb
212
- - test/util/test_procwrapper.rb
213
174
  homepage: http://test-unit.github.io/
214
175
  licenses:
215
176
  - Ruby
@@ -217,6 +178,8 @@ licenses:
217
178
  - PSFL
218
179
  metadata:
219
180
  source_code_uri: https://github.com/test-unit/test-unit
181
+ documentation_uri: https://test-unit.github.io/test-unit/en/
182
+ bug_tracker_uri: https://github.com/test-unit/test-unit/issues
220
183
  post_install_message:
221
184
  rdoc_options: []
222
185
  require_paths:
@@ -236,44 +199,4 @@ rubygems_version: 3.3.0.dev
236
199
  signing_key:
237
200
  specification_version: 4
238
201
  summary: An xUnit family unit testing framework for Ruby.
239
- test_files:
240
- - test/collector/test-descendant.rb
241
- - test/collector/test-load.rb
242
- - test/collector/test_dir.rb
243
- - test/collector/test_objectspace.rb
244
- - test/fixtures/header-label.csv
245
- - test/fixtures/header-label.tsv
246
- - test/fixtures/header.csv
247
- - test/fixtures/header.tsv
248
- - test/fixtures/no-header.csv
249
- - test/fixtures/no-header.tsv
250
- - test/fixtures/plus.csv
251
- - test/run-test.rb
252
- - test/test-assertions.rb
253
- - test/test-attribute-matcher.rb
254
- - test/test-attribute.rb
255
- - test/test-code-snippet.rb
256
- - test/test-color-scheme.rb
257
- - test/test-color.rb
258
- - test/test-data.rb
259
- - test/test-diff.rb
260
- - test/test-emacs-runner.rb
261
- - test/test-error.rb
262
- - test/test-failure.rb
263
- - test/test-fault-location-detector.rb
264
- - test/test-fixture.rb
265
- - test/test-notification.rb
266
- - test/test-omission.rb
267
- - test/test-pending.rb
268
- - test/test-priority.rb
269
- - test/test-test-case.rb
270
- - test/test-test-result.rb
271
- - test/test-test-suite-creator.rb
272
- - test/test-test-suite.rb
273
- - test/testunit-test-util.rb
274
- - test/ui/test_testrunmediator.rb
275
- - test/util/test-method-owner-finder.rb
276
- - test/util/test-output.rb
277
- - test/util/test_backtracefilter.rb
278
- - test/util/test_observable.rb
279
- - test/util/test_procwrapper.rb
202
+ test_files: []
@@ -1,182 +0,0 @@
1
- require 'test/unit'
2
- require 'test/unit/collector/descendant'
3
-
4
- class TestUnitCollectorDescendant < Test::Unit::TestCase
5
- def setup
6
- @previous_descendants = Test::Unit::TestCase::DESCENDANTS.dup
7
- Test::Unit::TestCase::DESCENDANTS.clear
8
- end
9
-
10
- def teardown
11
- Test::Unit::TestCase::DESCENDANTS.replace(@previous_descendants)
12
- end
13
-
14
- private
15
- def assert_collect(expected, *collect_args)
16
- collector = Test::Unit::Collector::Descendant.new
17
- yield(collector) if block_given?
18
- assert_equal(expected, collector.send(:collect, *collect_args))
19
- end
20
-
21
- def default_name
22
- Test::Unit::Collector::Descendant::NAME
23
- end
24
-
25
- def empty_suite(name=nil)
26
- Test::Unit::TestSuite.new(name || default_name)
27
- end
28
-
29
- class TestCollect < self
30
- def setup
31
- super
32
-
33
- @test_case1 = Class.new(Test::Unit::TestCase) do
34
- self.test_order = :alphabetic
35
-
36
- def self.name
37
- "test-case1"
38
- end
39
-
40
- def test_1
41
- end
42
-
43
- def test_2
44
- end
45
- end
46
-
47
- @test_case2 = Class.new(Test::Unit::TestCase) do
48
- self.test_order = :alphabetic
49
-
50
- def self.name
51
- "test-case2"
52
- end
53
-
54
- def test_0
55
- end
56
- end
57
-
58
- @no_test_case = Class.new do
59
- def self.name
60
- "no-test-case"
61
- end
62
-
63
- def test_4
64
- end
65
- end
66
- end
67
-
68
- def test_basic
69
- assert_collect(full_suite("name"), "name")
70
-
71
- assert_collect(full_suite("name"), "name") do |collector|
72
- collector.filter = []
73
- end
74
- end
75
-
76
- def test_filtered
77
- assert_collect(empty_suite) do |collector|
78
- collector.filter = Proc.new {false}
79
- end
80
-
81
- assert_collect(full_suite) do |collector|
82
- collector.filter = Proc.new {true}
83
- end
84
-
85
- assert_collect(full_suite) do |collector|
86
- collector.filter = Proc.new {nil}
87
- end
88
-
89
- assert_collect(empty_suite) do |collector|
90
- collector.filter = [Proc.new {false}, Proc.new {true}]
91
- end
92
-
93
- assert_collect(empty_suite) do |collector|
94
- collector.filter = [Proc.new {true}, Proc.new {false}]
95
- end
96
-
97
- assert_collect(empty_suite) do |collector|
98
- collector.filter = [Proc.new {nil}, Proc.new {false}]
99
- end
100
-
101
- assert_collect(full_suite) do |collector|
102
- collector.filter = [Proc.new {nil}, Proc.new {true}]
103
- end
104
-
105
- expected = empty_suite
106
- suite1 = Test::Unit::TestSuite.new(@test_case1.name)
107
- suite1 << @test_case1.new("test_1")
108
- suite2 = Test::Unit::TestSuite.new(@test_case2.name)
109
- suite2 << @test_case2.new("test_0")
110
- expected << suite1 << suite2
111
- assert_collect(expected) do |collector|
112
- collector.filter = Proc.new do |test|
113
- ['test_1', 'test_0'].include?(test.method_name)
114
- end
115
- end
116
-
117
- suite1 = Test::Unit::TestSuite.new(@test_case1.name)
118
- suite1 << @test_case1.new("test_1")
119
- suite2 = Test::Unit::TestSuite.new(@test_case2.name)
120
- suite2 << @test_case2.new("test_0")
121
- assert_collect(empty_suite) do |collector|
122
- filters = [Proc.new {|test| test.method_name == 'test_1' ? true : nil},
123
- Proc.new {|test| test.method_name == 'test_0' ? true : nil},
124
- Proc.new {false}]
125
- collector.filter = filters
126
- end
127
- end
128
-
129
- private
130
- def full_suite(name=nil)
131
- sub_suite1 = Test::Unit::TestSuite.new(@test_case1.name)
132
- sub_suite1 << @test_case1.new('test_1')
133
- sub_suite1 << @test_case1.new('test_2')
134
-
135
- sub_suite2 = Test::Unit::TestSuite.new(@test_case2.name)
136
- sub_suite2 << @test_case2.new('test_0')
137
-
138
- suite = empty_suite(name)
139
- suite << sub_suite1
140
- suite << sub_suite2
141
- suite
142
- end
143
- end
144
-
145
- class TestModule < self
146
- def test_included_in_child
147
- tests = Module.new do
148
- def test_in_module
149
- end
150
- end
151
-
152
- parent_test_case = Class.new(Test::Unit::TestCase) do
153
- class << self
154
- def name
155
- "Parent"
156
- end
157
- end
158
- end
159
-
160
- child_test_case = Class.new(parent_test_case) do
161
- include tests
162
-
163
- class << self
164
- def name
165
- "Child"
166
- end
167
- end
168
- end
169
-
170
- child_suite = Test::Unit::TestSuite.new(child_test_case.name)
171
- child_suite << child_test_case.new("test_in_module")
172
-
173
- parent_suite = Test::Unit::TestSuite.new(parent_test_case.name)
174
- parent_suite << child_suite
175
-
176
- suite = empty_suite("all")
177
- suite << parent_suite
178
-
179
- assert_collect(suite, "all")
180
- end
181
- end
182
- end