very_good_cli icon indicating copy to clipboard operation
very_good_cli copied to clipboard

Support for --machine in very_good test

Open davidmartos96 opened this issue 3 years ago • 15 comments

Description Support for the --machine option from flutter test. It provides a way to output a summary of the tests that were executed. How many failed, how long they took, etc... This output is useful to then convert it to popular formats such as an XML JUnit report, which can be interpreted by different other tools, like CI/CD platforms or IDEs. One tool to convert this output is https://pub.dev/packages/junitreport

On a dart test, the report output is obtained with --reporter json, not with --machine

davidmartos96 avatar Mar 21 '22 22:03 davidmartos96

Are there any reasons why very_good does not support passing arguments with the -- operator, like very_good test -- --machine? npm uses the -- operator as well (https://github.com/npm/npm/pull/5518).

cc: @marcossevilla

nilsreichardt avatar Apr 07 '22 14:04 nilsreichardt

Are there any reasons why very_good does not support passing arguments with the -- operator, like very_good test -- --machine? npm uses the -- operator as well (npm/npm#5518).

cc: @marcossevilla

The goal is not to expose an API that mirrors the underlying flutter/dart tool APIs. We wanted the CLI to serve as an abstraction above existing tooling so we didn't want to tightly couple them by proxying commands/options directly. Also, the CLI is using package:args which has a standard way of defining CLI flags and options. If we accepted -- and proxied them then they wouldn't be properly documented in the CLI usage (via --help).

Hope that helps 👍

felangel avatar Apr 07 '22 14:04 felangel

Ah, thanks for the detailed answer!

nilsreichardt avatar Apr 07 '22 15:04 nilsreichardt

Isn't the requested feature valid? I agree that mirroring with -- would not be ideal, but maybe some equivalent option for the test command would help for this use case?

davidmartos96 avatar Apr 07 '22 16:04 davidmartos96

Yup reopening this to track the lack of support for --machine

felangel avatar Apr 07 '22 16:04 felangel

Hi @felangel

any update for this feature. We need to generate also a json file for sonar or other tools. We tried to open a PR to add this option or an equivalent option. We discovered that --reporter=json is already added to flutter test command but the output is mapped to a list of objects.

thanks for your help

agacemi avatar Jul 05 '22 09:07 agacemi

Big +1! It would really help us out to have machine readable output.

justinschier avatar Jul 07 '22 23:07 justinschier

Hey all, just want to give an update:

This is in on our radar but we probably won't get to it for a couple of weeks. We're more than happy to review any PRs in the meantime if this is urgent/blocking for folks.

felangel avatar Jul 15 '22 18:07 felangel

Added a PR here: https://github.com/VeryGoodOpenSource/very_good_cli/pull/473 We require this for our CI pipelines, it's the only thing stopping us from migrating to very_good (it's cutting our test runs to 30% of their original run time!)

jackgllghr avatar Jul 28 '22 16:07 jackgllghr

It would be great to get this option.... I'm looking forward to it, it is mandatory for my project in order to use it in our pipelines

Thelm76 avatar Nov 02 '22 13:11 Thelm76

Any news on this feature by chance?

justinschier avatar Mar 23 '23 20:03 justinschier

This would be a really useful feature for our GitHub pipeline.

We're using very_good with optimization and it's a lot faster than the default tests. But unfortunately it's not possible to use an action like Test Reporter because of the missing json summary file.

DFelten avatar Jun 24 '23 07:06 DFelten

Hello! I think this is not an issue anymore since VGC test supports "vanilla" parameters using -- (added to documentation with #840 )

Just be careful not to use --machine or --report as they modify stdout used by the cli to know test statuses. You should use --file-report=<reportType>:<path> as so : very_good test --coverage -- --file-reporter json:test.txt

Thelm76 avatar Feb 27 '24 14:02 Thelm76

I tried the file-reporter parameter. The test therefore takes four times as long. Is that expected?

very_good test --optimization --coverage -> 00:29 +641 ~2: All tests passed!

very_good test --optimization --coverage -- --file-reporter json:test_reports/dd_test_report.json -> 01:53 +641 ~2: All tests passed!

DFelten avatar Apr 04 '24 16:04 DFelten