From d078f6dc10eb265a5d88cd96adf86173d6d3ba2e Mon Sep 17 00:00:00 2001 From: Flu0r1ne Date: Thu, 2 Sep 2021 03:14:47 -0500 Subject: Make adapters and internals complient with new directory structure --- adapters/gtest/config.go | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) (limited to 'adapters/gtest/config.go') diff --git a/adapters/gtest/config.go b/adapters/gtest/config.go index cff45fa..4f8735f 100644 --- a/adapters/gtest/config.go +++ b/adapters/gtest/config.go @@ -5,6 +5,7 @@ import ( "golang.flu0r1ne.net/planr" "strings" "github.com/BurntSushi/toml" + "path" ) type GtestDefaults struct { @@ -42,29 +43,13 @@ func (g GtestConfig) ensureSatisfied(path string) { } } -func (cfg GtestConfig) joinTests(path_ string) string { - if cfg.Test_root == nil { - return planr.JoinConfigDir("tests", path_) - } - - return planr.JoinConfigDir(*cfg.Test_root, path_) -} - -func (cfg GtestConfig) joinSrcs(path_ string) string { - if cfg.Srcs_root == nil { - return planr.JoinConfigDir("../src", path_) - } - - return planr.JoinConfigDir(*cfg.Srcs_root, path_) -} - -func (cfg GtestConfig) srcList() string { +func (cfg GtestConfig) srcList(srcDir string) string { var srcList string if cfg.Srcs != nil { srcs := make([]string, len(*cfg.Srcs)) for i, src := range *cfg.Srcs { - srcs[i] = "\"" + cfg.joinSrcs(src) + "\"" + srcs[i] = "\"" + path.Join(srcDir, src) + "\"" } srcList = strings.Join(srcs, "\n ") -- cgit v1.2.3 From 287d029975b7718109f81b480079f375f7d8700a Mon Sep 17 00:00:00 2001 From: Flu0r1ne Date: Fri, 3 Sep 2021 00:02:31 -0500 Subject: Add clean option and fix issue with dir propegation --- adapters/gtest/config.go | 4 ---- 1 file changed, 4 deletions(-) (limited to 'adapters/gtest/config.go') diff --git a/adapters/gtest/config.go b/adapters/gtest/config.go index 4f8735f..4105932 100644 --- a/adapters/gtest/config.go +++ b/adapters/gtest/config.go @@ -12,9 +12,7 @@ type GtestDefaults struct { Name *string Suite *string Testfile *string - Test_root *string Srcs *[]string - Srcs_root *string } func (child *GtestDefaults) Inherit(p interface{}) { @@ -23,9 +21,7 @@ func (child *GtestDefaults) Inherit(p interface{}) { if(child.Name == nil) { child.Name = parent.Name } if(child.Suite == nil) { child.Suite = parent.Suite } if(child.Testfile == nil) { child.Testfile = parent.Testfile } - if(child.Test_root == nil) { child.Test_root = parent.Test_root } if(child.Srcs == nil) { child.Srcs = parent.Srcs } - if(child.Srcs_root == nil) { child.Srcs_root = parent.Srcs_root } } -- cgit v1.2.3 From 0e6b7378a564bb51b3a4289059e80fe9e3c6545b Mon Sep 17 00:00:00 2001 From: Flu0r1ne Date: Fri, 3 Sep 2021 00:51:47 -0500 Subject: BUG: Fix decoding when no defaults is present --- adapters/gtest/config.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'adapters/gtest/config.go') diff --git a/adapters/gtest/config.go b/adapters/gtest/config.go index 4105932..457eb64 100644 --- a/adapters/gtest/config.go +++ b/adapters/gtest/config.go @@ -8,11 +8,16 @@ import ( "path" ) +const ( + DEFAULT_TIMEOUT = 1000 +) + type GtestDefaults struct { Name *string Suite *string Testfile *string Srcs *[]string + Timeout *uint } func (child *GtestDefaults) Inherit(p interface{}) { @@ -22,6 +27,7 @@ func (child *GtestDefaults) Inherit(p interface{}) { if(child.Suite == nil) { child.Suite = parent.Suite } if(child.Testfile == nil) { child.Testfile = parent.Testfile } if(child.Srcs == nil) { child.Srcs = parent.Srcs } + if(child.Timeout == nil) { child.Timeout = parent.Timeout } } @@ -37,6 +43,11 @@ func (g GtestConfig) ensureSatisfied(path string) { } else if g.Testfile == nil { log.Fatalf("\"testfile\" is not defined for unit: %s\n", path) } + + if g.Timeout == nil { + g.Timeout = new(uint) + *g.Timeout = DEFAULT_TIMEOUT; + } } func (cfg GtestConfig) srcList(srcDir string) string { -- cgit v1.2.3 From cc7ba659adbc5ad55e1ce67f76952f2b8392c9c9 Mon Sep 17 00:00:00 2001 From: Flu0r1ne Date: Sat, 4 Sep 2021 15:38:30 -0500 Subject: Refactor build/eval pipeline to use clearer IO model and adapter segmentation methods --- adapters/gtest/config.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'adapters/gtest/config.go') diff --git a/adapters/gtest/config.go b/adapters/gtest/config.go index 457eb64..3305977 100644 --- a/adapters/gtest/config.go +++ b/adapters/gtest/config.go @@ -12,7 +12,7 @@ const ( DEFAULT_TIMEOUT = 1000 ) -type GtestDefaults struct { +type Defaults struct { Name *string Suite *string Testfile *string @@ -20,8 +20,8 @@ type GtestDefaults struct { Timeout *uint } -func (child *GtestDefaults) Inherit(p interface{}) { - parent := p.(*GtestDefaults) +func (child *Defaults) Inherit(p interface{}) { + parent := p.(*Defaults) if(child.Name == nil) { child.Name = parent.Name } if(child.Suite == nil) { child.Suite = parent.Suite } @@ -31,11 +31,11 @@ func (child *GtestDefaults) Inherit(p interface{}) { } -type GtestConfig struct { - GtestDefaults +type Config struct { + Defaults } -func (g GtestConfig) ensureSatisfied(path string) { +func (g Config) ensureSatisfied(path string) { if g.Name == nil { log.Fatalf("\"name\" is not defined for unit: %s\n", path) } else if g.Suite == nil { @@ -50,7 +50,7 @@ func (g GtestConfig) ensureSatisfied(path string) { } } -func (cfg GtestConfig) srcList(srcDir string) string { +func (cfg Config) srcList(srcDir string) string { var srcList string if cfg.Srcs != nil { @@ -66,7 +66,7 @@ func (cfg GtestConfig) srcList(srcDir string) string { } func ParseConfig(prim toml.Primitive) (planr.InheritableConfig, error) { - config := GtestConfig{} + config := Config{} if err := toml.PrimitiveDecode(prim, &config); err != nil { return nil, err @@ -76,7 +76,7 @@ func ParseConfig(prim toml.Primitive) (planr.InheritableConfig, error) { } func ParseDefaultConfig(prim toml.Primitive) (planr.InheritableConfig, error) { - config := GtestDefaults{} + config := Defaults{} if err := toml.PrimitiveDecode(prim, &config); err != nil { return nil, err -- cgit v1.2.3 From 151d516e68f5d43aa2d0c5ff462752d640b6a614 Mon Sep 17 00:00:00 2001 From: Flu0r1ne Date: Sun, 5 Sep 2021 00:37:23 -0500 Subject: Refactor gtest adapter to fit new pipeline --- adapters/gtest/config.go | 58 +++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 20 deletions(-) (limited to 'adapters/gtest/config.go') diff --git a/adapters/gtest/config.go b/adapters/gtest/config.go index 3305977..04d426c 100644 --- a/adapters/gtest/config.go +++ b/adapters/gtest/config.go @@ -2,10 +2,10 @@ package gtest import ( "log" - "golang.flu0r1ne.net/planr" "strings" - "github.com/BurntSushi/toml" "path" + "golang.flu0r1ne.net/planr" + "github.com/BurntSushi/toml" ) const ( @@ -16,7 +16,7 @@ type Defaults struct { Name *string Suite *string Testfile *string - Srcs *[]string + Srcs []string Timeout *uint } @@ -26,7 +26,7 @@ func (child *Defaults) Inherit(p interface{}) { if(child.Name == nil) { child.Name = parent.Name } if(child.Suite == nil) { child.Suite = parent.Suite } if(child.Testfile == nil) { child.Testfile = parent.Testfile } - if(child.Srcs == nil) { child.Srcs = parent.Srcs } + if(len(child.Srcs) == 0) { child.Srcs = parent.Srcs } if(child.Timeout == nil) { child.Timeout = parent.Timeout } } @@ -35,34 +35,52 @@ type Config struct { Defaults } -func (g Config) ensureSatisfied(path string) { - if g.Name == nil { +func (c * Config) finalize(path string) { + if c.Name == nil { log.Fatalf("\"name\" is not defined for unit: %s\n", path) - } else if g.Suite == nil { + } else if c.Suite == nil { log.Fatalf("\"suite\" is not defined for unit: %s\n", path) - } else if g.Testfile == nil { + } else if c.Testfile == nil { log.Fatalf("\"testfile\" is not defined for unit: %s\n", path) } - if g.Timeout == nil { - g.Timeout = new(uint) - *g.Timeout = DEFAULT_TIMEOUT; + if c.Timeout == nil { + c.Timeout = new(uint) + *c.Timeout = DEFAULT_TIMEOUT; } } -func (cfg Config) srcList(srcDir string) string { - var srcList string +func srcList(srcdir string, srcs []string) string { + builder := strings.Builder {} - if cfg.Srcs != nil { - srcs := make([]string, len(*cfg.Srcs)) - for i, src := range *cfg.Srcs { - srcs[i] = "\"" + path.Join(srcDir, src) + "\"" - } + for _, src := range srcs { + builder.WriteString("\"") + builder.WriteString(path.Join(srcdir, src)) + builder.WriteString("\"\n ") + } + + return builder.String() +} + +func cmakeUnits(e []executable, dirs planr.DirConfig) []cmakeUnit { + + units := make([]cmakeUnit, len(e)) + for i, exe := range e { + testpath := path.Join(dirs.Tests(), exe.testpath) + srclist := srcList(dirs.Src(), exe.srcs) - srcList = strings.Join(srcs, "\n ") + units[i] = cmakeUnit { exe.exeNm, testpath, srclist } } - return srcList + return units +} + +func finalizeConfigs(tcs []planr.TestCase) { + for i := range tcs { + cfg := tcs[i].AdapterConfig().(*Config) + + cfg.finalize(tcs[i].Path) + } } func ParseConfig(prim toml.Primitive) (planr.InheritableConfig, error) { -- cgit v1.2.3 From 4cc29e50d59daf445f4152d10f9f41cb1828f702 Mon Sep 17 00:00:00 2001 From: Flu0r1ne Date: Sun, 5 Sep 2021 01:00:12 -0500 Subject: Remove pointers and cleanup templating, add version info --- adapters/gtest/config.go | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'adapters/gtest/config.go') diff --git a/adapters/gtest/config.go b/adapters/gtest/config.go index 04d426c..533f266 100644 --- a/adapters/gtest/config.go +++ b/adapters/gtest/config.go @@ -13,21 +13,21 @@ const ( ) type Defaults struct { - Name *string - Suite *string - Testfile *string + Name string + Suite string + Testfile string Srcs []string - Timeout *uint + Timeout uint } func (child *Defaults) Inherit(p interface{}) { parent := p.(*Defaults) - if(child.Name == nil) { child.Name = parent.Name } - if(child.Suite == nil) { child.Suite = parent.Suite } - if(child.Testfile == nil) { child.Testfile = parent.Testfile } + if(child.Name == "") { child.Name = parent.Name } + if(child.Suite == "") { child.Suite = parent.Suite } + if(child.Testfile == "") { child.Testfile = parent.Testfile } if(len(child.Srcs) == 0) { child.Srcs = parent.Srcs } - if(child.Timeout == nil) { child.Timeout = parent.Timeout } + if(child.Timeout == 0) { child.Timeout = parent.Timeout } } @@ -36,17 +36,16 @@ type Config struct { } func (c * Config) finalize(path string) { - if c.Name == nil { + if c.Name == "" { log.Fatalf("\"name\" is not defined for unit: %s\n", path) - } else if c.Suite == nil { + } else if c.Suite == "" { log.Fatalf("\"suite\" is not defined for unit: %s\n", path) - } else if c.Testfile == nil { + } else if c.Testfile == "" { log.Fatalf("\"testfile\" is not defined for unit: %s\n", path) } - if c.Timeout == nil { - c.Timeout = new(uint) - *c.Timeout = DEFAULT_TIMEOUT; + if c.Timeout == 0 { + c.Timeout = DEFAULT_TIMEOUT; } } -- cgit v1.2.3