package bash import ( "log" "golang.flu0r1ne.net/planr" "github.com/BurntSushi/toml" ) const ( DEFAULT_TIMEOUT=1000 ) type Defaults struct { Testfile string Timeout uint } func (child *Defaults) Inherit(p interface{}) { parent := p.(*Defaults) if(child.Timeout == 0) { child.Timeout = parent.Timeout } } type Config struct { Defaults } func (c *Config) finalize(path string) { if c.Testfile == "" { log.Fatalf("\"Testfile\" is not defined for unit %s\n", path) } if c.Timeout == 0 { c.Timeout = DEFAULT_TIMEOUT; } } 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) { config := Config {} if err := toml.PrimitiveDecode(prim, &config); err != nil { return nil, err } return &config, nil } func ParseDefaultConfig(prim toml.Primitive) (planr.InheritableConfig, error) { config := Defaults{} if err := toml.PrimitiveDecode(prim, &config); err != nil { return nil, err } return &config, nil }