| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Convex.Tasty.Streaming
Synopsis
Documentation
streamingJsonReporter :: Ingredient Source #
The streaming JSON reporter ingredient.
When activated via --streaming-json, replaces console output with
newline-delimited JSON events streamed to stdout.
listTestsJsonIngredient :: Ingredient Source #
Ingredient that lists the test tree as JSON and exits without running tests.
Activated via --list-tests-json.
streamingIngredients :: [Ingredient] Source #
Default ingredients with streaming reporter added
defaultMainStreaming :: HasCallStack => TestTree -> IO () Source #
Drop-in replacement for defaultMain that supports --streaming-json.
If you bypass this entry point and wire streamingIngredients manually,
threat-model summaries will not appear in the JSON output unless you
also call
on your tree (with a freshly-allocated store from localOption (TMStoreOption (Just store)) . localOption (storeRecorder store)newTMStore).
Package root capture
The packageRoot field emitted on the SuiteStarted event is captured
from the call site of defaultMainStreaming (typically the user's
Main.hs) via HasCallStack. The mechanism is implemented in
callerPackageRoot: read the top of
callStack to obtain both the GHC package identifier of the calling
module and the file path it was compiled from, then search the workspace
(starting at the process working directory) for a directory containing
both a matching <pkgname>.cabal file and the relative source file.
This is correct in the common case where the Main.hs entry point and
the tests it assembles live in the same cabal package. It is not
correct for cross-package test reuse — for example, if Main.hs in
package A pulls in test trees defined in package B's library, those
tests will be attributed to package A, not B. We explicitly accept
this limitation; addressing it would require per-test source-location
metadata (e.g. via Template Haskell or CPP at every test definition
site), which is significantly more invasive.
If the resolution fails (e.g. the test is launched from a working
directory that does not contain the package, or the package name cannot
be extracted), packageRoot is omitted from the JSON output (consistent
with the existing Maybe-as-absent-key convention).
defaultMainStreamingWithIngredients :: HasCallStack => [Ingredient] -> TestTree -> IO () Source #
Variant of defaultMainStreaming that allows callers to prepend
additional ingredients (e.g. package-specific CLI option managers).
The same internal streaming wiring is always installed (threat-model summary store, trace recorder, shared output lock, and package root capture from call-site), then Tasty runs with:
extraIngredients <> streamingIngredients