convex-pbt-cli
Safe HaskellSafe-Inferred
LanguageHaskell2010

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

Events

data Event Source #

A streaming event. Each constructor keeps the line's raw JSON.

Constructors

EventSuiteStarted

suite_started: the whole test tree, before anything runs. This is also the single event --list-tests-json emits.

Fields

EventTestStarted
test_started

Fields

EventTestDone
test_done
EventSuiteDone
suite_done
EventOther

any other tag — test_progress, test_trace, or something added to the library after this binary was built.

Fields

Instances

Instances details
FromJSON Event Source # 
Instance details

Defined in PbtCli.Events

Show Event Source # 
Instance details

Defined in PbtCli.Events

Methods

showsPrec :: Int -> Event -> ShowS #

show :: Event -> String #

showList :: [Event] -> ShowS #

Eq Event Source # 
Instance details

Defined in PbtCli.Events

Methods

(==) :: Event -> Event -> Bool #

(/=) :: Event -> Event -> Bool #

data TestInfo Source #

One test in the tree, as reported by suite_started.

Constructors

TestInfo 

Fields

Instances

Instances details
FromJSON TestInfo Source # 
Instance details

Defined in PbtCli.Events

Show TestInfo Source # 
Instance details

Defined in PbtCli.Events

Eq TestInfo Source # 
Instance details

Defined in PbtCli.Events

data Failure Source #

Why a test failed.

Constructors

Failure 

Instances

Instances details
FromJSON Failure Source # 
Instance details

Defined in PbtCli.Events

Show Failure Source # 
Instance details

Defined in PbtCli.Events

Eq Failure Source # 
Instance details

Defined in PbtCli.Events

Methods

(==) :: Failure -> Failure -> Bool #

(/=) :: Failure -> Failure -> Bool #

eventTag :: Event -> Text Source #

The event's event tag.

eventRaw :: Event -> Value Source #

The event's original JSON, for pass-through output.

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

Instances details
Show SuiteOutcome Source # 
Instance details

Defined in PbtCli.Events

Eq SuiteOutcome Source # 
Instance details

Defined in PbtCli.Events