summaryrefslogtreecommitdiff
path: root/adapters
diff options
context:
space:
mode:
Diffstat (limited to 'adapters')
-rw-r--r--adapters/bash/adapter.go14
-rw-r--r--adapters/gtest/adapter.go25
2 files changed, 23 insertions, 16 deletions
diff --git a/adapters/bash/adapter.go b/adapters/bash/adapter.go
index 65a6c80..8c7713c 100644
--- a/adapters/bash/adapter.go
+++ b/adapters/bash/adapter.go
@@ -15,7 +15,8 @@ import (
)
type Adapter struct {
- dirs planr.DirConfig
+ dirs planr.DirConfig
+ buildDir string
}
func (a *Adapter) Config() planr.AdapterConfig {
@@ -36,13 +37,14 @@ func safeWd() string{
return wd
}
-func (a *Adapter) Init(dirs planr.DirConfig) {
- a.dirs = dirs
+func (a *Adapter) Init(ctx planr.PipelineContext) {
+ a.dirs = ctx.Dirs
+ a.buildDir = ctx.AdapterDir
}
func (adapter Adapter) Build(tcs []planr.TestCase) { }
-func executeScriptedTest(testdir string, tc planr.TestCase) planr.TestResult {
+func executeScriptedTest(builddir, testdir string, tc planr.TestCase) planr.TestResult {
cfg := tc.AdapterConfig().(*Config)
timeout := time.Duration(cfg.Timeout) * time.Millisecond
@@ -57,6 +59,8 @@ func executeScriptedTest(testdir string, tc planr.TestCase) planr.TestResult {
result.Tc = tc
cmd := exec.CommandContext(ctx, "bash", path)
+
+ cmd.Dir = builddir
if out, err := cmd.CombinedOutput(); err != nil {
result.Status = planr.RUNTIME_FAILURE
@@ -87,7 +91,7 @@ func (adapter Adapter) Evaluate(tcs []planr.TestCase) [] planr.TestResult {
c := make(chan planr.TestResult, 0)
for i := range tcs {
go func(i int) {
- c <- executeScriptedTest(adapter.dirs.Tests(), tcs[i])
+ c <- executeScriptedTest(adapter.buildDir, adapter.dirs.Tests(), tcs[i])
}(i)
}
diff --git a/adapters/gtest/adapter.go b/adapters/gtest/adapter.go
index 2961f29..bcd5a68 100644
--- a/adapters/gtest/adapter.go
+++ b/adapters/gtest/adapter.go
@@ -4,6 +4,7 @@ import (
"log"
"os"
"path"
+ "os/exec"
"golang.flu0r1ne.net/planr"
)
@@ -20,7 +21,8 @@ func safeWd() string{
}
type Adapter struct {
- dirs planr.DirConfig
+ dirs planr.DirConfig
+ buildDir string
}
func (a *Adapter) Config() planr.AdapterConfig {
@@ -31,28 +33,29 @@ func (a *Adapter) Config() planr.AdapterConfig {
}
}
-func (a *Adapter) Init(dirs planr.DirConfig) {
- a.dirs = dirs
+func (a *Adapter) Init(ctx planr.PipelineContext) {
+ a.dirs = ctx.Dirs
+ a.buildDir = ctx.AdapterDir
}
func (adapter Adapter) Build(tcs []planr.TestCase) {
- buildDir := safeWd()
-
finalizeConfigs(tcs)
exes := createExecutables(tcs)
- cmakeFile := path.Join(buildDir, GTEST_CMAKE)
+ cmakeFile := path.Join(adapter.buildDir, GTEST_CMAKE)
cmakeUnits := cmakeUnits(exes, adapter.dirs)
generateCmakeScript(cmakeFile, cmakeUnits)
- planr.RunCmd("cmake", "-S", ".", "-B", ".")
+ cmd := exec.Command("cmake", "-S", ".", "-B", ".")
+
+ cmd.Dir = adapter.buildDir
+
+ planr.Exec(cmd)
}
func (adapter *Adapter) Evaluate(tcs []planr.TestCase) [] planr.TestResult {
- buildDir := safeWd()
-
finalizeConfigs(tcs)
results := make([]planr.TestResult, 0)
@@ -62,14 +65,14 @@ func (adapter *Adapter) Evaluate(tcs []planr.TestCase) [] planr.TestResult {
c := make(chan []planr.TestResult, len(exes))
for i := range exes {
go func(exe *executable) {
- succeed, buildFailures := exe.compile(buildDir)
+ succeed, buildFailures := exe.compile(adapter.buildDir)
if ! succeed {
c <- buildFailures
return
}
- runtimeResults := exe.execute(buildDir)
+ runtimeResults := exe.execute(adapter.buildDir)
c <- runtimeResults
}(&exes[i])