onflow / onflow/flow-cli

`flow test --output=json` does not strictly emit JSON data

Open
#1,324 1 comment 0 reactions 1 assignee View on GitHub

@chasefleming is already working on this.

Since Jan 2, 2024.

Feedback
Dominant language
Go
Stars
209
Forks
87
Avg merge
1d 17h
Merged PRs (30d)
3

Description

Instructions

Please fill out the template below to the best of your ability and include a label indicating which tool/service you were working with when you encountered the problem.

Problem

Logs outputted by flow test --output=json are not captured in any way and are emitted to stdio as plaintext. This is problematic because applications which rely on this functionality will fail to parse the output from the Flow CLI.

Steps to Reproduce

Run the command with a test file that emits a log.

Acceptance Criteria

The CLI strictly emits JSON output to stdio. There are multiple solutions for this:

  • Suppress logs entirely (probably the easy quick-fix that can be revisited later)
  • Extend the output of flow test to include logs. It's likely this could introduce some breaking changes to the schema of the CLI output and break external consumers, however, this is a relatively new feature so this is probably acceptable in order to migrate to a more robust output format in the long-run.
  • Output logs directly to stdio in JSON format and stream multiple messages in realtime (this is similar to flow emulator --log-format json, however requires all consumers be equipped to handle multiple JSON objects in the output). It does, however, offer the benefit of instantly serving in-progress information without waiting for a terminal state.
Context

Currently cadence log() calls break the VSCode Test Runner.

This relies on changes to the Cadence Test Framework (see https://github.com/onflow/cadence-tools/issues/265 https://github.com/onflow/cadence-tools/pull/267)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.