# HG changeset patch # User Jan Vrany # Date 1373040904 -7200 # Node ID cc00c3e2019ce427c5c70f7801faac6becb30548 # Parent d6aa9cd00ae0d47c9c0826b19a80787f54e39ea4 Fix for JUnit XML report. Write correctly formated CDATA section when the text itself contains CDATA terminator (string ']]>') diff -r d6aa9cd00ae0 -r cc00c3e2019c reports/Builder__TestReportFormat.st --- 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:'">'; nextPut:Character lf @@ -306,7 +305,39 @@ stream flush "Created: / 03-08-2011 / 19:42:17 / Jan Vrany " - "Modified: / 21-11-2012 / 15:35:43 / Jan Vrany " + "Modified: / 05-07-2013 / 16:54:24 / Jan Vrany " +! ! + +!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: ']]>'. + 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 " ! ! !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$' ! ! +