MCPcopy Create free account
hub / github.com/commander-cli/commander / Run

Method Run

pkg/runtime/runner.go:16–70  ·  view source on GitHub ↗

Run the runner

(tests []TestCase)

Source from the content-addressed store, hash-verified

14
15// Run the runner
16func (r *Runner) Run(tests []TestCase) <-chan TestResult {
17 in := make(chan TestCase)
18 out := make(chan TestResult)
19
20 go func(tests []TestCase) {
21 defer close(in)
22 for _, t := range tests {
23 in <- t
24 }
25 }(tests)
26
27 var wg sync.WaitGroup
28 wg.Add(1)
29
30 go func(tests chan TestCase) {
31 defer wg.Done()
32
33 for t := range tests {
34 // If no node was set use local mode as default
35 if len(t.Nodes) == 0 {
36 t.Nodes = []string{"local"}
37 }
38
39 for _, n := range t.Nodes {
40 result := TestResult{}
41 for i := 1; i <= t.Command.GetRetries(); i++ {
42
43 if t.Skip {
44 result = TestResult{TestCase: t, Skipped: true, Node: n}
45 break
46 }
47
48 e := r.getExecutor(n)
49 result = e.Execute(t)
50 result.Node = n
51 result.Tries = i
52
53 if result.ValidationResult.Success {
54 break
55 }
56
57 executeRetryInterval(t)
58 }
59 out <- result
60 }
61 }
62 }(in)
63
64 go func(results chan TestResult) {
65 wg.Wait()
66 close(results)
67 }(out)
68
69 return out
70}
71
72// getExecutor gets the node by the name it matches within the runner config
73func (r *Runner) getExecutor(node string) Executor {

Callers 4

Test_RunnerExexcuteFunction · 0.95
ExecuteMethod · 0.80
StartMethod · 0.80
runFunction · 0.80

Calls 4

getExecutorMethod · 0.95
executeRetryIntervalFunction · 0.85
GetRetriesMethod · 0.80
ExecuteMethod · 0.65

Tested by 1

Test_RunnerExexcuteFunction · 0.76