Skip to content

Commit

Permalink
print all nodes when skipping
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanhitt committed Aug 7, 2020
1 parent 5437b45 commit 352ac31
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 13 deletions.
4 changes: 3 additions & 1 deletion commander_linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion commander_unix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion commander_windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions integration/linux/nodes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 7 additions & 2 deletions pkg/output/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/output/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 5 additions & 6 deletions pkg/runtime/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 352ac31

Please sign in to comment.