From b3efa2051e3b0edf4001afa326c5bf8b1268f4fe Mon Sep 17 00:00:00 2001 From: Flu0r1ne Date: Mon, 6 Sep 2021 13:21:49 -0500 Subject: Set individual cmd working dir rather than using chdir. Robust multithreading. --- adapters/gtest/adapter.go | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'adapters/gtest') 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]) -- cgit v1.2.3 From 9138bf659ccf80a6e6c414bab592214119788347 Mon Sep 17 00:00:00 2001 From: Flu0r1ne Date: Mon, 6 Sep 2021 14:12:08 -0500 Subject: Precompiler gtest and gmock libraries to stop threads from trampling on one another --- adapters/gtest/adapter.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'adapters/gtest') diff --git a/adapters/gtest/adapter.go b/adapters/gtest/adapter.go index bcd5a68..96b6976 100644 --- a/adapters/gtest/adapter.go +++ b/adapters/gtest/adapter.go @@ -53,6 +53,12 @@ func (adapter Adapter) Build(tcs []planr.TestCase) { cmd.Dir = adapter.buildDir planr.Exec(cmd) + + cmd = exec.Command("make", "gtest", "gmock") + + cmd.Dir = adapter.buildDir + + planr.Exec(cmd) } func (adapter *Adapter) Evaluate(tcs []planr.TestCase) [] planr.TestResult { -- cgit v1.2.3