Commit cdd56bd9891193c902b9796a84c5db4a7fe03aa9
- Diff rendering mode:
- inline
- side by side
ext/Tapir/Parser.pir
(43 / 5)
|   | |||
| 8 | 8 | ||
| 9 | 9 | .namespace [ 'Tapir'; 'Parser' ] | |
| 10 | 10 | ||
| 11 | .sub bail_if_necessary :method | ||
| 12 | .param string line | ||
| 13 | $S0 = substr line, 0, 9 | ||
| 14 | if $S0 == 'Bail out!' goto bail_out | ||
| 15 | .return(0) | ||
| 16 | bail_out: | ||
| 17 | .return(1) | ||
| 18 | .end | ||
| 19 | |||
| 11 | 20 | .sub parse_tapstream :method | |
| 12 | 21 | .param string tap | |
| 13 | 22 | .param int exit_code :optional | |
| 14 | 23 | .local string curr_line | |
| 15 | 24 | .local pmc plan, pass, fail, skip, todo | |
| 16 | .local int i, curr_test, reported_test | ||
| 25 | .local int i, curr_test, reported_test, ordered, num_lines | ||
| 17 | 26 | .local pmc tap_lines, parts, klass, stream | |
| 18 | 27 | ||
| 19 | 28 | i = 0 | |
| 20 | 29 | curr_test = 1 | |
| 30 | ordered = 1 | ||
| 21 | 31 | fail = new 'Integer' | |
| 22 | 32 | skip = new 'Integer' | |
| 23 | 33 | todo = new 'Integer' | |
| … | … | ||
| 37 | 37 | parts = new 'ResizablePMCArray' | |
| 38 | 38 | ||
| 39 | 39 | split tap_lines, "\n", tap | |
| 40 | $I0 = tap_lines | ||
| 40 | num_lines = tap_lines | ||
| 41 | 41 | ||
| 42 | 42 | .local string plan_line | |
| 43 | 43 | plan_line = tap_lines[0] | |
| … | … | ||
| 45 | 45 | ||
| 46 | 46 | .local string prefix | |
| 47 | 47 | loop: | |
| 48 | if i >= $I0 goto done | ||
| 48 | if i >= num_lines goto done | ||
| 49 | 49 | curr_line = tap_lines[i] | |
| 50 | 50 | ||
| 51 | .local int need_to_bail | ||
| 52 | need_to_bail = self.'bail_if_necessary'(curr_line) | ||
| 53 | if need_to_bail goto done | ||
| 54 | |||
| 55 | .local int is_tap | ||
| 56 | is_tap = self.'is_tap'(curr_line) | ||
| 57 | unless is_tap goto unrecognized | ||
| 58 | |||
| 51 | 59 | split parts, "ok ", curr_line | |
| 52 | 60 | ||
| 53 | 61 | prefix = parts[0] | |
| … | … | ||
| 64 | 64 | if prefix == 'not ' goto fail_or_todo | |
| 65 | 65 | ||
| 66 | 66 | if reported_test == curr_test goto pass_or_skip | |
| 67 | # out of order test | ||
| 68 | ordered = 0 | ||
| 67 | 69 | ||
| 68 | # it was an unrecognized line | ||
| 70 | goto pass_or_skip | ||
| 71 | |||
| 72 | unrecognized: # doesn't look like TAP, just ignore | ||
| 69 | 73 | inc i | |
| 70 | 74 | goto loop | |
| 75 | |||
| 71 | 76 | pass_or_skip: | |
| 72 | 77 | split parts, "# ", curr_line | |
| 73 | 78 | $S0 = parts[1] | |
| … | … | ||
| 108 | 108 | ||
| 109 | 109 | done: | |
| 110 | 110 | stream = new [ 'Tapir'; 'Stream' ] | |
| 111 | stream.'set_ordered'(ordered) | ||
| 111 | 112 | stream.'set_pass'(pass) | |
| 112 | 113 | stream.'set_fail'(fail) | |
| 113 | 114 | stream.'set_todo'(todo) | |
| … | … | ||
| 118 | 118 | .return (stream) | |
| 119 | 119 | .end | |
| 120 | 120 | ||
| 121 | # parse_plan returns the expected number of test given a TAP stream as a string | ||
| 121 | .sub is_tap :method | ||
| 122 | .param string tapline | ||
| 123 | $S0 = substr tapline, 0, 3 | ||
| 124 | if $S0 == "ok " goto yes | ||
| 125 | |||
| 126 | $S0 = substr tapline, 0, 7 | ||
| 127 | if $S0 == "not ok " goto yes | ||
| 128 | |||
| 129 | no: | ||
| 130 | .return( 0 ) | ||
| 131 | yes: | ||
| 132 | .return( 1 ) | ||
| 133 | .end | ||
| 134 | |||
| 135 | # parse_plan returns the expected number of tests given a plan line as a string | ||
| 122 | 136 | ||
| 123 | 137 | .sub parse_plan :method | |
| 124 | 138 | .param string plan_line |
ext/Tapir/Stream.pir
(18 / 2)
|   | |||
| 11 | 11 | .local pmc klass | |
| 12 | 12 | ||
| 13 | 13 | klass = newclass [ 'Tapir'; 'Stream' ] | |
| 14 | klass.'add_attribute'('ordered') | ||
| 14 | 15 | klass.'add_attribute'('pass') | |
| 15 | 16 | klass.'add_attribute'('fail') | |
| 16 | 17 | klass.'add_attribute'('skip') | |
| … | … | ||
| 29 | 29 | exit_code = self."get_exit_code"() | |
| 30 | 30 | if exit_code goto failz | |
| 31 | 31 | ||
| 32 | .local pmc skip, pass, todo, plan | ||
| 32 | .local pmc skip, pass, todo, plan, ordered | ||
| 33 | ordered = self."get_ordered"() | ||
| 34 | unless ordered goto disorder | ||
| 35 | |||
| 33 | 36 | skip = self."get_skip"() | |
| 34 | 37 | pass = self."get_pass"() | |
| 35 | 38 | todo = self."get_todo"() | |
| … | … | ||
| 40 | 40 | $P0 = pass + todo | |
| 41 | 41 | $P0 += skip | |
| 42 | 42 | ||
| 43 | $I1 = plan == $P0 | ||
| 43 | $I1 = plan == $P0 | ||
| 44 | 44 | .return( $I1 ) | |
| 45 | disorder: | ||
| 45 | 46 | failz: | |
| 46 | 47 | .return( 0 ) | |
| 47 | 48 | .end | |
| … | … | ||
| 52 | 52 | setattribute self, "exit_code", exit_code | |
| 53 | 53 | .end | |
| 54 | 54 | ||
| 55 | .sub set_ordered :method | ||
| 56 | .param pmc ordered | ||
| 57 | setattribute self, "ordered", ordered | ||
| 58 | .end | ||
| 59 | |||
| 55 | 60 | .sub set_pass :method | |
| 56 | 61 | .param pmc pass | |
| 57 | 62 | setattribute self, "pass", pass | |
| … | … | ||
| 86 | 86 | .local pmc exit_code | |
| 87 | 87 | exit_code = getattribute self, "exit_code" | |
| 88 | 88 | .return( exit_code ) | |
| 89 | .end | ||
| 90 | |||
| 91 | .sub get_ordered :method | ||
| 92 | .local pmc ordered | ||
| 93 | ordered = getattribute self, "ordered" | ||
| 94 | .return( ordered ) | ||
| 89 | 95 | .end | |
| 90 | 96 | ||
| 91 | 97 | .sub get_pass :method |
t/harness.pir
(1 / 1)
|   | |||
| 174 | 174 | $I0 = stream.'get_fail'() | |
| 175 | 175 | print $I0 | |
| 176 | 176 | inc failing_files | |
| 177 | inc failing_tests | ||
| 177 | failing_tests += $I0 | ||
| 178 | 178 | $S1 = stream.'total'() | |
| 179 | 179 | $S0 = "/" . $S1 | |
| 180 | 180 | print $S0 |

