grosser-autotest 4.0.3

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.
@@ -0,0 +1,313 @@
1
+ require 'test/helper'
2
+ require 'unit_diff'
3
+
4
+ class TestUnitDiff < Test::Unit::TestCase
5
+
6
+ def setup
7
+ @diff = UnitDiff.new
8
+ end
9
+
10
+ def test_input
11
+ header = "Loaded suite ./blah\nStarted\nFF\nFinished in 0.035332 seconds.\n\n"
12
+ input = "#{header} 1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n<\"line1\\nline2\\nline3\\n\"> expected but was\n<\"line4\\nline5\\nline6\\n\">.\n\n 2) Failure:\ntest_test2(TestBlah) [./blah.rb:29]:\n<\"line1\"> expected but was\n<\"line2\\nline3\\n\\n\">.\n\n2 tests, 2 assertions, 2 failures, 0 errors\n"
13
+
14
+ # TODO: I think I'd like a separate footer array as well
15
+ expected = [[[" 1) Failure:\n", "test_test1(TestBlah) [./blah.rb:25]:\n", "<\"line1\\nline2\\nline3\\n\"> expected but was\n", "<\"line4\\nline5\\nline6\\n\">.\n"],
16
+ [" 2) Failure:\n", "test_test2(TestBlah) [./blah.rb:29]:\n", "<\"line1\"> expected but was\n", "<\"line2\\nline3\\n\\n\">.\n"]],
17
+ ["\n", "2 tests, 2 assertions, 2 failures, 0 errors\n"]]
18
+
19
+ util_unit_diff(header, input, expected, :parse_input)
20
+ end
21
+
22
+ def test_input_miniunit
23
+ header = "Loaded suite -e\nStarted\nF\nFinished in 0.035332 seconds.\n\n"
24
+ input = "#{header} 1) Failure:
25
+ test_blah(TestBlah) [./blah.rb:25]:
26
+ Expected ['a', 'b', 'c'], not ['a', 'c', 'b'].
27
+
28
+ 1 tests, 1 assertions, 1 failures, 0 errors
29
+ "
30
+
31
+ expected = [[[" 1) Failure:\n",
32
+ "test_blah(TestBlah) [./blah.rb:25]:\n",
33
+ "Expected ['a', 'b', 'c'], not ['a', 'c', 'b'].\n"]],
34
+ ["\n", "1 tests, 1 assertions, 1 failures, 0 errors\n"]]
35
+
36
+ util_unit_diff(header, input, expected, :parse_input)
37
+ end
38
+
39
+ def test_input_mspec
40
+ header = <<-HEADER
41
+ Started
42
+ .......F
43
+ Finished in 0.1 seconds
44
+
45
+ HEADER
46
+
47
+ failure = <<-FAILURE
48
+ 1)
49
+ The unless expression should fail FAILED
50
+ Expected nil to equal "baz":
51
+ FAILURE
52
+
53
+ backtrace = <<-BACKTRACE
54
+ PositiveExpectation#== at spec/mspec.rb:217
55
+ main.__script__ {} at spec/language/unless_spec.rb:49
56
+ Proc#call at kernel/core/proc.rb:127
57
+ SpecRunner#it at spec/mspec.rb:368
58
+ main.it at spec/mspec.rb:412
59
+ main.__script__ {} at spec/language/unless_spec.rb:48
60
+ Proc#call at kernel/core/proc.rb:127
61
+ SpecRunner#describe at spec/mspec.rb:378
62
+ main.describe at spec/mspec.rb:408
63
+ main.__script__ at spec/language/unless_spec.rb:3
64
+ CompiledMethod#as_script at kernel/bootstrap/primitives.rb:41
65
+ main.load at kernel/core/compile.rb:150
66
+ main.__script__ {} at last_mspec.rb:11
67
+ Array#each {} at kernel/core/array.rb:545
68
+ Integer(Fixnum)#times at kernel/core/integer.rb:15
69
+ Array#each at kernel/core/array.rb:545
70
+ main.__script__ at last_mspec.rb:16
71
+ CompiledMethod#as_script at kernel/bootstrap/primitives.rb:41
72
+ main.load at kernel/core/compile.rb:150
73
+ main.__script__ at kernel/loader.rb:145
74
+ BACKTRACE
75
+
76
+ footer = "\n8 examples, 1 failures\n"
77
+ input = header + failure + backtrace + footer
78
+
79
+ expected_backtrace = backtrace.split("\n").map {|l| "#{l}\n"}
80
+ expected = [[["1)\n", "The unless expression should fail FAILED\n",
81
+ "Expected nil to equal \"baz\":\n",
82
+ *expected_backtrace]],
83
+ ["\n", "8 examples, 1 failures\n"]]
84
+ util_unit_diff(header, input, expected, :parse_input)
85
+ end
86
+
87
+ def test_input_mspec_multiline
88
+ header = <<-HEADER
89
+ Started
90
+ .......F
91
+ Finished in 0.1 seconds
92
+
93
+ HEADER
94
+
95
+ failure = <<-FAILURE
96
+ 1)
97
+ Compiler compiles a case without an argument FAILED
98
+ Expected #<TestGenerator [[:push, :false], [:gif, #<Label 5>], [:push_literal, "foo"], [:string_dup], [:goto, #<Label 19>], [:set_label, #<Label 5>], [:push, :nil], [:gif, #<Label 10>], [:push_literal, "foo"], [:string_dup], [:goto, #<Label 19>], [:set_label, #<Label 10>], [:push, 2], [:push, 1], [:send, :==, 1, false], [:gif, #<Label 17>], [:push_literal, "bar"], [:string_dup], [:goto, #<Label 19>], [:set_label, #<Label 17>], [:push_literal, "baz"], [:string_dup], [:set_label, #<Label 19>]]
99
+ to equal #<TestGenerator [[:push, false], [:gif, #<Label 5>], [:push, "foo"], [:string_dup], [:goto, #<Label 6>], [:set_label, #<Label 5>], [:push, nil], [:set_label, #<Label 6>], [:pop], [:push, nil], [:gif, #<Label 12>], [:push, "foo"], [:string_dup], [:goto, #<Label 13>], [:set_label, #<Label 12>], [:push, nil], [:set_label, #<Label 13>], [:pop], [:push, 2], [:push, 1], [:send, :==, 1], [:gif, #<Label 21>], [:push, "bar"], [:string_dup], [:goto, #<Label 23>], [:set_label, #<Label 21>], [:push_literal, "baz"], [:string_dup], [:set_label, #<Label 23>], [:sret]]:
100
+ FAILURE
101
+
102
+ backtrace = <<-BACKTRACE
103
+ PositiveExpectation#== at spec/mspec.rb:216
104
+ main.gen at ./compiler2/spec/helper.rb:125
105
+ main.__script__ {} at compiler2/spec/control_spec.rb:448
106
+ BACKTRACE
107
+
108
+ footer = "\n8 examples, 1 failures\n"
109
+ input = header + failure + backtrace + footer
110
+
111
+ expected_backtrace = backtrace.split("\n").map {|l| "#{l}\n"}
112
+ expected_failure = failure.split("\n").map {|l| "#{l}\n"}
113
+ expected = [[[*(expected_failure + expected_backtrace)]],
114
+ ["\n", "8 examples, 1 failures\n"]]
115
+ util_unit_diff(header, input, expected, :parse_input)
116
+ end
117
+
118
+ def test_unit_diff_empty # simulates broken pipe at the least
119
+ input = ""
120
+ expected = ""
121
+ util_unit_diff("", "", "")
122
+ end
123
+
124
+ def test_parse_diff_angles
125
+ input = [" 1) Failure:\n",
126
+ "test_test1(TestBlah) [./blah.rb:25]:\n",
127
+ "<\"<html>\"> expected but was\n",
128
+ "<\"<body>\">.\n"
129
+ ]
130
+
131
+ expected = [[" 1) Failure:\n", "test_test1(TestBlah) [./blah.rb:25]:\n"],
132
+ ["<html>"],
133
+ ["<body>"],
134
+ []]
135
+
136
+ assert_equal expected, @diff.parse_diff(input)
137
+ end
138
+
139
+ def test_parse_diff_miniunit
140
+ input = [" 1) Failure:\n",
141
+ "test_blah(TestBlah) [./blah.rb:25]:\n",
142
+ "Expected ['a', 'b', 'c'], not ['a', 'c', 'b'].\n"]
143
+
144
+ expected = [[" 1) Failure:\n", "test_blah(TestBlah) [./blah.rb:25]:\n"],
145
+ ["['a', 'b', 'c']"],
146
+ ["['a', 'c', 'b']"],
147
+ []]
148
+
149
+ assert_equal expected, @diff.parse_diff(input)
150
+ end
151
+
152
+ def test_parse_diff_miniunit_multiline
153
+ input = [" 1) Failure:\n",
154
+ "test_blah(TestBlah) [./blah.rb:25]:\n",
155
+ "Expected ['a',\n'b',\n'c'], not ['a',\n'c',\n'b'].\n"]
156
+
157
+ expected = [[" 1) Failure:\n", "test_blah(TestBlah) [./blah.rb:25]:\n"],
158
+ ["['a',\n'b',\n'c']"],
159
+ ["['a',\n'c',\n'b']"],
160
+ []]
161
+
162
+ assert_equal expected, @diff.parse_diff(input)
163
+ end
164
+ def test_parse_diff1
165
+ input = [" 1) Failure:\n",
166
+ "test_test1(TestBlah) [./blah.rb:25]:\n",
167
+ "<\"line1\\nline2\\nline3\\n\"> expected but was\n",
168
+ "<\"line4\\nline5\\nline6\\n\">.\n"
169
+ ]
170
+
171
+ expected = [[" 1) Failure:\n", "test_test1(TestBlah) [./blah.rb:25]:\n"], ["line1\\nline2\\nline3\\n"], ["line4\\nline5\\nline6\\n"], []]
172
+
173
+ assert_equal expected, @diff.parse_diff(input)
174
+ end
175
+
176
+ def test_parse_diff2
177
+ input = [" 2) Failure:\n",
178
+ "test_test2(TestBlah) [./blah.rb:29]:\n",
179
+ "<\"line1\"> expected but was\n",
180
+ "<\"line2\\nline3\\n\\n\">.\n"
181
+ ]
182
+
183
+ expected = [[" 2) Failure:\n",
184
+ "test_test2(TestBlah) [./blah.rb:29]:\n"],
185
+ ["line1"],
186
+ ["line2\\nline3\\n\\n"],
187
+ []
188
+ ]
189
+
190
+ assert_equal expected, @diff.parse_diff(input)
191
+ end
192
+
193
+ def test_parse_diff3
194
+ input = [" 13) Failure:\n",
195
+ "test_case_stmt(TestRubyToRubyC) [./r2ctestcase.rb:1198]:\n",
196
+ "Unknown expected data.\n",
197
+ "<false> is not true.\n"]
198
+
199
+ expected = [[" 13) Failure:\n", "test_case_stmt(TestRubyToRubyC) [./r2ctestcase.rb:1198]:\n", "Unknown expected data.\n"], ["<false> is not true.\n"], nil, []]
200
+
201
+ assert_equal expected, @diff.parse_diff(input)
202
+ end
203
+
204
+ def test_parse_diff_suspect_equals
205
+ input = ["1) Failure:\n",
206
+ "test_util_capture(AssertionsTest) [test/test_zentest_assertions.rb:53]:\n",
207
+ "<\"out\"> expected but was\n",
208
+ "<\"out\">.\n"]
209
+ expected = [["1) Failure:\n",
210
+ "test_util_capture(AssertionsTest) [test/test_zentest_assertions.rb:53]:\n"],
211
+ ["out"],
212
+ ["out"], []]
213
+
214
+ assert_equal expected, @diff.parse_diff(input)
215
+ end
216
+
217
+ def test_parse_diff_NOT_suspect_equals
218
+ input = ["1) Failure:\n",
219
+ "test_util_capture(AssertionsTest) [test/test_zentest_assertions.rb:53]:\n",
220
+ "<\"out\"> expected but was\n",
221
+ "<\"out\\n\">.\n"]
222
+ expected = [["1) Failure:\n",
223
+ "test_util_capture(AssertionsTest) [test/test_zentest_assertions.rb:53]:\n"],
224
+ ["out"],
225
+ ["out\\n"], []]
226
+
227
+ assert_equal expected, @diff.parse_diff(input)
228
+ end
229
+
230
+ def test_parse_diff_mspec
231
+ input = ["1)\n", "The unless expression should fail FAILED\n",
232
+ "Expected nil to equal \"baz\":\n",
233
+ " PositiveExpectation#== at spec/mspec.rb:217\n"]
234
+
235
+ expected = [["1)\n", "The unless expression should fail FAILED\n"],
236
+ ["nil"],
237
+ ["\"baz\""],
238
+ [" PositiveExpectation#== at spec/mspec.rb:217"]]
239
+
240
+ assert_equal expected, @diff.parse_diff(input)
241
+ end
242
+
243
+ def test_parse_diff_mspec_multiline
244
+ input = ["1)\n", "The unless expression should fail FAILED\n",
245
+ "Expected #<TestGenerator [[:push, :true],\n", " [:dup]\n", "]\n",
246
+ "to equal #<TestGenerator [[:pop],\n", " [:dup]\n", "]:\n",
247
+ " PositiveExpectation#== at spec/mspec.rb:217\n"]
248
+
249
+ expected = [["1)\n", "The unless expression should fail FAILED\n"],
250
+ ["#<TestGenerator [[:push, :true],\n", " [:dup]\n", "]"],
251
+ ["#<TestGenerator [[:pop],\n", " [:dup]\n", "]"],
252
+ [" PositiveExpectation#== at spec/mspec.rb:217"]]
253
+
254
+ assert_equal expected, @diff.parse_diff(input)
255
+ end
256
+
257
+ def test_unit_diff_angles
258
+ header = "Loaded suite ./blah\nStarted\nF\nFinished in 0.035332 seconds.\n\n"
259
+ input = "#{header} 1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n<\"<html>\"> expected but was\n<\"<body>\">.\n\n1 tests, 1 assertions, 1 failures, 0 errors\n"
260
+ expected = "1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n1c1\n< <html>\n---\n> <body>\n\n1 tests, 1 assertions, 1 failures, 0 errors"
261
+
262
+ util_unit_diff(header, input, expected)
263
+ end
264
+
265
+ def test_unit_diff1
266
+ header = "Loaded suite ./blah\nStarted\nF\nFinished in 0.035332 seconds.\n\n"
267
+ input = "#{header} 1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n<\"line1\\nline2\\nline3\\n\"> expected but was\n<\"line4\\nline5\\nline6\\n\">.\n\n1 tests, 1 assertions, 1 failures, 0 errors\n"
268
+ expected = "1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n1,3c1,3\n< line1\n< line2\n< line3\n---\n> line4\n> line5\n> line6\n\n1 tests, 1 assertions, 1 failures, 0 errors"
269
+
270
+ util_unit_diff(header, input, expected)
271
+ end
272
+
273
+ def test_unit_diff2
274
+ header = "Loaded suite ./blah\nStarted\nFF\nFinished in 0.035332 seconds.\n\n"
275
+ input = "#{header} 1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n<\"line1\\nline2\\nline3\\n\"> expected but was\n<\"line4\\nline5\\nline6\\n\">.\n\n 2) Failure:\ntest_test2(TestBlah) [./blah.rb:29]:\n<\"line1\"> expected but was\n<\"line2\\nline3\\n\\n\">.\n\n2 tests, 2 assertions, 2 failures, 0 errors\n"
276
+ expected = "1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n1,3c1,3\n< line1\n< line2\n< line3\n---\n> line4\n> line5\n> line6\n\n2) Failure:\ntest_test2(TestBlah) [./blah.rb:29]:\n1c1,4\n< line1\n---\n> line2\n> line3\n> \n> \n\n2 tests, 2 assertions, 2 failures, 0 errors"
277
+
278
+ util_unit_diff(header, input, expected)
279
+ end
280
+
281
+ def test_unit_diff3
282
+ header = ""
283
+ input = " 13) Failure:\ntest_case_stmt(TestRubyToRubyC) [./r2ctestcase.rb:1198]:\nUnknown expected data.\n<false> is not true.\n"
284
+ expected = "13) Failure:\ntest_case_stmt(TestRubyToRubyC) [./r2ctestcase.rb:1198]:\nUnknown expected data.\n<false> is not true."
285
+
286
+ util_unit_diff(header, input, expected)
287
+ end
288
+
289
+ def test_unit_diff_suspect_equals
290
+ header = "Loaded suite ./blah\nStarted\n.............................................F............................................\nFinished in 0.834671 seconds.\n\n"
291
+ footer = "90 tests, 241 assertions, 1 failures, 0 errors"
292
+ input = "#{header} 1) Failure:\ntest_unit_diff_suspect_equals(TestUnitDiff) [./test/test_unit_diff.rb:122]:\n<\"out\"> expected but was\n<\"out\">.\n\n#{footer}"
293
+ expected = "1) Failure:\ntest_unit_diff_suspect_equals(TestUnitDiff) [./test/test_unit_diff.rb:122]:\n[no difference--suspect ==]\n\n#{footer}"
294
+
295
+ util_unit_diff(header, input, expected)
296
+ end
297
+
298
+ def test_unit_diff_NOT_suspect_equals
299
+ header = "Loaded suite ./blah\nStarted\n.\nFinished in 0.0 seconds.\n\n"
300
+ input = "#{header} 1) Failure:\ntest_blah(TestBlah)\n<\"out\"> expected but was\n<\"out\\n\">.\n\n1 tests, 1 assertions, 1 failures, 0 errors"
301
+ expected = "1) Failure:\ntest_blah(TestBlah)\n1a2\n> \n\n1 tests, 1 assertions, 1 failures, 0 errors"
302
+
303
+ util_unit_diff(header, input, expected)
304
+ end
305
+
306
+ def util_unit_diff(header, input, expected, msg=:unit_diff)
307
+ output = StringIO.new("")
308
+ actual = @diff.send(msg, StringIO.new(input), output)
309
+ assert_equal header, output.string, "header output"
310
+ assert_equal expected, actual
311
+ end
312
+ end
313
+
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: grosser-autotest
3
+ version: !ruby/object:Gem::Version
4
+ version: 4.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Davis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-03-30 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email:
18
+ executables:
19
+ - autotest
20
+ - unit_diff
21
+ extensions: []
22
+
23
+ extra_rdoc_files: []
24
+
25
+ files:
26
+ - VERSION.yml
27
+ - History.txt
28
+ - README.markdown
29
+ - bin/autotest
30
+ - bin/unit_diff
31
+ - lib/autotest.rb
32
+ - lib/autotest
33
+ - lib/autotest/restart.rb
34
+ - lib/autotest/snarl.rb
35
+ - lib/autotest/jabber_notify.rb
36
+ - lib/autotest/fixtures.rb
37
+ - lib/autotest/menu.rb
38
+ - lib/autotest/kdenotify.rb
39
+ - lib/autotest/emacs.rb
40
+ - lib/autotest/camping.rb
41
+ - lib/autotest/pretty.rb
42
+ - lib/autotest/email_notify.rb
43
+ - lib/autotest/heckle.rb
44
+ - lib/autotest/discover.rb
45
+ - lib/autotest/cctray.rb
46
+ - lib/autotest/shame.rb
47
+ - lib/autotest/rcov.rb
48
+ - lib/autotest/once.rb
49
+ - lib/autotest/migrate.rb
50
+ - lib/autotest/autoupdate.rb
51
+ - lib/autotest/rails.rb
52
+ - lib/autotest/timestamp.rb
53
+ - lib/autotest/growl.rb
54
+ - lib/autotest/notify.rb
55
+ - lib/autotest/redgreen.rb
56
+ - lib/autotest/html_report.rb
57
+ - lib/unit_diff.rb
58
+ - test/test_unit_diff.rb
59
+ - test/helper.rb
60
+ - test/test_autotest.rb
61
+ has_rdoc: true
62
+ homepage: http://github.com/grosser/autotest
63
+ post_install_message:
64
+ rdoc_options:
65
+ - --inline-source
66
+ - --charset=UTF-8
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: "0"
74
+ version:
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: "0"
80
+ version:
81
+ requirements: []
82
+
83
+ rubyforge_project:
84
+ rubygems_version: 1.2.0
85
+ signing_key:
86
+ specification_version: 2
87
+ summary: Autotest, without ZenTest
88
+ test_files: []
89
+