Add test formatting options (toon, yaml, json)#1127
Conversation
isc-tleavitt
left a comment
There was a problem hiding this comment.
My main feedback is on how the OutputSuppressor works. Using the null device is - I think! - better than I/O redirection. One catch with I/O redirection is behavior if there's output after changing to a namespace (e.g. %SYS) that doesn't have the routine used - null device gets around that.
Also should improve cleanup for OutputSuppressor to use %RegisteredObject patterns along the lines of https://community.intersystems.com/post/robust-error-handling-and-cleanup-objectscript
| new $namespace | ||
| set tInitNS = $select($namespace="%SYS": "USER", 1: $namespace) | ||
| set tVerbose = $get(pParams("Verbose")) | ||
| set explicitQuiet = ($data(pParams("Verbose")) && (pParams("Verbose") = 0)) |
There was a problem hiding this comment.
Nitpick: $data(pParams("Verbose"))#2
But probably doesn't really matter.
There was a problem hiding this comment.
I don't believe that's quite right as this is checking if pParams("Verbose") has been explicitly set to 0.
| Class %IPM.Utils.OutputSuppressor | ||
| { | ||
|
|
||
| ClassMethod Begin(Output cookie As %String) As %Status [ ProcedureBlock = 0 ] |
There was a problem hiding this comment.
Should just use $io / the null device rather than I/O redirection? https://docs.intersystems.com/iris20261/csp/docbook/DocBook.UI.Page.cls?KEY=GIOD_principalandcurrent#GIOD_iodc_procdev_nulldev
There was a problem hiding this comment.
Instead return an instance of this class ByRef that manages cleanup through manual call or %OnClose.
There was a problem hiding this comment.
Switched to using the null device
| /// Used as the mnemonic device routine for BeginSuppressOutput / EndSuppressOutput. | ||
| /// Unlike BeginCaptureOutput, suppress does not use ^||%capture, so it is safe | ||
| /// to call while a capture is already active. | ||
| Class %IPM.Utils.OutputSuppressor |
There was a problem hiding this comment.
Should end capture in %OnClose.
| } | ||
| } | ||
| } catch e { | ||
| if capturing { |
There was a problem hiding this comment.
Don't need to do this if OutputSuppressor cancels in OnClose.
|
@isc-tleavitt Addressed the comments by switching to using the null device and the registered object/%OnClose pattern |
Description
-f <format>flag (json, yaml, toon) on test/verify: one-shot terminal output format override. When omitted, falls back to the persistent default set viaconfig set TestReportFormat <format>, and if neither is configured, shows the existing plain-text summary + legacy red FAILED lines.-output-file <path>flag: writes full results to a file; format inferred from extension (.json, .yaml, .toon, .xml for JUnit XML).-quietbehavior: suppresses build/install noise during test/verify while still showing the result summary.config set/delete TestReportFormat: persistent default format; config delete now correctly resets to empty (legacy mode) rather than restoring the first-ever value.test <module-name> -quiet -format toon, where-quietwill suppress almost all other output and what's left will be a summary and the failed tests in the TOON format.Examples
Testing
New unit test (Test.PM.Unit.CLI:TestReportFormatConfiguration) and extensive integration tests (Test.PM.Integration.TestOutputFormat) to cover all the different flag combos.
Checklist
mainbranch rebased or merged.zpm test -only) and integration tests (zpm verify -only) pass.