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) for i := range exes { succeed, buildFailures := exes[i].compile(buildDir) if ! succeed { results = append(results, buildFailures...) continue } runtimeResults := exes[i].execute(buildDir) results = append(results, runtimeResults...) } return results } func NewAdapter() *Adapter { return new(Adapter) }