aboutsummaryrefslogtreecommitdiff
path: root/runner.go
diff options
context:
space:
mode:
authorFlu0r1ne <flur01ne@flu0r1ne.net>2021-08-03 02:02:40 -0500
committerFlu0r1ne <flur01ne@flu0r1ne.net>2021-08-03 02:02:40 -0500
commita0b020a78eb0b33965c59460fc093c6959216e44 (patch)
tree3b2722388ea6b312e927b6066b0831524ba4ed6b /runner.go
downloadplanr-a0b020a78eb0b33965c59460fc093c6959216e44.tar.xz
planr-a0b020a78eb0b33965c59460fc093c6959216e44.zip
Initial commit with basic build structure
Diffstat (limited to 'runner.go')
-rw-r--r--runner.go63
1 files changed, 63 insertions, 0 deletions
diff --git a/runner.go b/runner.go
new file mode 100644
index 0000000..5c66573
--- /dev/null
+++ b/runner.go
@@ -0,0 +1,63 @@
+package planr
+
+type Runner struct {
+ adapters []Adapter
+}
+
+func (r *Runner) RegisterAdapter(a Adapter) {
+ r.adapters = append(r.adapters, a)
+}
+
+func (r Runner) adapterCfgs() []AdapterConfig {
+ cgs := make([]AdapterConfig, len(r.adapters))
+
+ for _, adapter := range r.adapters {
+ cgs = append(cgs, adapter.Config())
+ }
+
+ return cgs
+}
+
+func (r Runner) collectUnits(root string) []TestCase {
+ tcs := make([]TestCase, 10)
+
+ collectUnits(root, nil, r.adapterCfgs(), &tcs)
+
+ return tcs
+}
+
+func (r Runner) cycle(tcs []TestCase) []TestResult {
+ results := make([]TestResult, 0)
+
+ for _, adapter := range r.adapters {
+ aname := adapter.Config().Name
+
+ adapter.InitializeBuild()
+
+ for _, tc := range tcs {
+ if tc.ContainsAdapter(aname) {
+ adapter.Build(tc)
+ }
+ }
+
+ adapter.FinalizeBuild()
+
+ for _, tc := range tcs {
+ if tc.ContainsAdapter(aname) {
+ results = append(results, adapter.Evaluate(tc))
+ }
+ }
+
+ adapter.Cleanup()
+ }
+
+ return results
+}
+
+func (r Runner) Run(root string) [] TestResult {
+ tcs := r.collectUnits(root)
+
+ trs := r.cycle(tcs)
+
+ return trs
+}