Skip to content

Testing framework: make `run test --display-format json` output the same JSON as `Test.to_json`

E. Rivas requested to merge er433/test/display-format-json into dev

Motivation and Context

It was reported in #ligo-debugger that --display-format json for run test just returns null.

Description

This MR derives the JSON output for the testing framework's return value.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Performance improvement (non-breaking change that improves performance)
  • None (change with no changelog)

Changelog

The output given by run test --display-format json is an array containing the name of the test entrypoint, followed by its value as a JSON (same format as Test.to_json, see API reference for further documentation on it). E.g.

$ cat display_format_json.mligo 
let test_x =
  let x = 42 in
  x + 23

let test_y =
  "hello"
$ ligo run test display_format_json.mligo --display-format json
[                                           
  [ "test_x", [ "constant", [ "int", "65" ] ] ],
  [ "test_y", [ "constant", [ "string", "hello" ] ] ]
]

Checklist:

  • Changes follow the existing coding style (use dune @fmt to check).
  • Tests for the changes have been added (for bug fixes / feature).
  • Documentation has been updated.
  • Changelog description has been added (if appropriate).
  • Start titles under ## Changelog section with #### (if appropriate).
  • There is no image or uploaded file in changelog
  • Examples in changed behaviour have been added to the changelog (for breaking change / feature).
Edited by E. Rivas

Merge request reports

Loading