dnephin / pre-commit-golang

Golang hooks for pre-commit
MIT License
656 stars 222 forks source link

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

Closed larsks closed 1 year ago

larsks commented 3 years ago

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 commented 3 years ago

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.

sgielen commented 2 years ago

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?