CleanCut / green

Green is a clean, colorful, fast python test runner.
MIT License
786 stars 74 forks source link

How to pass options to coverage module? #168

Closed cytrinox closed 5 years ago

cytrinox commented 6 years ago

The coverage module provides important command line options like -a:

By default, each run of your program starts with an empty data set. If you need to run your program multiple times to get complete data (for example, because you need to supply disjoint options), you can accumulate data across runs with the -a flag on the run command.

For full coverage, I need to run green/coverage multiple times with different environment options. Is it possible to accumulate multiple runs / pass the -a option via green?

CleanCut commented 6 years ago

It is not possible with the current version of green (2.10.0), though it sounds like a straightforward and useful feature to add.

althonos commented 6 years ago

I haven't tried, but you could probably use a configuration file to configure the coverage module !

Ogaday commented 6 years ago

+1 for passing options to the coverage module. Happy to look into it, but I haven't yet looked into the last thing I wanted to look at for this library!

CleanCut commented 6 years ago

The tricky thing is that green is using coverage as a library and calling things internally, so coverage isn't doing any option parsing for us. On top of that, coverage itself uses subcommands, and each subcommand has different options.

If the part of coverage we call reaches out and looks at config files, then that's an excellent option!

If not, then perhaps we could devise some syntax for giving green the desired options for coverage subcommands and then green could try to hook into coverage's parsing code.

jrabbit commented 5 years ago

https://coverage.readthedocs.io/en/v4.5.x/api_coverage.html#coverage.Coverage.__init__ specifically the config argument if this was exposed in options that'd be great. Having to specify in multiple locations coverage options seems odd.

CleanCut commented 5 years ago

@jrabbit That's a good suggestion. Having the ability to direct coverage to a config file could cover all future (and existing) coverage options, and Green wouldn't have to maintain some custom parsing of said options.

CleanCut commented 5 years ago

Included in 2.16.0 (just released) as -g/--cov-config-file