Permalink
Browse files

Ensure that we don't fail plan position with random stdout afterwards

  • Loading branch information...
1 parent 458cdfb commit 5c04459efc194372959bb3e044545d673ceee0fc Scott McWhirter committed Mar 12, 2012
@@ -184,8 +184,18 @@ public void parseLine( String tapLine )
}
// Last line that is not a comment.
- lastLine = tapLine;
-
+ // However we also need to ensure we don't don't capture random test either
+ if(
+ COMMENT_PATTERN.matcher( tapLine ).matches()
+ || HEADER_PATTERN.matcher( tapLine ).matches()
+ || PLAN_PATTERN.matcher( tapLine ).matches()
+ || TEST_RESULT_PATTERN.matcher( tapLine ).matches()
+ || BAIL_OUT_PATTERN.matcher( tapLine ).matches()
+ || FOOTER_PATTERN.matcher( tapLine ).matches()
+ ){
+ lastLine = tapLine;
+ }
+
// Header
matcher = HEADER_PATTERN.matcher( tapLine );
if ( matcher.matches() )
@@ -83,7 +83,17 @@ public void parseLine(String tapLine)
}
// Last line that is not a comment.
- lastLine = tapLine;
+ // However we also need to ensure we don't don't capture random test either
+ if(
+ COMMENT_PATTERN.matcher( tapLine ).matches()
+ || HEADER_PATTERN.matcher( tapLine ).matches()
+ || PLAN_PATTERN.matcher( tapLine ).matches()
+ || TEST_RESULT_PATTERN.matcher( tapLine ).matches()
+ || BAIL_OUT_PATTERN.matcher( tapLine ).matches()
+ || FOOTER_PATTERN.matcher( tapLine ).matches()
+ ){
+ lastLine = tapLine;
+ }
// Check if we already know the indentation level... if so, try to find
// out the indentation level of the current line in the TAP Stream.
@@ -432,4 +432,25 @@ public void testStateOfConsumer()
testSet = consumer.load( new File(TestTap13Consumer.class.getResource("/org/tap4j/consumer/two_tr.tap").getFile()) );
}
+ @Test(description="Tests a TapConsumer reading a plan at end with random output afterwards")
+ public void testTapConsumerStdoutAfterPlan()
+ {
+ TapConsumer tapConsumer = TapConsumerFactory.makeTap13Consumer();
+
+ TestSet testSet = null;
+
+ String validTapStream = "ok 1\n1..1\nJust some random stuff here";
+
+ try
+ {
+ testSet = tapConsumer.load(validTapStream);
+ }
+ catch ( TapConsumerException tapConsumerException )
+ {
+ Assert.fail( NOT_SUPPOSED_TO_GET_HERE );
+ }
+
+ Assert.assertNotNull( testSet );
+ }
+
}

0 comments on commit 5c04459

Please sign in to comment.