COVERAGE_FILE should be a command-line parameter instead. · Issue #624 · nedbat/coveragepy (original) (raw)

Originally reported by Anonymous


Hi, Ned. First of all, thank you for this wonderful tool.

In a UNIX environment, I would expect a tool to allow me to specify the output path from the command line, instead of setting it through an environment variable. Much so that I think coverage.py is the first tool I have seen with such behavior. In light of this, I am proposing to remove the COVERAGE_FILE environment variable, and add an option to run subcommand that exactly serves in place of the mentioned environment variable.

Comparing the existing API,

Regular use

COVERAGE_FILE=my_file coverage run my_program.py

alternatively

export COVERAGE_FILE=my_file coverage run my_program.py

Write to stdout of the process, to enable piping

COVERAGE_FILE=/dev/stdout my_program.py

with my proposal,

Regular use

coverage run -o my_file my_program.py

Write to stdout of the process, to enable piping

coverage run -o /dev/stdout my_program.py

I believe the command line argument option is more elegant, and something a programmer would expect. I personally had to search documents on how to specify the output file.

If you think this is a good idea, I am willing to do the work on the codebase to implement this feature.