Add some tests for parsing out of order tests, mostly passing.
[tapir.git] / t / 03-parse_tapstream_error.t
blobd5973ffe47742a61223d4d99ffd2eec4a17d3edc
1 #!/usr/bin/env parrot
4 .sub main :main
5     .include 'test_more.pir'
6     .local pmc tapir, klass
7     load_bytecode 'lib/Tapir/Stream.pbc'
8     load_bytecode 'lib/Tapir/Parser.pbc'
10     plan(35)
12     # setup test data
13     klass = newclass [ 'Tapir'; 'Parser' ]
14     tapir = klass.'new'()
16     test_parse_death(tapir)
17     test_parse_death_with_passing_tests(tapir)
18     test_plumage_sanity(tapir)
19     test_exit_code(tapir)
20     test_exit_code_pass(tapir)
21     test_parse_tapstream_out_of_order(tapir)
22 .end
24 .sub test_parse_tapstream_out_of_order
25     .param pmc tapir
26     .local string tap_error
27     .local pmc stream
28     tap_error = <<"TAP"
29 1..4
30 ok 1 - foo
31 ok 3 - bar
32 ok 2 - baz
33 ok 4 - fuzzlebub
34 TAP
35     stream = tapir.'parse_tapstream'(tap_error)
37     $I0 = stream.'get_plan'()
38     is($I0,4,"plan is correct")
40     $I0 = stream.'is_pass'()
41     is($I0,0,"parse_tapstream does not pass something with out of order tests")
43     $I0 = stream.'get_pass'()
44     is($I0,4,"parse_tapstream gets 4 passed tests")
46     $I0 = stream.'get_todo'()
47     is($I0,0,"parse_tapstream gets no todo tests")
49     $I0 = stream.'get_skip'()
50     is($I0,0,"parse_tapstream gets no skip tests")
52     $I0 = stream.'get_fail'()
53     is($I0,0,"parse_tapstream gets no fails")
55     $I0 = stream.'total'()
56     is($I0,4,"parse_tapstream gets correct # of tests in total")
58     $I0 = stream.'get_exit_code'()
59     is($I0,0,"parse_tapstream gets correct exit code")
61 .end
63 .sub test_exit_code_pass
64     .param pmc tapir
65     .local string tap
66     .local pmc stream
67     tap = <<"TAP"
68 1..2
69 ok 1 - Class of Tapir::Parser is of the correct type
70 ok 2 - new returns a Tapir::Parser object isa Tapir;Parser
71 TAP
72     stream = tapir.'parse_tapstream'(tap,0)
73     $I0 = stream.'get_exit_code'()
74     is($I0,0,"parse_tapstream gets passing exit code")
75 .end
78 .sub test_exit_code
79     .param pmc tapir
80     .local string tap_error
81     .local pmc stream
82     tap_error = <<"TAP"
83 1..2
84 ok 1 - Class of Tapir::Parser is of the correct type
85 ok 2 - new returns a Tapir::Parser object isa Tapir;Parser
86 eat it!
87 current instr.: 'parrot;Tapir;Stream;main' pc 554 (t/00-sanity.t:20)
88 TAP
89     stream = tapir.'parse_tapstream'(tap_error,42)
91     $I0 = stream.'get_plan'()
92     is($I0,2,"plan is correct")
94     $I0 = stream.'is_pass'()
95     is($I0,0,"parse_tapstream does not pass something with a non-successful exit code")
97     $I0 = stream.'get_pass'()
98     is($I0,2,"parse_tapstream gets 2 passed tests")
100     $I0 = stream.'get_todo'()
101     is($I0,0,"parse_tapstream gets no todo tests")
103     $I0 = stream.'get_skip'()
104     is($I0,0,"parse_tapstream gets no skip tests")
106     $I0 = stream.'get_fail'()
107     is($I0,0,"parse_tapstream gets no fails")
109     $I0 = stream.'total'()
110     is($I0,2,"parse_tapstream gets correct # of tests in total")
112     $I0 = stream.'get_exit_code'()
113     is($I0,42,"parse_tapstream gets correct exit code")
115 .end
117 .sub test_plumage_sanity
118     .param pmc tapir
119     .local string tap_error
120     .local pmc stream
121     tap_error = <<"TAP"
122 1..18
123 invalidjunkdoesnotexist
124 ok 1 - do_run()ing invalidjunk returns false
125 ./plumage asdfversion
126 I don't know how to 'asdfversion'!
127 ok 2 - plumage returns failure for invalid commands
128 ok 3
129 ok 4
130 ok 5
131 ok 6
132 ok 7
133 ok 8 - no args give usage
134 ok 9 - no args give usage
135 ok 10 - plumage fetch no args
136 ok 11
137 ok 12
138 ./plumage version
139 This is Parrot Plumage, version 0.
141 Copyright (C) 2009, Parrot Foundation.
143 This code is distributed under the terms of the Artistic License 2.0.
144 For more details, see the full text of the license in the LICENSE file
145 included in the Parrot Plumage source tree.
146 ok 13 - plumage version returns success
147 ok 14 - plumage version knows its name
148 ok 15 - version mentions Parrot Foundation
149 ok 16 - version mentions Artistic License
150 ok 17 - info rakudo
151 ok 18 - info rakudo
152 .end
154     stream = tapir.'parse_tapstream'(tap_error)
156     $I0 = stream.'get_plan'()
157     is($I0,18,"plan is correct")
159     $I0 = stream.'is_pass'()
160     is($I0,1,"parse_tapstream passes Plumage's sanity test")
162     $I0 = stream.'get_pass'()
163     is($I0,18,"parse_tapstream gets 18 tests")
165     $I0 = stream.'get_todo'()
166     is($I0,0,"parse_tapstream gets no todo tests")
168     $I0 = stream.'get_skip'()
169     is($I0,0,"parse_tapstream gets no skip tests")
171     $I0 = stream.'get_fail'()
172     is($I0,0,"parse_tapstream gets no fails")
174     $I0 = stream.'total'()
175     is($I0,18,"parse_tapstream gets 18 tests in total")
176 .end
178 .sub test_parse_death
179     .param pmc tapir
180     .local string tap_error
181     .local pmc stream
182     tap_error = <<"TAP"
183 1..2
184 not ok 1 - newclass Tapir::Parser is of the correct type
185 # Have: Class
186 # Want: Tapir;Parser
187 get_bool() not implemented in class 'Tapir;Parser'
188 current instr.: 'parrot;Test;More;ok' pc 39 (runtime/parrot/library/Test/More.pir:108)
189 called from Sub 'parrot;Tapir;Stream;main' pc 505 (t/00-sanity.t:18)
191     stream = tapir.'parse_tapstream'(tap_error)
193     $I0 = stream.'is_pass'()
194     is($I0,0,"parse_tapstream does not pass a TAP stream with a death message")
196     $I0 = stream.'get_pass'()
197     is($I0,0,"parse_tapstream gets no passed tests")
199     $I0 = stream.'get_todo'()
200     is($I0,0,"parse_tapstream gets 0 todo tests")
202     $I0 = stream.'get_skip'()
203     is($I0,0,"parse_tapstream gets 0 skip tests")
205     $I0 = stream.'get_fail'()
206     is($I0,1,"parse_tapstream gets one failed test")
208     $I0 = stream.'total'()
209     is($I0,1,"parse_tapstream gets one test in total")
211 .end
213 .sub test_parse_death_with_passing_tests
214     .param pmc tapir
215     .local string tap_error
216     .local pmc stream
217     tap_error = <<"TAP"
218 1..2
219 ok 1 - new returns a Tapir::Parser object isa Tapir;Parser
220 Class Stream already registered!
222 current instr.: 'parrot;Tapir;Stream;main' pc 495 (t/00-sanity.t:18)
224     stream = tapir.'parse_tapstream'(tap_error)
226     $I0 = stream.'is_pass'()
227     is($I0,0,"parse_tapstream does not pass a TAP stream with a death message")
229     $I0 = stream.'get_pass'()
230     is($I0,1,"parse_tapstream gets 1 passing test")
232     $I0 = stream.'get_todo'()
233     is($I0,0,"parse_tapstream gets 0 todo tests")
235     $I0 = stream.'get_skip'()
236     is($I0,0,"parse_tapstream gets 0 skip tests")
238     $I0 = stream.'get_fail'()
239     is($I0,0,"parse_tapstream gets no failing tests")
241     $I0 = stream.'total'()
242     is($I0,1,"parse_tapstream gets one test in total")
243 .end
245 # Local Variables:
246 #   mode: pir
247 #   fill-column: 100
248 # End:
249 # vim: expandtab shiftwidth=4 ft=pir: