-
Notifications
You must be signed in to change notification settings - Fork 0
/
params.go
58 lines (53 loc) · 2.31 KB
/
params.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"flag"
"os"
"github.com/launchdarkly/sdk-test-harness/v2/framework/helpers"
"github.com/launchdarkly/sdk-test-harness/v2/framework/ldtest"
)
type commandParams struct {
serviceURL string
port int
host string
filters ldtest.RegexFilters
stopServiceAtEnd bool
debug bool
debugAll bool
enablePersistenceTests bool
jUnitFile string
recordFailures string
skipFile string
queryTimeoutSeconds int
}
func (c *commandParams) Read(args []string) bool {
fs := flag.NewFlagSet("", flag.ExitOnError)
fs.StringVar(&c.serviceURL, "url", "", "test service URL")
fs.StringVar(&c.host, "host", "localhost", "external hostname of the test harness")
fs.IntVar(&c.port, "port", defaultPort, "http port that the test harness will listen on"+
" (if TLS capability enabled in an SDK, then port+1 will be used for HTTPS)")
fs.Var(&c.filters.MustMatch, "run", "regex pattern(s) to select tests to run")
fs.Var(&c.filters.MustNotMatch, "skip", "regex pattern(s) to select tests not to run")
fs.BoolVar(&c.stopServiceAtEnd, "stop-service-at-end", false, "tell test service to exit after the test run")
fs.BoolVar(&c.debug, "debug", false, "enable debug logging for failed tests")
fs.BoolVar(&c.debugAll, "debug-all", false, "enable debug logging for all tests")
fs.BoolVar(&c.enablePersistenceTests, "enable-persistence-tests", false,
"enable tests that require external persistence support")
fs.StringVar(&c.jUnitFile, "junit", "", "write JUnit XML output to the specified path")
fs.StringVar(&c.recordFailures, "record-failures", "", "record failed test IDs to the given file.\n"+
"recorded tests can be skipped by the next run of the harness via -skip-from")
fs.StringVar(&c.skipFile, "skip-from", "", "skips any test IDs recorded in the specified file.\n"+
"may be used in conjunction with -record-failures")
fs.IntVar(&c.queryTimeoutSeconds, "status-timeout", 10, "how many seconds to attempt to query to "+
"the test service before failing")
if err := fs.Parse(args[1:]); err != nil {
helpers.MustFprintln(os.Stderr, err)
fs.Usage()
return false
}
if c.serviceURL == "" {
helpers.MustFprintln(os.Stderr, "-url is required")
fs.Usage()
return false
}
return true
}