Verified Commit 63094448 authored by Camil Staps's avatar Camil Staps 🚀

Use source locations in JUnit export when available

parent 082b2b99
Pipeline #27778 failed with stage
in 48 seconds
implementation module Testing.JUnitExport
import StdEnv
import StdMaybe
import Data.Func
import Data.Maybe
import System.FilePath
import Testing.Options
import Testing.TestEvents
......@@ -49,8 +49,8 @@ where
}
where
failure msg =
{ juf_file = suite_name // TODO
, juf_line = 0 // TODO
{ juf_file = fromMaybe "" event.EndEvent.filename
, juf_line = fromMaybe 0 event.EndEvent.line
, juf_category = "failed unit test"
, juf_message = msg
, juf_severity = "ERROR"
......
......@@ -253,7 +253,7 @@ list r w
run :: !Options !SubTestRun !*World -> *(!RunResult, !*World)
run opts r w
# (io,w) = stdio w
# io = emit (StartEvent {StartEvent | name=name}) io
# io = emit (StartEvent {StartEvent | name=name, filename=Nothing, line=Nothing}) io
with name = (case r of JustRun r -> r; Only _ r -> r; Without _ r -> r).TestRun.name
# (extra_opts,r,w) = case r of
JustRun r -> (Just [], r, w)
......@@ -263,9 +263,11 @@ run opts r w
_ -> Just ["--skip":intersperse "--skip" names], r, w)) $ list r w
| isNothing extra_opts
# io = emit (EndEvent
{ name = r.TestRun.name
, event = Passed
, message = "No remaining tests"
{ name = r.TestRun.name
, filename = Nothing
, line = Nothing
, event = Passed
, message = "No remaining tests"
}) io
= return Passed [] r io w
# extra_opts = fromJust extra_opts
......@@ -274,9 +276,11 @@ run opts r w
# (err,msg) = fromError h
# event = Failed Nothing
# io = emit (EndEvent
{ name = r.TestRun.name
, event = event
, message = "Failed to execute " <+ r.TestRun.name <+ " (" <+ err <+ "; " <+ msg <+ ")"
{ name = r.TestRun.name
, filename = Nothing
, line = Nothing
, event = event
, message = "Failed to execute " <+ r.TestRun.name <+ " (" <+ err <+ "; " <+ msg <+ ")"
}) io
= return event [] r io w
# (h,pio) = fromOk h
......@@ -299,9 +303,11 @@ where
# (err,msg) = fromError t
# event = Failed Nothing
# io = emit (EndEvent
{ name = r.TestRun.name
, event = event
, message = "Failed to check on child process (" <+ err <+ "; " <+ msg <+ ")"
{ name = r.TestRun.name
, filename = Nothing
, line = Nothing
, event = event
, message = "Failed to check on child process (" <+ err <+ "; " <+ msg <+ ")"
}) io
= return event [] r io w
# rcode = fromOk t
......@@ -312,9 +318,11 @@ where
| any isNothing results
# event = Failed Nothing
# io = emit (EndEvent
{ name = r.TestRun.name
, event = event
, message = join "\n "
{ name = r.TestRun.name
, filename = Nothing
, line = Nothing
, event = event
, message = join "\n "
[ "Failed to read child messages:"
: [printToString (ellipsis 40 outp) \\ outp <- output.lines & Nothing <- results]
]
......@@ -332,12 +340,15 @@ where
| ee.event=:(Failed (Just (FailedChildren _)))
// We already have a FailedChildren message; no need for another about the exit code
= return event [ee \\ EndEvent ee <- events] r io w
# io = emit ( EndEvent { name = r.TestRun.name
, event = event
, message = "Child process exited with " <+ fromJust rcode
}
)
io
# io = emit
(EndEvent
{ name = r.TestRun.name
, filename = Nothing
, line = Nothing
, event = event
, message = "Child process exited with " <+ fromJust rcode
})
io
= return event [ee \\ EndEvent ee <- events] r io w
= return ee.event [ee \\ EndEvent ee <- events] r io w
# w = snd $ fclose io w
......@@ -345,8 +356,10 @@ where
where
collectEvents :: [TestEvent] -> EndEvent
collectEvents tes =
{ name = r.TestRun.name
, event = if (isEmpty failed && isEmpty lost) Passed
{ name = r.TestRun.name
, filename = Nothing
, line = Nothing
, event = if (isEmpty failed && isEmpty lost) Passed
(Failed $ Just $ FailedChildren $
[(name, fr) \\ EndEvent {name,event=Failed fr} <- failed] ++
[(l, Just Crashed) \\ l <- lost])
......@@ -375,9 +388,11 @@ where
_ -> fromError err
# event = Failed Nothing
# io = emit (EndEvent
{ name = r.TestRun.name
, event = event
, message = "Failed to read child process IO (" <+ err <+ "; " <+ msg <+ ")"
{ name = r.TestRun.name
, filename = Nothing
, line = Nothing
, event = event
, message = "Failed to read child process IO (" <+ err <+ "; " <+ msg <+ ")"
}) io
= (Error oserr, output, io, w)
# out = fromOk out
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment