summaryrefslogtreecommitdiff
path: root/runner.go
diff options
context:
space:
mode:
Diffstat (limited to 'runner.go')
-rw-r--r--runner.go48
1 files changed, 34 insertions, 14 deletions
diff --git a/runner.go b/runner.go
index 3bee17a..f2eb8e9 100644
--- a/runner.go
+++ b/runner.go
@@ -3,10 +3,12 @@ package planr
import (
"log"
"os"
+ "path"
)
type Runner struct {
adapters []Adapter
+ DirConfig
}
func (r *Runner) RegisterAdapter(a Adapter) {
@@ -43,12 +45,17 @@ func (r Runner) checkConfig(tcs []TestCase) {
}
}
-func cdBuild(adapter Adapter) {
- dir := adapter.Config().Dir()
+func (r Runner) setupEnv(adapter Adapter) {
+ nm := adapter.Config().Name
+ wd := path.Join(r.BuildDir(), nm)
- if err := os.Chdir(dir); err != nil {
- log.Fatal(err)
- }
+ if !directoryExists(wd) {
+ if err := os.Mkdir(wd, 0755); err != nil {
+ log.Fatalf("Could not create adapter config %s %v\n", wd, err)
+ }
+ }
+
+ safeCd(wd)
}
func (r Runner) build(tcs []TestCase) {
@@ -58,18 +65,25 @@ func (r Runner) build(tcs []TestCase) {
for _, adapter := range r.adapters {
nm := adapter.Config().Name
- cdBuild(adapter)
+ r.setupEnv(adapter)
adapter.Build(tcTab[nm])
}
+
+ safeCd(r.ConfigDir())
}
-func (r Runner) units(root string) []TestCase {
- return collectUnits(root, r.adapterCfgs())
+func (r Runner) units() []TestCase {
+ return collectUnits(r.RubricDir(), r.adapterCfgs())
}
-func (r Runner) Build(root string) {
- units := r.units(root)
+func (r Runner) Build() {
+ units := r.units()
+
+ if !directoryExists(r.BuildDir()) {
+ r.MkBuildDir()
+ }
+
r.build(units)
}
@@ -78,16 +92,22 @@ func (r Runner) evaluate(tcs []TestCase) {
for _, adapter := range r.adapters {
nm := adapter.Config().Name
- cdBuild(adapter)
-
+
+ r.setupEnv(adapter)
adapter.Evaluate(tcTab[nm])
}
+
+ safeCd(r.ConfigDir())
}
-func (r Runner) Evaluate(root string) []TestCase {
- units := r.units(root)
+func (r Runner) Evaluate() []TestCase {
+ units := r.units()
r.evaluate(units)
return units
}
+
+func (r Runner) Clean() {
+ r.CleanBuildDir()
+}