From a0b020a78eb0b33965c59460fc093c6959216e44 Mon Sep 17 00:00:00 2001 From: Flu0r1ne Date: Tue, 3 Aug 2021 02:02:40 -0500 Subject: Initial commit with basic build structure --- adapters/gtest_adapter.go | 97 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 adapters/gtest_adapter.go (limited to 'adapters/gtest_adapter.go') diff --git a/adapters/gtest_adapter.go b/adapters/gtest_adapter.go new file mode 100644 index 0000000..4cbaa9c --- /dev/null +++ b/adapters/gtest_adapter.go @@ -0,0 +1,97 @@ +package adapters + +import ( + "fmt" + "github.com/BurntSushi/toml" + "golang.flu0r1ne.net/planr" + "log" +) + +/* + CONFIGURATION +*/ + +type GtestDefaults struct { + Name *string + Suite *string + File *string +} + +func (child *GtestDefaults) Inherit(p interface{}) { + parent := p.(*GtestDefaults) + + if(child.Name == nil) { + child.Name = parent.Name + } + + if(child.Suite == nil) { + child.Suite = parent.Suite + } + + if(child.File == nil) { + child.File = parent.File + } +} + + +type GtestConfig struct { + GtestDefaults +} + +func primitiveDecode(primitive toml.Primitive, config interface{}) { + if err := toml.PrimitiveDecode(primitive, config); err != nil { + log.Fatal(err) + } +} + +func ParseConfig(prim toml.Primitive) planr.InheritableConfig { + config := GtestConfig{} + + primitiveDecode(prim, &config) + + return &config +} + +func ParseDefaultConfig(prim toml.Primitive) planr.InheritableConfig { + config := GtestDefaults{} + + primitiveDecode(prim, &config) + + return &config +} + +/* + BUILD PROCESS +*/ + +type GtestAdapter struct {} + +func (a GtestAdapter) Config() planr.AdapterConfig { + return planr.AdapterConfig { + Name: "gtest", + ParseConfig: ParseConfig, + ParseDefaultConfig: ParseDefaultConfig, + } +} + +func (a GtestAdapter) InitializeBuild() { + fmt.Println("Initializing"); +} + +func (a GtestAdapter) Build(tc planr.TestCase) { + fmt.Printf("Building %v\n", tc); +} + +func (a GtestAdapter) FinalizeBuild() { + fmt.Println("Finalizing"); +} + +func (a GtestAdapter) Evaluate(tc planr.TestCase) planr.TestResult { + fmt.Printf("Evaluating %v\n", tc); + + return planr.TestResult {} +} + +func (a GtestAdapter) Cleanup() { + fmt.Printf("Cleaning\n") +} -- cgit v1.2.3