Add sudo tag

ignore tests that require sudo during development time to speed up workflow
This commit is contained in:
Peter 2021-05-24 13:17:00 +02:00
parent 886ee47a52
commit 1fb42ae68c
Signed by: prskr
GPG key ID: C1DB5D2E8DB512F9
5 changed files with 28 additions and 11 deletions

View file

@ -32,7 +32,7 @@ tasks:
- go.mod
- go.sum
cmds:
- go mod download
- go mod tidy
dep-graph:
desc: generate dependency graph
@ -94,6 +94,19 @@ tasks:
- protoc
test:
desc: run short running unit tests that do not need sudo
sources:
- "**/*.go"
deps:
- deps
- generate
cmds:
- mkdir -p {{ .OUT_DIR }}
- go test -coverprofile={{ .OUT_DIR }}/cov-raw.out -covermode count -v ./...
- grep -v "generated" {{ .OUT_DIR }}/cov-raw.out > {{ .OUT_DIR }}/cov.out
- go tool cover -func={{ .OUT_DIR }}/cov.out
test-all:
desc: run all unit tests
sources:
- "**/*.go"
@ -102,7 +115,7 @@ tasks:
- generate
cmds:
- mkdir -p {{ .OUT_DIR }}
- cmd: go test -coverprofile={{ .OUT_DIR }}/cov-raw.out -covermode count -v ./... 2>&1 | tee {{ .OUT_DIR }}/test_output
- cmd: go test --tags sudo -coverprofile={{ .OUT_DIR }}/cov-raw.out -covermode count -v ./... 2>&1 | tee {{ .OUT_DIR }}/test_output
ignore_error: true
- cat {{ .OUT_DIR }}/test_output | go-junit-report -set-exit-code > {{ .OUT_DIR }}/report.xml
- grep -v "generated" {{ .OUT_DIR }}/cov-raw.out > {{ .OUT_DIR }}/cov.out
@ -123,21 +136,22 @@ tasks:
cli-cover-report:
desc: generate a coverage report on the CLI
deps:
- test
- test-all
cmds:
- go tool cover -func={{ .OUT_DIR }}/cov.out
html-cover-report:
desc: generate a coverage report as HTML page
deps:
- test
- test-all
cmds:
- go tool cover -html={{ .OUT_DIR }}/cov.out -o {{ .OUT_DIR }}/coverage.html
build-inetmock:
desc: build the INetMock server part
deps:
- test
- deps
- generate
cmds:
- mkdir -p {{ .OUT_DIR }}
- go build -ldflags='-w -s' -o {{ .OUT_DIR }}/inetmock {{ .INETMOCK_PKG }}
@ -150,7 +164,8 @@ tasks:
build-imctl:
desc: build the imctl INetMock client CLI
deps:
- test
- deps
- generate
cmds:
- mkdir -p {{ .OUT_DIR }}
- go build -ldflags='-w -s' -o {{ .OUT_DIR }}/imctl {{ .IMCTL_PKG }}

View file

@ -89,18 +89,16 @@ func NewApp(spec Spec) App {
spec.Defaults = make(map[string]interface{})
}
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
a := &app{
rootCmd: &cobra.Command{
Use: spec.Name,
Short: spec.Short,
SilenceUsage: true,
},
ctx: ctx,
cancel: cancel,
}
a.ctx, a.cancel = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
lateInitTasks := []func(cmd *cobra.Command, args []string) (err error){
func(*cobra.Command, []string) (err error) {
return spec.readConfig(a.rootCmd)

View file

@ -1,3 +1,5 @@
//+build sudo
package pcap_test
import (

View file

@ -1,4 +1,4 @@
// +build linux
// +build linux,sudo
package pcap_test

View file

@ -1,3 +1,5 @@
//+build sudo
package rpc_test
import (