Open jamiebuilds opened 6 years ago
This is very cool. We could then potentially run linting and tests in parallel.
I think I'm gonna do it like this:
(./run-tests.sh | zap-wrap 0 "Tests" & ./run-lints.sh | zap-wrap 1 "Lints")
Where ... | zap-wrap <id> <message>
accepts stdin and outputs:
// prepends a group "started" event
{"kind":"group","event":"started","id":"<id>","timestamp":"...","content":[{"message":"<message>"}]}
// modifies previous contents as stream:
{ ... "id":"<id>.<previous id>" ... }
// appends a group completion event that "passed" or "failed" based on the process exit code
{"kind":"group","event":"<passed|failed>","id":"<id>","timestamp":"...","content":[{"message":"<message>"}]}
Because of the
"id"
format, it is easy to merge together multiple ZAP streams into a single stream simply by prepending all the"id"
's in each stream with another number for the stream and some sort of label.Stream 1:
Stream 2:
Merged Streams:
This allows ZAP reporters to report the output from multiple tools without any additional changes.
There are no required changes to ZAP to support this behavior, but it seems worth documenting and maybe writing a library to do automatically.