Fix for JUnit XML report.
Write correctly formated CDATA section when the text itself contains CDATA terminator (string ']]>')
--- a/reports/Builder__TestReportFormat.st Sun Jun 30 00:45:43 2013 +0200
+++ b/reports/Builder__TestReportFormat.st Fri Jul 05 18:15:04 2013 +0200
@@ -190,7 +190,7 @@
!TestReportFormat::JUnit class methodsFor:'documentation'!
version_SVN
- ^ '§Id: Builder__TestReportFormat.st 282 2011-11-07 08:51:43Z vranyj1 §'
+ ^ '$Id$'
! !
!TestReportFormat::JUnit methodsFor:'initialization'!
@@ -291,8 +291,7 @@
nextPutAll:'" message="';
nextPutAll:(self encode: message);
nextPutAll:'"><!![CDATA['; cr.
- stream
- nextPutAll:(stacktrace ? 'stacktrace not available').
+ self writeCDATA: (stacktrace ? 'stacktrace not available').
stream
nextPutAll:']]></'; nextPutAll: outcome; nextPutAll:'>';
nextPut:Character lf
@@ -306,7 +305,39 @@
stream flush
"Created: / 03-08-2011 / 19:42:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 21-11-2012 / 15:35:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 05-07-2013 / 16:54:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!TestReportFormat::JUnit methodsFor:'writing - utilities'!
+
+writeCDATA: string
+ | start stop |
+
+ start := 1.
+ stop := start.
+ [ (stop := (string indexOf: $] startingAt: stop)) ~~ 0 ] whileTrue:[
+ ((stop < (string size - 1))
+ and:[(string at: stop + 1) == $]
+ and:[(string at: stop + 2) == $>]]) ifTrue:[
+ " Okay, found CDATA end token "
+ stream nextPutAll: string startingAt: start to: stop + 1.
+ stream nextPutAll: ']]><!![CDATA[>'.
+ start := stop := stop + 3.
+ ] ifFalse:[
+ stop := stop + 1.
+ ].
+ ].
+ start < string size ifTrue:[
+ stream nextPutAll: string startingAt: start to: string size.
+ ].
+
+ "
+ String streamContents:[:s | Builder::TestReportFormat::JUnit new report: nil stream: s; writeCDATA:'ABCD']
+ String streamContents:[:s | Builder::TestReportFormat::JUnit new report: nil stream: s; writeCDATA:']]]]']
+ String streamContents:[:s | Builder::TestReportFormat::JUnit new report: nil stream: s; writeCDATA:'Some <[CDATA[ CDATA ]]> Some Text and stray terminator ]]> here']
+ "
+
+ "Created: / 05-07-2013 / 16:54:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!TestReportFormat::PerfPublisher class methodsFor:'accessing'!
@@ -322,7 +353,7 @@
!TestReportFormat::PerfPublisher class methodsFor:'documentation'!
version_SVN
- ^ '§Id: Builder__TestReportFormat.st 282 2011-11-07 08:51:43Z vranyj1 §'
+ ^ '$Id$'
! !
!TestReportFormat::PerfPublisher methodsFor:'writing'!
@@ -459,7 +490,7 @@
!TestReportFormat::PythonUnittest class methodsFor:'documentation'!
version_SVN
- ^ '§Id: Builder__TestReportFormat.st 282 2011-11-07 08:51:43Z vranyj1 §'
+ ^ '$Id$'
! !
!TestReportFormat::PythonUnittest methodsFor:'writing'!
@@ -531,7 +562,7 @@
!TestReportFormat::TAP class methodsFor:'documentation'!
version_SVN
- ^ '§Id: Builder__TestReportFormat.st 282 2011-11-07 08:51:43Z vranyj1 §'
+ ^ '$Id$'
! !
!TestReportFormat::TAP methodsFor:'accessing - defaults'!
@@ -595,5 +626,6 @@
!
version_SVN
- ^ '§Id: Builder__TestReportFormat.st 282 2011-11-07 08:51:43Z vranyj1 §'
+ ^ '$Id$'
! !
+