| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
PbtCli.Events
Description
The NDJSON events a streaming test suite emits, as much of them as
pbt-cli needs.
This is deliberately a *partial* view of Convex.Tasty.Streaming.Types.Event.
pbt-cli has to keep working against suites built with an older or newer
convex-tasty-streaming than the one it was compiled against, so every event
also keeps its raw Value and any tag this module does not know about decodes
to EventOther instead of failing. Only the fields the CLI actually renders or
makes decisions on are given names; test_trace payloads, coverage indices,
threat-model summaries and QuickCheck monitoring stats are passed through
untouched.
The canonical, complete schema lives in
src/tasty-streaming/schema/streaming-events.schema.json.
Synopsis
- data Event
- = EventSuiteStarted { }
- | EventTestStarted { }
- | EventTestDone { }
- | EventSuiteDone { }
- | EventOther {
- evOtherTag :: Text
- evSource :: Value
- data TestInfo = TestInfo {}
- data Failure = Failure {
- failReason :: Text
- failMessage :: Text
- eventTag :: Event -> Text
- eventRaw :: Event -> Value
- decodeEvent :: ByteString -> Either String Event
- isJsonObjectLine :: ByteString -> Bool
- jsonLines :: [ByteString] -> [ByteString]
- eventsFrom :: [ByteString] -> [Event]
- suiteOutcome :: [Event] -> Maybe SuiteOutcome
- data SuiteOutcome = SuiteOutcome {}
Events
A streaming event. Each constructor keeps the line's raw JSON.
Constructors
| EventSuiteStarted |
|
| EventTestStarted | test_started |
| EventTestDone | test_done |
| EventSuiteDone | suite_done |
| EventOther | any other tag — |
Fields
| |
One test in the tree, as reported by suite_started.
Constructors
| TestInfo | |
Why a test failed.
Constructors
| Failure | |
Fields
| |
Parsing a suite's stdout
decodeEvent :: ByteString -> Either String Event Source #
Decode one line as an event.
Left covers both "not JSON at all" (cabal's own chatter) and "JSON, but not
a recognisable event", which the caller normally wants to treat the same way:
ignore it.
isJsonObjectLine :: ByteString -> Bool Source #
Is this single line a JSON object?
The cheap { check comes first so cabal's chatter is rejected without paying
for a parse attempt on every build-progress line.
jsonLines :: [ByteString] -> [ByteString] Source #
Keep only the lines of a suite's stdout that are JSON objects.
cabal test interleaves its own output — Resolving dependencies,
Running 1 test suites..., build progress — with the suite's NDJSON. This is
the equivalent of the jq -R 'fromjson? // empty' idiom the tasty-streaming
README recommends, and for the same reason: there is no way to ask cabal to
stop talking, so the consumer filters.
eventsFrom :: [ByteString] -> [Event] Source #
Every decodable event in a suite's stdout, in order.
Interpreting a run
suiteOutcome :: [Event] -> Maybe SuiteOutcome Source #
The run's suite_done tally, if the suite got that far.
Nothing means the suite never reported a summary — it crashed, was killed, or
was not a streaming suite at all — which is why callers must not treat a
missing summary as success.
data SuiteOutcome Source #
What a completed run amounted to.
Constructors
| SuiteOutcome | |
Instances
| Show SuiteOutcome Source # | |
Defined in PbtCli.Events Methods showsPrec :: Int -> SuiteOutcome -> ShowS # show :: SuiteOutcome -> String # showList :: [SuiteOutcome] -> ShowS # | |
| Eq SuiteOutcome Source # | |
Defined in PbtCli.Events | |