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)
......@@ -264,6 +264,8 @@ run opts r w
| isNothing extra_opts
# io = emit (EndEvent
{ name = r.TestRun.name
, filename = Nothing
, line = Nothing
, event = Passed
, message = "No remaining tests"
}) io
......@@ -275,6 +277,8 @@ run opts r w
# event = Failed Nothing
# io = emit (EndEvent
{ name = r.TestRun.name
, filename = Nothing
, line = Nothing
, event = event
, message = "Failed to execute " <+ r.TestRun.name <+ " (" <+ err <+ "; " <+ msg <+ ")"
}) io
......@@ -300,6 +304,8 @@ where
# event = Failed Nothing
# io = emit (EndEvent
{ name = r.TestRun.name
, filename = Nothing
, line = Nothing
, event = event
, message = "Failed to check on child process (" <+ err <+ "; " <+ msg <+ ")"
}) io
......@@ -313,6 +319,8 @@ where
# event = Failed Nothing
# io = emit (EndEvent
{ name = r.TestRun.name
, filename = Nothing
, line = Nothing
, event = event
, message = join "\n "
[ "Failed to read child messages:"
......@@ -332,11 +340,14 @@ 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
# 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
......@@ -346,6 +357,8 @@ where
collectEvents :: [TestEvent] -> EndEvent
collectEvents tes =
{ 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] ++
......@@ -376,6 +389,8 @@ where
# event = Failed Nothing
# io = emit (EndEvent
{ name = r.TestRun.name
, filename = Nothing
, line = Nothing
, event = event
, message = "Failed to read child process IO (" <+ err <+ "; " <+ msg <+ ")"
}) io
......
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