Closed revelt closed 4 years ago
So, what you're asking for is somewhat at odds with the nature of how TAP works. It is a line-based streaming protocol, not an object serialization notation.
We could pretty easily create a static method to "parse" a string into the array of events and arguments that is output by default by bin/cmd.js
, and in the other direction, turn such a nested array into a TAP string. Since the bin has a --tap
output option, the code to turn the array back into TAP is there already. Would just be a matter of refactoring it into static methods in the exported class.
If you want to do this today, you can do something like cat my-test-output.tap | tap-parser --json
.
Thanks for adding this! I could use this in a project I'm working on. Any chance a new release including this could get published to npm?
@dramirez42 since original posting I wrote tap-parse-string-to-object — it's not comprehensive, it's aimed at extracting total counts but maybe it will do?
Oh, whoops, I'd forgotten to push it, I guess. Published now as 10.1.
Hi all,
Thank you for making the Tap ecosystem. I have a newbie-related readme suggestion; please excuse any ignorance from my side.
Currently we allude this is The Parser:
But this program seems to me like a terminal-oriented parser, not aimed at Node scripting, à la
JSON.parse
, "string-in, object-out".If it is possible to achieve "string-in, object-out" parsing using this program, it is not a trivial task; if you can, please supplement the readme with a code example to achieve that.
If it is not possible to parse into an object, let's direct people to an alternative parser which does this.
If anybody wonders why am I concerned about parsing into a plain object, I want to compile statistics of a monorepo, from a bunch of packages' raw Tap output files, received via
tap -o
. It's a seemingly trivial task but I'm still in search how to parse the raw TAP "string-in, object-out".Again, thank you for any help or advise.