diff options
author | Flu0r1ne <flur01ne@flu0r1ne.net> | 2021-09-06 13:21:49 -0500 |
---|---|---|
committer | Flu0r1ne <flur01ne@flu0r1ne.net> | 2021-09-06 13:21:49 -0500 |
commit | b3efa2051e3b0edf4001afa326c5bf8b1268f4fe (patch) | |
tree | 52b8d8e678773c6fde49c6a64d5b91ea21c630ac /runner.go | |
parent | 40236ca7e4024a2a181a2de6d0bbc22a68487dc1 (diff) | |
download | planr-b3efa2051e3b0edf4001afa326c5bf8b1268f4fe.tar.xz planr-b3efa2051e3b0edf4001afa326c5bf8b1268f4fe.zip |
Set individual cmd working dir rather than using chdir. Robust multithreading.
Diffstat (limited to 'runner.go')
-rw-r--r-- | runner.go | 29 |
1 files changed, 17 insertions, 12 deletions
@@ -29,17 +29,19 @@ func (r Runner) checkConfig(tcs []TestCase) { } } -func (r Runner) setupEnv(adapter Adapter) { - nm := adapter.Config().Name - wd := path.Join(r.dirs.Build(), nm) +func adapterBuildDir(dirs DirConfig, adapter Adapter) string { + return path.Join(dirs.Build(), adapter.Config().Name) +} + +func (r Runner) createAdapterBuildDir(adapter Adapter) { + build := adapterBuildDir(r.dirs, adapter) - if !directoryExists(wd) { - if err := os.Mkdir(wd, 0755); err != nil { - log.Fatalf("Could not create adapter config %s %v\n", wd, err) + if !directoryExists(build) { + if err := os.Mkdir(build, 0755); err != nil { + log.Fatalf("Could not create adapter config %s %v\n", build, err) } } - safeCd(wd) } type adapterTestSet struct { @@ -101,12 +103,10 @@ func (r Runner) Build(tcs []TestCase) { adapter := pair.adapter cases := pair.tcs - r.setupEnv(adapter) + r.createAdapterBuildDir(adapter) adapter.Build(cases) } - - safeCd(r.dirs.Config()) } func (r Runner) Evaluate(tcs []TestCase) []TestResult { @@ -119,7 +119,6 @@ func (r Runner) Evaluate(tcs []TestCase) []TestResult { adapter := pair.adapter cases := pair.tcs - r.setupEnv(adapter) resultSet := adapter.Evaluate(cases) c <- resultSet @@ -155,9 +154,15 @@ func (r Runner) SrcDir() string { func NewRunner(adapters map[string]Adapter, dirs DirConfig) Runner { r := Runner{adapters, dirs} + for _, adapter := range r.adapters { - adapter.Init(dirs) + ctx := PipelineContext { + Dirs: dirs, + AdapterDir: adapterBuildDir(dirs, adapter), + } + + adapter.Init(ctx) } return r |