From a8c59d9fc6bac37ecbe59dd5666504eda4596f2e Mon Sep 17 00:00:00 2001 From: Nick Ethier Date: Tue, 31 Jul 2018 15:21:47 -0400 Subject: [PATCH] e2e/cli: add -run option to mimic go test --- e2e/cli/command/meta.go | 2 +- e2e/cli/command/run.go | 18 +++++++++++++++++- e2e/cli/command/test_decoder.go | 1 - 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/e2e/cli/command/meta.go b/e2e/cli/command/meta.go index 3ad4b8ffe..2d9c66292 100644 --- a/e2e/cli/command/meta.go +++ b/e2e/cli/command/meta.go @@ -25,7 +25,7 @@ func NewMeta(ui cli.Ui, logger hclog.Logger) Meta { func (m *Meta) FlagSet(n string) *flag.FlagSet { f := flag.NewFlagSet(n, flag.ContinueOnError) - f.BoolVar(&m.verbose, "v", false, "Toggle verbose output") + f.BoolVar(&m.verbose, "verbose", false, "Toggle verbose output") return f } diff --git a/e2e/cli/command/run.go b/e2e/cli/command/run.go index e7bdec7d4..b0d55e13a 100644 --- a/e2e/cli/command/run.go +++ b/e2e/cli/command/run.go @@ -45,6 +45,12 @@ General Options: Run Options: + -run regex + Sets a regular expression for what tests to run. Uses '/' as a separator + to allow hierarchy between Suite/Case/Test. + + Example '-run MyTestSuite' would only run tests under the MyTestSuite suite. + -slow If set, will only run test suites marked as slow. ` @@ -82,6 +88,7 @@ func (c *Run) Run(args []string) int { if len(args) == 0 { c.logger.Info("no environments specified, running test suite locally") report, err := c.runTest(&runOpts{ + run: run, slow: slow, verbose: c.verbose, }) @@ -140,6 +147,7 @@ func (c *Run) Run(args []string) int { provider: env.provider, env: env.name, slow: slow, + run: run, verbose: c.verbose, nomadAddr: results.nomadAddr, consulAddr: results.consulAddr, @@ -212,6 +220,7 @@ type runOpts struct { vaultAddr string provider string env string + run string local bool slow bool verbose bool @@ -223,10 +232,17 @@ func (opts *runOpts) goArgs() []string { a := []string{ "test", "-json", + } + + if opts.run != "" { + a = append(a, "-run=TestE2E/"+opts.run) + } + + a = append(a, []string{ "github.com/hashicorp/nomad/e2e", "-env=" + opts.env, "-env.provider=" + opts.provider, - } + }...) if opts.slow { a = append(a, "-slow") diff --git a/e2e/cli/command/test_decoder.go b/e2e/cli/command/test_decoder.go index 776b7778f..c3b178f07 100644 --- a/e2e/cli/command/test_decoder.go +++ b/e2e/cli/command/test_decoder.go @@ -40,7 +40,6 @@ type TestEvent struct { Elapsed float64 // seconds Output string - eventType string suiteName string caseName string testName string