feat: Add JSON, YAML, and Toon output options for zpm test results#979
feat: Add JSON, YAML, and Toon output options for zpm test results#979AshokThangavel wants to merge 2 commits intointersystems:mainfrom
Conversation
|
@AshokThangavel thank you for this! And for your other recent contributions. Just as a heads up / to set expectations, we have a serious backlog of large PRs right now and the people who most need to review (@isc-kiyer and I) also have a bunch of other non-IPM stuff on our plates. Getting community contribution on a project like this is like a dog chasing it's tail, and now that we've caught it we need to figure out what to do. :) There's a history of outstanding community contribution on IPM, but as part of inclusion in IRIS we've necessarily taken more control. On this particular PR, big picture (without a thorough review):
|
|
Hi @isc-tleavitt Regarding LLM-Friendly Output
|
isc-dchui
left a comment
There was a problem hiding this comment.
Seconding @isc-tleavitt's comment about needing extensive testing. Could you please create a test IPM module in ipm\tests\integration_tests\Test\PM\Integration\_data and a slew of tests that check that failures in the various places (in a test method, in On(Before|After)(AllTests|OneTest)) are caught and outputted properly?
| write ! | ||
| if $data(pParams("outputformat"),outputFormat)||('tVerbose) { | ||
| write !,"Test result summary",! | ||
| // TODO: Move this default format to ^IPM.Config.Test("outputFormat") rather than keeping it hardcoded. |
There was a problem hiding this comment.
%IPM.Repo.UniversalSettings would also be a good place for this. In either case, you still want to have some default if the globals aren't populated and some validation if they are.
| pTestStatus As %String = "", | ||
| pTestIndex As %Integer = {$order(^UnitTest.Result(""),-1)}) As %Status | ||
| { | ||
| set tSC = $$$OK |
There was a problem hiding this comment.
Nit: in new code, avoid t- and p- prefixes
| set fileStream.TranslateTable="UTF8" | ||
| do fileStream.LinkToFile(pFileName) | ||
| set responseJson = ..JSON(pTestIndex, pTestStatus) | ||
| do fileStream.Write(responseJson.%ToJSON()) |
There was a problem hiding this comment.
Make sure to ThrowOnError for LinkToFile and Write here and do the same throughout for methods that return statuses
| try { | ||
| set responseJson= ..JSON(pTestIndex, pCaseStatus) | ||
| write ! | ||
| do responseJson.%ToJSON() |
There was a problem hiding this comment.
Not fully sure what's happening here. Doesn't %ToJSON return the string of the dynamic object? But it's not being written here.
| do yamlStream.WriteLine(" methods:") | ||
| } | ||
| do yamlStream.WriteLine(" - methodName: """_tResult.methodName_"""") | ||
| //do yamlStream.WriteLine(" testMethod: """_tResult.testMethod_"""") |
There was a problem hiding this comment.
Any particular reason why these lines are commented out?
| do yamlStream.WriteLine(" namespace: """_tResult.namespace_"""") | ||
| do yamlStream.WriteLine(" duration: "_tResult.duration) | ||
| do yamlStream.WriteLine(" testDateTime: """_tResult.testDateTime_"""") | ||
| do yamlStream.WriteLine( "") |
There was a problem hiding this comment.
Nit: extra space before the ""
| while tResult.%Next() { | ||
| if currentID = "" { | ||
| set currentID = pTestIndex | ||
| do fileStream.WriteLine("unitTest:") |
There was a problem hiding this comment.
Lots of statuses that need checking here
| <modifier name="dev" dataAlias="DeveloperMode" dataValue="1" description="Sets the DeveloperMode flag for the module's lifecycle. Key consequences of this are that ^Sources will be configured for resources in the module, and installer methods will be called with the dev mode flag set." /> | ||
| <modifier name="quiet" aliases="q" dataAlias="Verbose" dataValue="0" description="Produces minimal output from the command." /> | ||
| <modifier name="verbose" aliases="v" dataAlias="Verbose" dataValue="1" description="Produces verbose output from the command." /> | ||
| <modifier name="output-format" aliases="output,f" dataAlias="outputformat" value="true" description="Specifies the desired output format for the command result (e.g., json, yaml, toon)." /> |
There was a problem hiding this comment.
Might as well include "format" as an alias if "f" is an alias.
Also this looks like it only affects the test output, so you should specify that.
| - #938 Added flag -export-python-deps to package command | ||
| - #462: The `repo` command for repository configuration now supports secret input terminal mode for passwords with the `-password-stdin` flag | ||
| - #935: Adding a generic JFrog Artifactory tarball resource processor for bundling artifact with a package and deploying it to a final location on install. | ||
| - #971: Adds support for JSON, YAML, and Toon formats via the -f flag and new -DUnitTest.*Output directives. |
There was a problem hiding this comment.
Move this to 0.10.6 please
| @@ -0,0 +1,60 @@ | |||
| /// Unit Test Class to validate the ZPM 'test' command output configuration. | |||
There was a problem hiding this comment.
Would also be good to test the verify command
Feature: Add Multi-Format Output (Toon, JSON, YAML) to
zpm testfixes #971
Summary
This Pull Request includes significant flexibility to the
zpm testcommand by allowing users to define the output format for both terminal display and file generation. This enhancement supportsToon(default),JSON, andYAMLformats, improving integration with external reporting tools and overall user experience.1. Terminal Output Control via
-f/-outputFlagThe new optional flag,
-f(or-output), allows users to specify the desired output format of the test results displayed directly in the terminal (stdout).Toon,Json,YamlToonformat.Interaction with Verbose Flag (
-v):-v): If the-v(verbose) flag is not defined, the selected format will be displayed to the terminal.-v) is defined in the command, the-fflag is ignored, and no output summary is displayed (maintaining the existing verbose behavior).Example Toon Output Structure (Terminal):
2. Dedicated Configuration Directives for File Generation (
-D)The existing configuration directive logic (
-D) used for file output (e.g.,-DUnitTest.JUnitOutput) has been extended to support the new formats to easily generate and store results files.The following new configuration directives are now supported:
-DUnitTest.JsonOutput/path/to/testresult.json-DUnitTest.YamlOutput/path/to/testresult.yaml-DUnitTest.ToonOutput/path/to/testresult.toonExample File Generation Command:
zpm "zpm test -only -DUnitTest.JsonOutput=/usr/irissys/mgr/user/testresult/testresult.json"Unit Test Verification
A dedicated unit test class,
Test.PM.Unit.TestResultsOPFormatAndFileGenTest, has been created to thoroughly test the new file generation functionality for all three formats.The test results below confirm that files are successfully generated and then cleaned up: