diff options
| author | Roman Smrž <roman.smrz@seznam.cz> | 2026-09-06 10:50:17 +0200 |
|---|---|---|
| committer | Roman Smrž <roman.smrz@seznam.cz> | 2026-09-08 20:11:47 +0200 |
| commit | 66b914a1eef9a86126cd39954c676a51e92fa182 (patch) | |
| tree | 92242a3541dd9a2012f9b8718c9eea109e36dd23 /src/JUnit.hs | |
| parent | 359ddc68ea519108c3cf05c7a6eaff02217e979f (diff) | |
Add standard output to the JUnit report
Diffstat (limited to 'src/JUnit.hs')
| -rw-r--r-- | src/JUnit.hs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/JUnit.hs b/src/JUnit.hs index 71fe3c1..03e07ec 100644 --- a/src/JUnit.hs +++ b/src/JUnit.hs @@ -9,6 +9,7 @@ import Data.ByteString.Char8 qualified as BC import Data.Function import Data.List.NonEmpty qualified as NE import Data.Scientific +import Data.Text qualified as T import Data.Text.Encoding import System.Directory @@ -34,15 +35,26 @@ writeJUnitReport path Report {..} = do B.hPutStr h $ B.concat [ "<testcase name=\"", encodeUtf8 (testNameBase reportTestName), "\"" , " classname=\"", encodeUtf8 (textModuleName $ testNameModule reportTestName), "\"" - , " time=\"", showTime reportTime, "\"" + , " time=\"", showTime reportTime, "\">" + , "<system-out>" + , encodeUtf8 $ escape reportOutput + , "</system-out>" , case reportTestFailed of Nothing -> do - " />" + "" Just Failed -> do - "><failure message=\"Test failed\"></failure></testcase>" + "<failure message=\"Test failed\">" <> encodeUtf8 (escape reportOutputError) <> "</failure>" Just (ProcessCrashed _) -> do - "><error message=\"Process crashed\"></error></testcase>" + "<error message=\"Process crashed\">" <> encodeUtf8 (escape reportOutputError) <> "</error>" + , "</testcase>" ] B.hPutStr h $ "</testsuite>" B.hPutStr h $ "</testsuites>\n" + + where + escape = T.concatMap $ \case + '&' -> "&" + '<' -> "<" + '>' -> ">" + c -> T.singleton c |