package gtest import ( "log" "os" "path" "golang.flu0r1ne.net/planr" ) const GTEST_CMAKE = "CMakeLists.txt" func safeWd() string{ wd, err := os.Getwd() if err != nil { log.Fatalf("Could not get GtestBuildDir %s %v\n", wd, err) } return wd } type Adapter struct { dirs planr.DirConfig } func (a *Adapter) Config() planr.AdapterConfig { return planr.AdapterConfig { Name: "gtest", ParseConfig: ParseConfig, ParseDefaultConfig: ParseDefaultConfig, } } func (a *Adapter) Init(dirs planr.DirConfig) { a.dirs = dirs } func (adapter Adapter) Build(tcs []planr.TestCase) { buildDir := safeWd() finalizeConfigs(tcs) exes := createExecutables(tcs) cmakeFile := path.Join(buildDir, GTEST_CMAKE) cmakeUnits := cmakeUnits(exes, adapter.dirs) generateCmakeScript(cmakeFile, cmakeUnits) planr.RunCmd("cmake", "-S", ".", "-B", ".") } func (adapter *Adapter) Evaluate(tcs []planr.TestCase) [] planr.TestResult { buildDir := safeWd() finalizeConfigs(tcs) results := make([]planr.TestResult, 0) exes := createExecutables(tcs) c := make(chan []planr.TestResult, len(exes)) for i := range exes { go func(exe *executable) { succeed, buildFailures := exe.compile(buildDir) if ! succeed { c <- buildFailures return } runtimeResults := exe.execute(buildDir) c <- runtimeResults }(&exes[i]) } for range exes { results = append(results, (<-c)...) } return results } func NewAdapter() *Adapter { return new(Adapter) }