diff --git a/cmd/csaf_uploader/main.go b/cmd/csaf_uploader/main.go index dcee311..f44fd36 100644 --- a/cmd/csaf_uploader/main.go +++ b/cmd/csaf_uploader/main.go @@ -353,12 +353,12 @@ func check(err error) { } } -func main() { +func realMain(args []string) { var opts options parser := flags.NewParser(&opts, flags.Default) - args, err := parser.Parse() + args, err := parser.ParseArgs(args) check(err) if opts.Version { @@ -407,3 +407,7 @@ func main() { check(p.process(arg)) } } + +func main() { + realMain(os.Args[1:]) +} diff --git a/cmd/csaf_uploader/main_test.go b/cmd/csaf_uploader/main_test.go new file mode 100644 index 0000000..29dc488 --- /dev/null +++ b/cmd/csaf_uploader/main_test.go @@ -0,0 +1,24 @@ +package main + +import ( + "os" + "testing" +) + +// call realMain() with Args that skip over params used by "go test" +// allow calls like +// go test -c -vet=off -covermode=atomic -o csaf_uploader.debug +// ./csaf_uploader.debug -test.coverprofile=/tmp/csaf_uploader-itest-${EPOCHREALTIME}.cov -- --insecure .... +func TestMain(t *testing.T) { + var endOfTestParams int + for i, a := range os.Args[1:] { + if a == "--" { + endOfTestParams = i + 1 + } + } + + if endOfTestParams == 0 { + t.Skip("skipping integration test, no `--` parameter found") + } + realMain(os.Args[endOfTestParams+1:]) +}