summaryrefslogtreecommitdiff
path: root/runner.go
diff options
context:
space:
mode:
Diffstat (limited to 'runner.go')
-rw-r--r--runner.go59
1 files changed, 32 insertions, 27 deletions
diff --git a/runner.go b/runner.go
index 1470fbd..5b76cf1 100644
--- a/runner.go
+++ b/runner.go
@@ -1,8 +1,6 @@
package planr
-import (
- "fmt"
-)
+import "fmt"
type Runner struct {
adapters []Adapter
@@ -22,45 +20,52 @@ func (r Runner) adapterCfgs() []AdapterConfig {
return cgs
}
-// [Initialization] -> [Generation] -> [Finalization] ->
-// [Build] -> [Evaluation] -> [Clean]
+type TcTab map[string] []*TestCase
-func (r Runner) cycle(tcs []TestCase) []TestResult {
- results := make([]TestResult, 0)
+func (r Runner) buildTcLUT(tcs []TestCase) TcTab {
+ m := make(TcTab, 0)
- for _, adapter := range r.adapters {
- aname := adapter.Config().Name
-
- adapter.InitializeBuild()
-
- for _, tc := range tcs {
- if tc.ContainsAdapter(aname) {
- fmt.Printf("[R] Building %s\n", tc.Path)
- adapter.Build(tc)
- }
+ for i := range tcs {
+ tc := &tcs[i]
+ for nm := range tc.Config.adapters_ {
+ m[nm] = append(m[nm], tc)
}
+ }
- adapter.FinalizeBuild()
+ return m
+}
- adapter.Make()
+func (r Runner) Build(tcs []TestCase) {
+ tcTab := r.buildTcLUT(tcs)
- for _, tc := range tcs {
- if tc.ContainsAdapter(aname) {
- fmt.Printf("[R] Evaluating %s\n", tc.Path)
- results = append(results, adapter.Evaluate(tc))
- }
- }
+ for _, adapter := range r.adapters {
+ nm := adapter.Config().Name
+
+ fmt.Printf("[R] Building adapter \"%s\"\n", nm)
+ adapter.Build(tcTab[nm])
+ }
+}
- adapter.Cleanup()
+func (r Runner) Evaluate(tcs []TestCase) []TestResult {
+ tcTab := r.buildTcLUT(tcs)
+ results := make([]TestResult, 0)
+
+ for _, adapter := range r.adapters {
+ nm := adapter.Config().Name
+
+ fmt.Printf("[R] Evaluating adapter \"%s\"\n", nm)
+ adapter.Evaluate(tcTab[nm])
}
return results
}
+
func (r Runner) Run(root string) [] TestResult {
tcs := collectUnits(root, r.adapterCfgs())
- trs := r.cycle(tcs)
+ r.Build(tcs)
+ trs := r.Evaluate(tcs)
return trs
}