Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add additional 'runTestArgs' for go test command #626

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion goconvey.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func flags() {
flag.StringVar(&excludedDirs, "excludedDirs", "vendor,node_modules", "A comma separated list of directories that will be excluded from being watched.")
flag.StringVar(&workDir, "workDir", "", "set goconvey working directory (default current directory).")
flag.BoolVar(&autoLaunchBrowser, "launchBrowser", true, "toggle auto launching of browser.")
flag.StringVar(&runTestArgs, "runTestArgs", "", "additional arguments for exec 'go test' command.")

log.SetOutput(os.Stdout)
log.SetFlags(log.LstdFlags | log.Lshortfile)
Expand All @@ -62,7 +63,7 @@ func main() {

working := getWorkDir()
cover = coverageEnabled(cover, reports)
shell := system.NewShell(gobin, reports, cover, timeout)
shell := system.NewShell(gobin, reports, cover, timeout, runTestArgs)

watcherInput := make(chan messaging.WatcherCommand)
watcherOutput := make(chan messaging.Folders)
Expand Down Expand Up @@ -300,6 +301,7 @@ var (
watchedSuffixes string
excludedDirs string
autoLaunchBrowser bool
runTestArgs string

static string
reports string
Expand Down
14 changes: 13 additions & 1 deletion web/server/system/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ type Shell struct {
gobin string
reportsPath string
defaultTimeout string
runTestArgs string
}

func NewShell(gobin, reportsPath string, coverage bool, defaultTimeout string) *Shell {
func NewShell(gobin, reportsPath string, coverage bool, defaultTimeout string, runTestArgs string) *Shell {
return &Shell{
coverage: coverage,
gobin: gobin,
reportsPath: reportsPath,
defaultTimeout: defaultTimeout,
runTestArgs: runTestArgs,
}
}

Expand All @@ -35,6 +37,16 @@ func (self *Shell) GoTest(directory, packageName string, tags, arguments []strin
reportHTML := reportPath + ".html"
tagsArg := "-tags=" + strings.Join(tags, ",")

// add additional go test arguments
if self.runTestArgs != "" {
if arguments == nil {
arguments = make([]string, 1)
arguments[0] = self.runTestArgs
} else {
arguments = append(arguments, self.runTestArgs)
}
}

goconvey := findGoConvey(directory, self.gobin, packageName, tagsArg).Execute()
compilation := compile(directory, self.gobin, tagsArg).Execute()
withCoverage := runWithCoverage(compilation, goconvey, self.coverage, reportData, directory, self.gobin, self.defaultTimeout, tagsArg, arguments).Execute()
Expand Down
2 changes: 1 addition & 1 deletion web/server/system/shell_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestShellIntegration(t *testing.T) {
directory := filepath.Join(filepath.Dir(filename), "..", "watch", "integration_testing", "sub")
packageName := "github.com/smartystreets/goconvey/web/server/watch/integration_testing/sub"

shell := NewShell("go", "", true, "5s")
shell := NewShell("go", "", true, "5s", "")
output, err := shell.GoTest(directory, packageName, []string{}, []string{"-short"})

if !strings.Contains(output, "PASS\n") || !strings.Contains(output, "ok") {
Expand Down