pyrmont / testament

A testing library for Janet
MIT License
28 stars 8 forks source link

Adds possibility to override the built-in report printer #2

Closed roobie closed 4 years ago

roobie commented 4 years ago

The built-in default is used if none is explicitly configured.

The reason for this is to be able to produce e.g. TAP output so the library theoretically can be used with existing pretty printers.

roobie commented 4 years ago

I am willing to improve the patch if you have any suggestions? I think it could be nice if it was possible to "stream" results to a plugin. I.e. for each assert, there could be a callback invoked or something.

pyrmont commented 4 years ago

@roobie This is awesome! Thanks so much for submitting the PR :D I made some minor changes to make the style consistent with the remainder of the code. Let me know what you think!

pyrmont commented 4 years ago

@roobie Streaming results could be interesting. Would your idea be to add a variable that would be called instead of compose-and-record-result (but with that set as the default)? Similar to how the report printer works. Or would there need to be broader architectural changes?

roobie commented 4 years ago

:+1: Looks much better now! Sorry for being sloppy :) - I'll do better next time. I think your idea about making the compose-and-record-result configurable will cover the use case. If you don't mind, I'll take a stab at making it so and also implement a TAP-style printer.

roobie commented 4 years ago

Actually, having taken a closer look, I don't think we need to make the compose-and-record-result configurable, but instead we can have a (var- compose-and-record-result-hook)-function that can be set, and in the compose-and-record-result we call the hook, if set to a function. By doing that, testament can still track the results and without too big of a change.

pyrmont commented 4 years ago

@roobie Oh nice idea! I'll merge this now but please feel free to add that as a separate PR :)