aboutsummaryrefslogtreecommitdiff
path: root/runner.go
diff options
context:
space:
mode:
authorFlu0r1ne <flur01ne@flu0r1ne.net>2021-09-03 00:02:31 -0500
committerFlu0r1ne <flur01ne@flu0r1ne.net>2021-09-03 00:02:31 -0500
commit287d029975b7718109f81b480079f375f7d8700a (patch)
tree2324f902ebc59ffda5afa2e7506e3fa0ac9b51b3 /runner.go
parentd078f6dc10eb265a5d88cd96adf86173d6d3ba2e (diff)
downloadplanr-287d029975b7718109f81b480079f375f7d8700a.tar.xz
planr-287d029975b7718109f81b480079f375f7d8700a.zip
Add clean option and fix issue with dir propegation
Diffstat (limited to 'runner.go')
-rw-r--r--runner.go32
1 files changed, 23 insertions, 9 deletions
diff --git a/runner.go b/runner.go
index f2eb8e9..0a6243c 100644
--- a/runner.go
+++ b/runner.go
@@ -8,7 +8,7 @@ import (
type Runner struct {
adapters []Adapter
- DirConfig
+ dirs DirConfig
}
func (r *Runner) RegisterAdapter(a Adapter) {
@@ -47,7 +47,7 @@ func (r Runner) checkConfig(tcs []TestCase) {
func (r Runner) setupEnv(adapter Adapter) {
nm := adapter.Config().Name
- wd := path.Join(r.BuildDir(), nm)
+ wd := path.Join(r.dirs.Build(), nm)
if !directoryExists(wd) {
if err := os.Mkdir(wd, 0755); err != nil {
@@ -70,18 +70,26 @@ func (r Runner) build(tcs []TestCase) {
adapter.Build(tcTab[nm])
}
- safeCd(r.ConfigDir())
+ safeCd(r.dirs.Config())
+}
+
+func (r Runner) init_adapters() {
+ for _, adapter := range r.adapters {
+ adapter.Init(r.dirs)
+ }
}
func (r Runner) units() []TestCase {
- return collectUnits(r.RubricDir(), r.adapterCfgs())
+ return collectUnits(r.dirs.Rubric(), r.adapterCfgs())
}
func (r Runner) Build() {
- units := r.units()
+ r.init_adapters()
- if !directoryExists(r.BuildDir()) {
- r.MkBuildDir()
+ units := r.units()
+
+ if !directoryExists(r.dirs.Build()) {
+ r.dirs.MkBuild()
}
r.build(units)
@@ -97,10 +105,12 @@ func (r Runner) evaluate(tcs []TestCase) {
adapter.Evaluate(tcTab[nm])
}
- safeCd(r.ConfigDir())
+ safeCd(r.dirs.Config())
}
func (r Runner) Evaluate() []TestCase {
+ r.init_adapters()
+
units := r.units()
r.evaluate(units)
@@ -109,5 +119,9 @@ func (r Runner) Evaluate() []TestCase {
}
func (r Runner) Clean() {
- r.CleanBuildDir()
+ r.dirs.CleanBuild()
+}
+
+func (r * Runner) SetConfigDirFromTree(childPath string) {
+ r.dirs.SetConfigFromTree(childPath)
}