diff options
-rw-r--r-- | adapters/gtest/adapter.go | 7 | ||||
-rw-r--r-- | cmd/planr/main.go | 21 | ||||
-rw-r--r-- | runner.go | 20 | ||||
-rw-r--r-- | runner_builder.go | 42 |
4 files changed, 57 insertions, 33 deletions
diff --git a/adapters/gtest/adapter.go b/adapters/gtest/adapter.go index 415d823..0a955ef 100644 --- a/adapters/gtest/adapter.go +++ b/adapters/gtest/adapter.go @@ -188,8 +188,7 @@ func (adapter *GtestAdapter) Evaluate(tcs []*planr.TestCase) { // compilation failure if !ok { - fmt.Printf("CAN'T FIND %s: status %d\n", tc.Cname, tc.Result.Status) - + if tc.Result.Status == planr.PASSING { cfg := tc.AdapterConfig().(*GtestConfig) @@ -214,3 +213,7 @@ func (adapter *GtestAdapter) Evaluate(tcs []*planr.TestCase) { tc.Result.TestOutput = result.testOutput } } + +func New() *GtestAdapter { + return new(GtestAdapter) +} diff --git a/cmd/planr/main.go b/cmd/planr/main.go index 277ffc8..b2a0975 100644 --- a/cmd/planr/main.go +++ b/cmd/planr/main.go @@ -27,15 +27,14 @@ func dieUsage() { os.Exit(1) } -func NewRunner() planr.Runner { - r := planr.Runner {} - - r.RegisterAdapter(>est.GtestAdapter{}) +func getConfiguredRunner() planr.Runner { + r := planr.ConfigureRunner() + r = planr.RegisterAdapter(r, gtest.New()) if wd, err := os.Getwd(); err == nil { - r.SetConfigDirFromTree(wd) + r = planr.SetConfigDirFromTree(r, wd) } - + src := flag.String("srcdir", "", "source directory") config := flag.String("configdir", "", "config directory") build := flag.String("builddir", "", "build directory") @@ -43,18 +42,18 @@ func NewRunner() planr.Runner { flag.Parse() if src != nil && *src != "" { - r.SetSrcDir(*src) + r = planr.SetSrcDir(r, *src) } if config != nil && *config != "" { - r.SetConfigDir(*config) + r = planr.SetConfigDir(r, *config) } if build != nil && *build != "" { - r.SetBuildDir(*build) + r = planr.SetBuildDir(r, *build) } - return r + return r.New() } func main() { @@ -66,7 +65,7 @@ func main() { dieUsage() } - runner := NewRunner() + runner := getConfiguredRunner() subcommand := flag.Arg(0) subargs := flag.Args()[1:] @@ -11,10 +11,6 @@ type Runner struct { dirs DirConfig } -func (r *Runner) RegisterAdapter(a Adapter) { - r.adapters = append(r.adapters, a) -} - func (r Runner) adapterCfgs() []AdapterConfig { cgs := make([]AdapterConfig, len(r.adapters)) @@ -122,22 +118,6 @@ func (r Runner) Clean() { r.dirs.CleanBuild() } -func (r * Runner) SetConfigDirFromTree(childPath string) { - r.dirs.SetConfigFromTree(childPath) -} - -func (r * Runner) SetBuildDir(dir string) { - r.dirs.SetBuild(dir) -} - -func (r * Runner) SetConfigDir(dir string) { - r.dirs.SetConfig(dir) -} - -func (r * Runner) SetSrcDir(dir string) { - r.dirs.SetSrc(dir) -} - func (r Runner) BuildDir() string { return r.dirs.Build(); } diff --git a/runner_builder.go b/runner_builder.go new file mode 100644 index 0000000..848d09b --- /dev/null +++ b/runner_builder.go @@ -0,0 +1,42 @@ +package planr + +type RunnerBuilder struct { + adapters [] Adapter + dirs DirConfig +} + +func ConfigureRunner() RunnerBuilder { + return RunnerBuilder {} +} + +func RegisterAdapter(b RunnerBuilder, a Adapter) RunnerBuilder { + b.adapters = append(b.adapters, a) + return b +} + +func SetConfigDirFromTree(b RunnerBuilder, childPath string) RunnerBuilder { + b.dirs.SetConfigFromTree(childPath) + return b +} + +func SetConfigDir(b RunnerBuilder, dir string) RunnerBuilder { + b.dirs.SetConfig(dir) + return b +} + +func SetBuildDir(b RunnerBuilder, dir string) RunnerBuilder { + b.dirs.SetBuild(dir) + return b +} + +func SetSrcDir(b RunnerBuilder, dir string) RunnerBuilder { + b.dirs.SetSrc(dir) + return b +} + +func (b RunnerBuilder) New() Runner { + return Runner { + dirs: b.dirs, + adapters: b.adapters, + } +} |