From 352ac31e7d1a13a2834ea52e061ba31676bed5eb Mon Sep 17 00:00:00 2001 From: Dylan Date: Thu, 6 Aug 2020 20:42:23 -0400 Subject: [PATCH] print all nodes when skipping --- commander_linux.yaml | 4 +++- commander_unix.yaml | 2 +- commander_windows.yaml | 2 +- integration/linux/nodes.yaml | 5 +++++ pkg/output/cli.go | 9 +++++++-- pkg/output/cli_test.go | 2 +- pkg/runtime/runner.go | 11 +++++------ pkg/runtime/runtime.go | 2 +- 8 files changed, 24 insertions(+), 13 deletions(-) diff --git a/commander_linux.yaml b/commander_linux.yaml index 9c9e0401..49990ed6 100644 --- a/commander_linux.yaml +++ b/commander_linux.yaml @@ -6,7 +6,9 @@ tests: - ✓ [ssh-host] it should test ssh host - ✓ [ssh-host] it should set env variable - ✓ [ssh-host-default] it should be executed on ssh-host-default - - "- [] it should skip, was skipped" + - "- [ssh-host-default] it should skip, was skipped" + - "- [ssh-host] it should skip, was skipped" + - "- [local] it should skip, was skipped" - ✓ [ssh-host] it should test multiple hosts - ✓ [ssh-host-default] it should test multiple hosts - ✓ [local] it should test multiple hosts diff --git a/commander_unix.yaml b/commander_unix.yaml index d7245627..facbeae1 100644 --- a/commander_unix.yaml +++ b/commander_unix.yaml @@ -15,7 +15,7 @@ tests: stdout: contains: - ✓ [local] it should exit with error code - - "- [] it should skip, was skipped" + - "- [local] it should skip, was skipped" line-count: 17 exit-code: 0 diff --git a/commander_windows.yaml b/commander_windows.yaml index 0dec50f7..8a0f7571 100644 --- a/commander_windows.yaml +++ b/commander_windows.yaml @@ -14,7 +14,7 @@ tests: command: commander.exe test ./integration/windows/commander_test.yaml stdout: contains: - - "- [] it should skip, was skipped" + - "- [local] it should skip, was skipped" - test exit-code: 0 diff --git a/integration/linux/nodes.yaml b/integration/linux/nodes.yaml index 2c904a4d..e0373cb2 100644 --- a/integration/linux/nodes.yaml +++ b/integration/linux/nodes.yaml @@ -44,6 +44,11 @@ tests: it should skip: command: whoami stdout: root + config: + nodes: + - ssh-host-default + - ssh-host + - local skip: true it should test multiple hosts: diff --git a/pkg/output/cli.go b/pkg/output/cli.go index ac1c921a..36add127 100644 --- a/pkg/output/cli.go +++ b/pkg/output/cli.go @@ -91,7 +91,7 @@ func (w *OutputWriter) printResult(r TestResult) { } func (w *OutputWriter) printSkip(r TestResult) { - w.fprintf(fmt.Sprintf("- [] %s, was skipped", r.Title)) + w.fprintf(fmt.Sprintf("- [%s] %s, was skipped", r.Node, r.Title)) } func (w *OutputWriter) printFailures(results []runtime.TestResult) { @@ -101,12 +101,17 @@ func (w *OutputWriter) printFailures(results []runtime.TestResult) { for _, tr := range results { r := convertTestResult(tr) + if r.Skipped { + continue + } + if r.Error != nil { w.fprintf(w.au.Bold(w.au.Red(w.template.errors(r)))) w.fprintf(r.Error.Error()) continue } - if !r.Success && !r.Skipped { + + if !r.Success { w.fprintf(w.au.Bold(w.au.Red(w.template.failures(r)))) w.fprintf(r.Diff) } diff --git a/pkg/output/cli_test.go b/pkg/output/cli_test.go index 3e02b698..239b2a97 100644 --- a/pkg/output/cli_test.go +++ b/pkg/output/cli_test.go @@ -51,7 +51,7 @@ func Test_EventHandlerTestSkipped(t *testing.T) { } } output := buf.String() - assert.Contains(t, output, "- [] Skipped test, was skipped") + assert.Contains(t, output, "- [192.168.0.1] Skipped test, was skipped") } func Test_PrintSummary(t *testing.T) { diff --git a/pkg/runtime/runner.go b/pkg/runtime/runner.go index 761536f5..c1edd464 100644 --- a/pkg/runtime/runner.go +++ b/pkg/runtime/runner.go @@ -31,12 +31,6 @@ func (r *Runner) Run(tests []TestCase) <-chan TestResult { defer wg.Done() for t := range tests { - if t.Skip { - tr := TestResult{TestCase: t, Skipped: true} - out <- tr - continue - } - // If no node was set use local mode as default if len(t.Nodes) == 0 { t.Nodes = []string{"local"} @@ -46,6 +40,11 @@ func (r *Runner) Run(tests []TestCase) <-chan TestResult { result := TestResult{} for i := 1; i <= t.Command.GetRetries(); i++ { + if t.Skip { + result = TestResult{TestCase: t, Skipped: true, Node: n} + break + } + e := r.getExecutor(n) result = e.Execute(t) result.Node = n diff --git a/pkg/runtime/runtime.go b/pkg/runtime/runtime.go index afcd9ff5..0f0cce10 100644 --- a/pkg/runtime/runtime.go +++ b/pkg/runtime/runtime.go @@ -138,7 +138,7 @@ func (r *Runtime) Start(tests []TestCase) Result { if tr.Skipped { result.Skipped++ - log.Println("title: '"+tr.TestCase.Title+"'", " Was skipped") + log.Println("title: '"+tr.TestCase.Title+"'", " was skipped") log.Println("title: '"+tr.TestCase.Title+"'", " Command: ", tr.TestCase.Command.Cmd) log.Println("title: '"+tr.TestCase.Title+"'", " Directory: ", tr.TestCase.Command.Dir) log.Println("title: '"+tr.TestCase.Title+"'", " Env: ", tr.TestCase.Command.Env)