func ExecuteSpecs(inParallel bool, args []string) int { if checkUpdatesDuringExecution && config.CheckUpdates() { i := &install.UpdateFacade{} i.BufferUpdateDetails() defer i.PrintUpdateBuffer() } env.LoadEnv(false) specsToExecute, conceptsDictionary := parseSpecs(args) manifest, err := manifest.ProjectManifest() if err != nil { logger.Fatal(err.Error()) } runner := startApi() errMap := validateSpecs(manifest, specsToExecute, runner, conceptsDictionary) pluginHandler := plugin.StartPlugins(manifest) parallelInfo := ¶llelInfo{inParallel: inParallel, numberOfStreams: NumberOfExecutionStreams} if !parallelInfo.isValid() { os.Exit(1) } execution := newExecution(&executionInfo{manifest, specsToExecute, runner, pluginHandler, parallelInfo, reporter.Current(), errMap}) result := execution.start() execution.finish() exitCode := printExecutionStatus(result, errMap) return exitCode }
func InstallAllPlugins() { manifest, err := manifest.ProjectManifest() if err != nil { logger.Fatalf(err.Error()) } installPluginsFromManifest(manifest) }
func ExecuteSpecs(inParallel bool, args []string) { env.LoadEnv(false) conceptsDictionary, conceptParseResult := parser.CreateConceptsDictionary(false) parser.HandleParseResult(conceptParseResult) specsToExecute, specsSkipped := filter.GetSpecsToExecute(conceptsDictionary, args) if len(specsToExecute) == 0 { printExecutionStatus(nil, 0) } parallelInfo := ¶llelInfo{inParallel: inParallel, numberOfStreams: NumberOfExecutionStreams} if !parallelInfo.isValid() { os.Exit(1) } manifest, err := manifest.ProjectManifest() if err != nil { execLogger.CriticalError(err) } runner := startApi() validateSpecs(manifest, specsToExecute, runner, conceptsDictionary) pluginHandler := plugin.StartPlugins(manifest) execution := newExecution(manifest, specsToExecute, runner, pluginHandler, parallelInfo, execLogger.Current()) result := execution.start() execution.finish() exitCode := printExecutionStatus(result, specsSkipped) os.Exit(exitCode) }
func InstallAllPlugins() { manifest, err := manifest.ProjectManifest() if err != nil { execLogger.CriticalError(errors.New(fmt.Sprintf("manifest.json not found : --install-all requires manifest.json in working directory."))) } installPluginsFromManifest(manifest) }
func language() string { if config.ProjectRoot == "" { return "" } m, err := manifest.ProjectManifest() if err != nil { return "" } return m.Language }
func connectToRunner(killChannel chan bool) (*runner.TestRunner, error) { manifest, err := manifest.ProjectManifest() if err != nil { return nil, err } runner, connErr := runner.StartRunnerAndMakeConnection(manifest, &logger.Log, killChannel) if connErr != nil { return nil, connErr } return runner, nil }
func Validate(args []string) { specsToExecute, conceptsDictionary := parseSpecs(args) manifest, err := manifest.ProjectManifest() if err != nil { logger.Fatalf(err.Error()) } runner := startAPI() errMap := validateSpecs(manifest, specsToExecute, runner, conceptsDictionary) runner.Kill() if len(errMap.stepErrs) > 0 { os.Exit(1) } logger.Info("No error found.") os.Exit(0) }
// Gets all steps list from the runner func (specInfoGatherer *SpecInfoGatherer) getStepsFromRunner(killChannel chan bool) (*runner.TestRunner, error) { steps := make([]string, 0) manifest, err := manifest.ProjectManifest() if err != nil { execLogger.CriticalError(err) } testRunner, connErr := runner.StartRunnerAndMakeConnection(manifest, &logger.Log, killChannel) if connErr == nil { steps = append(steps, requestForSteps(testRunner)...) logger.ApiLog.Debug("Steps got from runner: %v", steps) } else { logger.ApiLog.Error("Runner connection failed: %s", connErr) } specInfoGatherer.runnerStepValues = specInfoGatherer.convertToStepValues(steps) return testRunner, connErr }
func newExecutionInfo(s *gauge.SpecCollection, r *runner.TestRunner, ph *plugin.Handler, rep reporter.Reporter, e *validation.ValidationErrMaps, p bool) *executionInfo { m, err := manifest.ProjectManifest() if err != nil { logger.Fatalf(err.Error()) } return &executionInfo{ manifest: m, specs: s, runner: r, pluginHandler: ph, consoleReporter: rep, errMaps: e, inParallel: p, numberOfStreams: NumberOfExecutionStreams, } }
func CheckSpecs(args []string) { env.LoadEnv(false) specsToExecute, conceptsDictionary := parseSpecs(args) manifest, err := manifest.ProjectManifest() if err != nil { logger.Log.Critical(err.Error()) } runner := startApi() errMap := validateSpecs(manifest, specsToExecute, runner, conceptsDictionary) runner.Kill() if len(errMap.stepErrs) > 0 { os.Exit(1) } logger.Log.Info("No error found.") os.Exit(0) }
func ValidateSpecs(args []string, r *runner.TestRunner) (*gauge.SpecCollection, *ValidationErrMaps) { s, c := parseSpecs(args) manifest, err := manifest.ProjectManifest() if err != nil { logger.Fatalf(err.Error()) } v := newValidator(manifest, s, r, c) vErrs := v.validate() errMap := &ValidationErrMaps{ SpecErrs: make(map[*gauge.Specification][]*StepValidationError), ScenarioErrs: make(map[*gauge.Scenario][]*StepValidationError), StepErrs: make(map[*gauge.Step]*StepValidationError), } if len(vErrs) > 0 { printValidationFailures(vErrs) fillErrors(errMap, vErrs) } return gauge.NewSpecCollection(s), errMap }
func ExecuteSpecs(inParallel bool, args []string) { env.LoadEnv(false) specsToExecute, conceptsDictionary := parseSpecs(args) manifest, err := manifest.ProjectManifest() if err != nil { logger.Log.Critical(err.Error()) } runner := startApi() errMap := validateSpecs(manifest, specsToExecute, runner, conceptsDictionary) pluginHandler := plugin.StartPlugins(manifest) parallelInfo := ¶llelInfo{inParallel: inParallel, numberOfStreams: NumberOfExecutionStreams} if !parallelInfo.isValid() { os.Exit(1) } execution := newExecution(&executionInfo{manifest, specsToExecute, runner, pluginHandler, parallelInfo, &logger.Log, errMap}) result := execution.start() execution.finish() exitCode := printExecutionStatus(result, errMap) os.Exit(exitCode) }
func ExecuteSpecs(inParallel bool, args []string) { env.LoadEnv(false) specsToExecute, conceptsDictionary := parseSpecs(args) manifest, err := manifest.ProjectManifest() if err != nil { logger.Log.Critical(err.Error()) } runner := startApi() errMap := validateSpecs(manifest, specsToExecute, runner, conceptsDictionary) pluginHandler := plugin.StartPlugins(manifest) parallelInfo := ¶llelInfo{inParallel: inParallel, numberOfStreams: NumberOfExecutionStreams} if !parallelInfo.isValid() { os.Exit(1) } execution := newExecution(&executionInfo{manifest, specsToExecute, runner, pluginHandler, parallelInfo, &logger.Log, errMap}) result := execution.start() // TODO: Remove this logger line below when plugins call tell the difference between their status messages and user-generated sysouts logger.Log.Debug("\n") execution.finish() exitCode := printExecutionStatus(result, errMap) os.Exit(exitCode) }
func AddPluginToProject(pluginName string, pluginArgs string) { additionalArgs := make(map[string]string) if pluginArgs != "" { // plugin args will be comma separated values // eg: version=1.0, foo_version = 2.41 args := strings.Split(pluginArgs, ",") for _, arg := range args { keyValuePair := strings.Split(arg, "=") if len(keyValuePair) == 2 { additionalArgs[strings.TrimSpace(keyValuePair[0])] = strings.TrimSpace(keyValuePair[1]) } } } manifest, err := manifest.ProjectManifest() if err != nil { logger.Fatalf(err.Error()) } if err := addPluginToTheProject(pluginName, additionalArgs, manifest); err != nil { logger.Fatalf(fmt.Sprintf("Failed to add plugin %s to project : %s\n", pluginName, err.Error())) } else { logger.Info("Plugin %s was successfully added to the project\n", pluginName) } }
func ExecuteSpecs(args []string) int { validateFlags() if checkUpdatesDuringExecution && config.CheckUpdates() { i := &install.UpdateFacade{} i.BufferUpdateDetails() defer i.PrintUpdateBuffer() } specsToExecute, conceptsDictionary := parseSpecs(args) manifest, err := manifest.ProjectManifest() if err != nil { logger.Fatalf(err.Error()) } runner := startAPI() errMap := validateSpecs(manifest, specsToExecute, runner, conceptsDictionary) executionInfo := newExecutionInfo(manifest, &specStore{specs: specsToExecute}, runner, nil, reporter.Current(), errMap, InParallel) execution := newExecution(executionInfo) execution.start() result := execution.run() execution.finish() exitCode := printExecutionStatus(result, errMap) return exitCode }