Commit c4443c4f authored by Camil Staps's avatar Camil Staps 🍃

Clarify human-readable output: add messages for crashed (lost) tests and non-zero exit code

parent a463aac0
Pipeline #29765 passed with stage
in 1 minute and 10 seconds
......@@ -24,7 +24,7 @@ import System.Options
import System.Process
import Testing.Options
import Testing.TestEvents
from Text import <+, class Text(join,lpad,replaceSubString,split,trim,concat), instance Text String
from Text import <+, class Text(join,lpad,ltrim,replaceSubString,split,trim,concat), instance Text String
import Text.GenJSON
import Text.GenPrint
import Text.Language
......@@ -236,7 +236,9 @@ where
| continue=:(Ok False)
# results = map (fromJSON o fromString) $ filter ((<>) "") output.lines
# events = map fromJust results
= return (collectEvents events).event [ee \\ EndEvent ee <- events] r io w
# (lost,ee) = collectEvents events
# io = foldl (flip emit) io lost
= return ee.event [ee \\ EndEvent ee <- events ++ lost] r io w
// Check if child has terminated
# (t,w) = checkProcess h w
| isError t
......@@ -271,45 +273,42 @@ where
| otherwise = s % (0,n-4) +++ "..."
= return event [] r io w
# events = map fromJust results
# ee = collectEvents events
# io = emit (EndEvent ee) io
# (lost,ee) = collectEvents events
# events = events ++ lost
# io = foldl (flip emit) io lost
| fromJust rcode <> 0
# event = Failed Nothing
| 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
, location = Nothing
, event = event
, message = "Child process exited with " <+ fromJust rcode
})
io
= return event [ee \\ EndEvent ee <- events] r io w
# msg = "Child process exited with " <+ fromJust rcode <+ "."
# ee & message = ltrim (ee.message +++ "\n" +++ msg)
# ee & event = case ee.event of
Passed -> Failed (Just (CustomFailReason msg))
_ -> ee.event
# io = emit (EndEvent ee) io
= return ee.event [ee \\ EndEvent ee <- events] r io w
# io = emit (EndEvent ee) io
= return ee.event [ee \\ EndEvent ee <- events] r io w
# w = snd $ fclose io w
= redirect output h pio r w
where
collectEvents :: [TestEvent] -> EndEvent
collectEvents :: [TestEvent] -> ([TestEvent], EndEvent)
collectEvents tes =
( [EndEvent {name=se.StartEvent.name, location=se.StartEvent.location, event=Failed (Just Crashed), message=""} \\ se <- lost],
{ name = r.TestRun.name
, location = Nothing
, event = if (isEmpty failed && isEmpty lost) Passed
(Failed $ Just $ FailedChildren $
[(name, fr) \\ EndEvent {name,event=Failed fr} <- failed] ++
[(l, Just Crashed) \\ l <- lost])
[(l.StartEvent.name, Just Crashed) \\ l <- lost])
, message =
pluralisen English (length passed) "test" <+ " passed, " <+
pluralisen English (length failed) "test" <+ " failed, " <+
pluralisen English (length skipped) "test" <+ " skipped and " <+
pluralisen English (length lost) "test" <+ " lost."
}
})
where
passed = filter (\te -> te=:(EndEvent {event=Passed})) tes
failed = filter (\te -> te=:(EndEvent {event=Failed _})) tes
skipped = filter (\te -> te=:(EndEvent {event=Skipped})) tes
lost = [se.StartEvent.name \\ StartEvent se <- tes
lost = [se \\ StartEvent se <- tes
| not
$ any (\(EndEvent ee) -> se.StartEvent.name == ee.EndEvent.name)
$ passed ++ failed ++ skipped]
......@@ -369,6 +368,7 @@ where
join "\n - " (map (replaceSubString "\n" "\n " o printCE) ces)
FailedChildren fcs -> "\n Children tests failed: " +++ join ", " (map fst fcs)
Crashed -> "\n Crashed"
CustomFailReason r -> "\n " +++ r
Failed Nothing -> "\n " +++ ee.message
_ -> ""
where
......
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