pre-commit-golang icon indicating copy to clipboard operation
pre-commit-golang copied to clipboard

Teach run-go-unit-tests.sh about options processing

Open larsks opened this issue 4 years ago • 2 comments

This modifies run-go-unit-tests.sh to expose several "go test" command line options, including those related to code coverage. It is now possible to configure a hook like this:

- repo: git://github.com/dnephin/pre-commit-golang
  rev: master
  hooks:
    - id: go-unit-tests
      args:
        - -coverprofile
        - coverage.out

larsks avatar May 31 '21 19:05 larsks

Do you think we need to handle the rest of the args explicitly? Or could we do more of a passthrough of the rest of $@

I thought about that, but I can't think of a sane way to do it: arguments may take no arguments (-cover) or they may take a single argument (-coverprofile coverage.out), and any arguments passed in are of course followed by the list of filenames provided by pre-commit.

There's no way to write a general passthrough that knows which options take arguments and which don't -- other by enumerating them all individually.

larsks avatar Jun 01 '21 02:06 larsks

Any updates regarding this? I would like to see this merged so we can modify our timeout option as well. Is it ready to be merged or is additional work needed?

sgielen avatar Feb 03 '22 13:02 sgielen