use $PATH for wrapping commands

Issue #329 duplicate
Buck Evan created an issue

To be more strictly a command wrapper, coveragepy should respect the $PATH environment variable (ala execp). By "strictly a command wrapper", I mean that coverage run myscript should behave similarly to simply running myscript. Think of the time command.

I often end up having to use -m with coverage run, which causes weird issues in the worst case (using runpy adds '' to the pythonpath :( ), and also doesn't use the console-script like the user would, which is desirable for functional tests.

If you'd add some notes as to which code and tests I'd need to touch to add this feature, I can work on a patch.

This would simplify my usage of coveragepy in all of our team's packages.

Comments (4)

  1. Buck Evan reporter

    A bit of pseudocode, to aid my memory and (maybe, possibly) clarify intent:

    if argument to `coverage run` is a file:
       continue per usual
       (old behavior) crash!
       (new behavior) if argument can be found via shutil.which:
          use the result, and continue per usual
          crash, as before

    This makes it much easier to run scripts installed to a virtualenv, and means I have a way to avoid the '' in sys.path pains that I have when I go the -m route.

  2. Log in to comment