Skip to content

Commit a1e89a4

Browse files
committed
fix Test_RuntimeWithSkip, some renaming and rearranging
1 parent 658228e commit a1e89a4

5 files changed

Lines changed: 17 additions & 14 deletions

File tree

pkg/output/cli.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func (w *OutputWriter) GetEventHandler() *runtime.EventHandler {
5757

5858
handler.TestSkipped = func(testResult runtime.TestResult) {
5959
tr := convertTestResult(testResult)
60-
w.printSkipped(tr)
60+
w.printSkip(tr)
6161
}
6262

6363
return &handler
@@ -90,7 +90,7 @@ func (w *OutputWriter) printResult(r TestResult) {
9090
w.fprintf(w.template.testResult(r))
9191
}
9292

93-
func (w *OutputWriter) printSkipped(r TestResult) {
93+
func (w *OutputWriter) printSkip(r TestResult) {
9494
w.fprintf(fmt.Sprintf("- [skipped] %s: was skipped", r.Title))
9595
}
9696

pkg/runtime/runner.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,16 @@ type Runner struct {
1212
Nodes []Node
1313
}
1414

15-
// Execute the runner
16-
func (r *Runner) Execute(tests []TestCase) <-chan TestResult {
15+
// Run the runner
16+
func (r *Runner) Run(tests []TestCase) <-chan TestResult {
1717
in := make(chan TestCase)
1818
out := make(chan TestResult)
1919

2020
go func(tests []TestCase) {
2121
defer close(in)
22-
2322
for _, t := range tests {
24-
if t.Disable {
25-
tr := TestResult{TestCase: t, Skipped: true}
26-
out <- tr
27-
continue
28-
}
2923
in <- t
3024
}
31-
3225
}(tests)
3326

3427
var wg sync.WaitGroup
@@ -38,6 +31,13 @@ func (r *Runner) Execute(tests []TestCase) <-chan TestResult {
3831
defer wg.Done()
3932

4033
for t := range tests {
34+
// If test is disabled skip it
35+
if t.Disable {
36+
tr := TestResult{TestCase: t, Skipped: true}
37+
out <- tr
38+
continue
39+
}
40+
4141
// If no node was set use local mode as default
4242
if len(t.Nodes) == 0 {
4343
t.Nodes = []string{"local"}
@@ -60,7 +60,6 @@ func (r *Runner) Execute(tests []TestCase) <-chan TestResult {
6060
}
6161
out <- result
6262
}
63-
6463
}
6564
}(in)
6665

pkg/runtime/runner_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func Test_RunnerExexcute(t *testing.T) {
1212
Nodes: getExampleNodes(),
1313
}
1414

15-
got := r.Execute(s)
15+
got := r.Run(s)
1616

1717
assert.IsType(t, make(<-chan TestResult), got)
1818

pkg/runtime/runtime.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,11 @@ type Result struct {
131131
// Start starts the given test suite and executes all tests
132132
func (r *Runtime) Start(tests []TestCase) Result {
133133
result := Result{}
134-
testCh := r.Runner.Execute(tests)
134+
testCh := r.Runner.Run(tests)
135135
start := time.Now()
136136
for tr := range testCh {
137137
if tr.Skipped {
138+
result.Skipped++
138139
r.EventHandler.TestSkipped(tr)
139140
result.TestResults = append(result.TestResults, tr)
140141
continue

pkg/runtime/runtime_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ func getRuntime() Runtime {
8484
TestFinished: func(tr TestResult) {
8585
fmt.Println("I do nothing")
8686
},
87+
TestSkipped: func(tr TestResult) {
88+
fmt.Printf("%s was skipped", tr.TestCase.Title)
89+
},
8790
}
8891

8992
runtime := NewRuntime(&eh, Node{Name: "test"}, Node{Name: "test2"})

0 commit comments

Comments
 (0)