Skip to content
Browse files

Out of order tests are now detected

Test files which contain out of order tests will now fail.

Better diagnostics, such as:

    Out of order tests detected, saw test 42 but expected test 5

would be nice.
  • Loading branch information...
1 parent ff8b843 commit 42a74c6685909b8b1b3d7fcc8a0718b2f8e27122 @leto committed Jan 24, 2010
Showing with 22 additions and 2 deletions.
  1. +4 −0 lib/Tapir/Parser.pir
  2. +18 −2 lib/Tapir/Stream.pir
View
4 lib/Tapir/Parser.pir
@@ -67,9 +67,12 @@ Written and maintained by Jonathan "Duke" Leto C<< jonathan@leto.net >>.
# out of order test
ordered = 0
+ goto pass_or_skip
+
unrecognized: # doesn't look like TAP, just ignore
inc i
goto loop
+
pass_or_skip:
split parts, "# ", curr_line
$S0 = parts[1]
@@ -105,6 +108,7 @@ Written and maintained by Jonathan "Duke" Leto C<< jonathan@leto.net >>.
done:
stream = new [ 'Tapir'; 'Stream' ]
+ stream.'set_ordered'(ordered)
stream.'set_pass'(pass)
stream.'set_fail'(fail)
stream.'set_todo'(todo)
View
20 lib/Tapir/Stream.pir
@@ -11,6 +11,7 @@
.local pmc klass
klass = newclass [ 'Tapir'; 'Stream' ]
+ klass.'add_attribute'('ordered')
klass.'add_attribute'('pass')
klass.'add_attribute'('fail')
klass.'add_attribute'('skip')
@@ -28,16 +29,20 @@
exit_code = self."get_exit_code"()
if exit_code goto failz
- .local pmc skip, pass, todo, plan
+ .local pmc skip, pass, todo, plan, ordered
+ ordered = self."get_ordered"()
+ unless ordered goto disorder
+
skip = self."get_skip"()
pass = self."get_pass"()
todo = self."get_todo"()
plan = self."get_plan"()
$P0 = pass + todo
$P0 += skip
- $I1 = plan == $P0
+ $I1 = plan == $P0
.return( $I1 )
+ disorder:
failz:
.return( 0 )
.end
@@ -47,6 +52,11 @@
setattribute self, "exit_code", exit_code
.end
+.sub set_ordered :method
+ .param pmc ordered
+ setattribute self, "ordered", ordered
+.end
+
.sub set_pass :method
.param pmc pass
setattribute self, "pass", pass
@@ -78,6 +88,12 @@
.return( exit_code )
.end
+.sub get_ordered :method
+ .local pmc ordered
+ ordered = getattribute self, "ordered"
+ .return( ordered )
+.end
+
.sub get_pass :method
.local pmc pass
pass = getattribute self, "pass"

0 comments on commit 42a74c6

Please sign in to comment.
Something went wrong with that request. Please try again.