Home > Blockchain >  how to run go-unit-tests pre-commit hook to run with option -p
how to run go-unit-tests pre-commit hook to run with option -p

Time:04-26

I was looking into this golang-precommit hooks repository: https://github.com/dnephin/pre-commit-golang

go-unit-tests hook runs the command go test -tags=unit -timeout 30s -short -v but what if I want go hook to run command with -p=1 option. Is there any way to achieve this?

Here's the content from my .pre-commit-config.yaml file

repos:
  - repo: https://github.com/dnephin/pre-commit-golang
    rev: v0.4.0
    hooks:
      - id: go-fmt
      - id: go-unit-tests

CodePudding user response:

there isn't given that hook directly, but that repo isn't really adding too terribly much, you could replicate what you want via a repo: local hook (untested):

-   repo: local
    hooks:
    -   id: go-unit-tests
        name: go unit tests
        entry: go test -p=1 ./...
        pass_filenames: false
        types: [go]
        language: system

disclaimer: I wrote pre-commit

  • Related