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