diff options
author | Flu0r1ne <flur01ne@flu0r1ne.net> | 2021-08-05 15:56:10 -0500 |
---|---|---|
committer | Flu0r1ne <flur01ne@flu0r1ne.net> | 2021-08-05 15:56:10 -0500 |
commit | 72a70b127636ae8a83e2a2bd53b69143e3c5ded0 (patch) | |
tree | fdddf5cccdb487d63909f97074d111e67c79ded7 /runner.go | |
parent | f90a14d5d723c5d2b87f2eaa19f441dec33bb9b2 (diff) | |
download | planr-72a70b127636ae8a83e2a2bd53b69143e3c5ded0.tar.xz planr-72a70b127636ae8a83e2a2bd53b69143e3c5ded0.zip |
Runtime & reorganziation
Diffstat (limited to 'runner.go')
-rw-r--r-- | runner.go | 59 |
1 files changed, 32 insertions, 27 deletions
@@ -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 } |