From 7c7cc02d7250345c97f18be2ee617fafc5022f18 Mon Sep 17 00:00:00 2001 From: Prateek Baheti Date: Fri, 22 May 2015 18:09:13 +0530 Subject: [PATCH] Re-using the same runner instance when executing specs after starting api. This ensures runner is not started twice during execution. Fixes #34 --- gauge.go | 13 ++++++------- specDetails.go | 4 +--- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/gauge.go b/gauge.go index 65a22a1df..ff0060c5b 100644 --- a/gauge.go +++ b/gauge.go @@ -260,18 +260,17 @@ func executeSpecs(inParallel bool) { handleCriticalError(err) } err, apiHandler := startAPIService(0) - apiHandler.runner.kill(getCurrentLogger()) if err != nil { + apiHandler.runner.kill(getCurrentLogger()) handleCriticalError(errors.New(fmt.Sprintf("Failed to start gauge API. %s\n", err.Error()))) } - - runner, runnerError := startRunnerAndMakeConnection(manifest, getCurrentLogger()) - if runnerError != nil { - handleCriticalError(errors.New(fmt.Sprintf("Failed to start a runner. %s\n", runnerError.Error()))) + if apiHandler.runner == nil { + handleCriticalError(errors.New("Failed to start a runner\n")) } - validateSpecs(manifest, specsToExecute, runner, conceptsDictionary) + + validateSpecs(manifest, specsToExecute, apiHandler.runner, conceptsDictionary) pluginHandler := startPlugins(manifest) - execution := newExecution(manifest, specsToExecute, runner, pluginHandler, parallelInfo, getCurrentLogger()) + execution := newExecution(manifest, specsToExecute, apiHandler.runner, pluginHandler, parallelInfo, getCurrentLogger()) result := execution.start() execution.finish() exitCode := printExecutionStatus(result, specsSkipped) diff --git a/specDetails.go b/specDetails.go index b286cd895..222e14586 100644 --- a/specDetails.go +++ b/specDetails.go @@ -264,11 +264,9 @@ func (specInfoGatherer *specInfoGatherer) getStepsFromRunner(runner *testRunner) if connErr == nil { steps = append(steps, requestForSteps(runner)...) logger.ApiLog.Debug("Steps got from runner: %v", steps) - } - if connErr != nil { + } else { logger.ApiLog.Error("Runner connection failed: %s", connErr) } - } else { steps = append(steps, requestForSteps(runner)...) logger.ApiLog.Debug("Steps got from runner: %v", steps)