mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-29 17:47:14 +02:00
Introduced the `--json-output
option to the
pio test` command // Resolve #4740
This commit is contained in:
@ -20,6 +20,7 @@ test-driven methodologies, and modern toolchains for unrivaled success.
|
||||
6.1.14 (2024-??-??)
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* Introduced the ``--json-output`` option to the `pio test <https://docs.platformio.org/en/latest/core/userguide/cmd_test.html>`__ command, enabling users to generate test results in the JSON format
|
||||
* Broadened version support for the ``pyelftools`` dependency, enabling compatibility with lower versions and facilitating integration with a wider range of third-party tools (`issue #4834 <https://github.com/platformio/platformio-core/issues/4834>`_)
|
||||
* Addressed an issue where passing a relative path (``--project-dir``) to the `pio project init <https://docs.platformio.org/en/latest/core/userguide/project/cmd_init.html>`__ command resulted in an error (`issue #4847 <https://github.com/platformio/platformio-core/issues/4847>`_)
|
||||
* Resolved an issue related to the relative package path in the `pio pkg publish <https://docs.platformio.org/en/latest/core/userguide/pkg/cmd_publish.html>`__ command
|
||||
|
2
docs
2
docs
Submodule docs updated: 37c10d2f72...5ada9ce233
@ -14,6 +14,7 @@
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
import click
|
||||
|
||||
@ -79,6 +80,7 @@ from platformio.test.runners.factory import TestRunnerFactory
|
||||
help="A program argument (multiple are allowed)",
|
||||
)
|
||||
@click.option("--list-tests", is_flag=True)
|
||||
@click.option("--json-output", is_flag=True)
|
||||
@click.option("--json-output-path", type=click.Path())
|
||||
@click.option("--junit-output-path", type=click.Path())
|
||||
@click.option(
|
||||
@ -105,6 +107,7 @@ def cli( # pylint: disable=too-many-arguments,too-many-locals,redefined-builtin
|
||||
monitor_dtr,
|
||||
program_args,
|
||||
list_tests,
|
||||
json_output,
|
||||
json_output_path,
|
||||
junit_output_path,
|
||||
verbose,
|
||||
@ -156,6 +159,7 @@ def cli( # pylint: disable=too-many-arguments,too-many-locals,redefined-builtin
|
||||
stdout_report.generate(verbose=verbose or list_tests)
|
||||
|
||||
for output_format, output_path in [
|
||||
("json", subprocess.STDOUT if json_output else None),
|
||||
("json", json_output_path),
|
||||
("junit", junit_output_path),
|
||||
]:
|
||||
|
@ -15,6 +15,7 @@
|
||||
import datetime
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
import click
|
||||
|
||||
@ -24,6 +25,9 @@ from platformio.test.result import TestStatus
|
||||
|
||||
class JsonTestReport(TestReportBase):
|
||||
def generate(self, output_path, verbose=False):
|
||||
if output_path == subprocess.STDOUT:
|
||||
return click.echo("\n\n" + json.dumps(self.to_json()))
|
||||
|
||||
if os.path.isdir(output_path):
|
||||
output_path = os.path.join(
|
||||
output_path,
|
||||
@ -40,6 +44,8 @@ class JsonTestReport(TestReportBase):
|
||||
if verbose:
|
||||
click.secho(f"Saved JSON report to the {output_path}", fg="green")
|
||||
|
||||
return True
|
||||
|
||||
def to_json(self):
|
||||
result = dict(
|
||||
version="1.0",
|
||||
|
Reference in New Issue
Block a user