Beispiel #1
0
func StartPlugin(pd *pluginDescriptor, action string) (*plugin, error) {
	command := []string{}
	switch runtime.GOOS {
	case "windows":
		command = pd.Command.Windows
		break
	case "darwin":
		command = pd.Command.Darwin
		break
	default:
		command = pd.Command.Linux
		break
	}
	if len(command) == 0 {
		return nil, fmt.Errorf("Platform specific command not specified: %s.", runtime.GOOS)
	}

	cmd, err := common.ExecuteCommand(command, pd.pluginPath, reporter.Current(), reporter.Current())

	if err != nil {
		return nil, err
	}
	var mutex = &sync.Mutex{}
	go func() {
		pState, _ := cmd.Process.Wait()
		mutex.Lock()
		cmd.ProcessState = pState
		mutex.Unlock()
	}()
	plugin := &plugin{pluginCmd: cmd, descriptor: pd, mutex: mutex}
	return plugin, nil
}
Beispiel #2
0
func (s *MySuite) TestCreateSkippedSpecResultWithScenarios(c *C) {
	specText := SpecBuilder().specHeading("A spec heading").
		scenarioHeading("First scenario").
		step("create user \"456\" \"foo\" and \"9900\"").
		String()

	spec, _ := new(parser.SpecParser).Parse(specText, gauge.NewConceptDictionary())
	spec.FileName = "FILE"
	specExecutor := newSpecExecutor(spec, nil, nil, indexRange{start: 0, end: 0}, nil, nil)
	specExecutor.errMap = &validationErrMaps{make(map[*gauge.Specification][]*stepValidationError), make(map[*gauge.Scenario][]*stepValidationError), make(map[*gauge.Step]*stepValidationError)}
	specExecutor.consoleReporter = reporter.Current()
	specExecutor.specResult = &result.SpecResult{ProtoSpec: &gauge_messages.ProtoSpec{}}
	result := specExecutor.createSkippedSpecResult(fmt.Errorf("ERROR"))

	c.Assert(result.IsFailed, Equals, false)
	c.Assert(result.Skipped, Equals, true)

	c.Assert(len(specExecutor.errMap.specErrs[spec]), Equals, 1)
	c.Assert(specExecutor.errMap.specErrs[spec][0].Error(), Equals, "ERROR")
	c.Assert(specExecutor.errMap.specErrs[spec][0].fileName, Equals, "FILE")
	c.Assert(specExecutor.errMap.specErrs[spec][0].step.LineNo, Equals, 1)
	c.Assert(specExecutor.errMap.specErrs[spec][0].step.LineText, Equals, "A spec heading")
	c.Assert(len(specExecutor.errMap.scenarioErrs[spec.Scenarios[0]]), Equals, 1)
	c.Assert(specExecutor.errMap.scenarioErrs[spec.Scenarios[0]][0].Error(), Equals, "ERROR")
	c.Assert(specExecutor.errMap.scenarioErrs[spec.Scenarios[0]][0].fileName, Equals, "FILE")
	c.Assert(specExecutor.errMap.scenarioErrs[spec.Scenarios[0]][0].step.LineNo, Equals, 1)
	c.Assert(specExecutor.errMap.scenarioErrs[spec.Scenarios[0]][0].step.LineText, Equals, "A spec heading")
}
Beispiel #3
0
func connectToRunner(killChannel chan bool) (*runner.TestRunner, error) {
	manifest, err := manifest.ProjectManifest()
	if err != nil {
		return nil, err
	}

	runner, connErr := runner.StartRunnerAndMakeConnection(manifest, reporter.Current(), killChannel)
	if connErr != nil {
		return nil, connErr
	}

	return runner, nil
}
Beispiel #4
0
func ExecuteSpecs(specDirs []string) int {
	validateFlags()
	if config.CheckUpdates() {
		i := &install.UpdateFacade{}
		i.BufferUpdateDetails()
		defer i.PrintUpdateBuffer()
	}

	runner := startAPI()
	specs, errMap := validation.ValidateSpecs(specDirs, runner)
	ei := newExecutionInfo(specs, runner, nil, reporter.Current(), errMap, InParallel)
	e := newExecution(ei)
	return printExecutionStatus(e.run(), errMap)
}
Beispiel #5
0
func (s *MySuite) TestCreateSkippedSpecResult(c *C) {
	spec := &gauge.Specification{Heading: &gauge.Heading{LineNo: 0, Value: "SPEC_HEADING"}, FileName: "FILE"}

	specExecutor := newSpecExecutor(spec, nil, nil, indexRange{start: 0, end: 0}, nil, nil)
	specExecutor.errMap = &validationErrMaps{make(map[*gauge.Specification][]*stepValidationError), make(map[*gauge.Scenario][]*stepValidationError), make(map[*gauge.Step]*stepValidationError)}
	specExecutor.consoleReporter = reporter.Current()
	specExecutor.specResult = &result.SpecResult{}
	result := specExecutor.createSkippedSpecResult(fmt.Errorf("ERROR"))

	c.Assert(result.IsFailed, Equals, false)
	c.Assert(result.Skipped, Equals, true)

	c.Assert(len(specExecutor.errMap.specErrs[spec]), Equals, 1)
	c.Assert(specExecutor.errMap.specErrs[spec][0].Error(), Equals, "ERROR")
	c.Assert(specExecutor.errMap.specErrs[spec][0].fileName, Equals, "FILE")
	c.Assert(specExecutor.errMap.specErrs[spec][0].step.LineNo, Equals, 0)
	c.Assert(specExecutor.errMap.specErrs[spec][0].step.LineText, Equals, "SPEC_HEADING")
}
Beispiel #6
0
func (s *MySuite) TestCreateSkippedSpecResult(c *C) {
	spec := &gauge.Specification{Heading: &gauge.Heading{LineNo: 0, Value: "SPEC_HEADING"}, FileName: "FILE"}

	se := newSpecExecutor(spec, nil, nil, indexRange{start: 0, end: 0}, nil, nil)
	se.errMap = getValidationErrorMap()
	se.consoleReporter = reporter.Current()
	se.specResult = &result.SpecResult{}
	se.skipSpecForError(fmt.Errorf("ERROR"))

	c.Assert(se.specResult.IsFailed, Equals, false)
	c.Assert(se.specResult.Skipped, Equals, true)

	// c.Assert(len(se.errMap.SpecErrs[spec]), Equals, 1)
	// c.Assert(se.errMap.SpecErrs[spec][0].message, Equals, "ERROR")
	// c.Assert(se.errMap.SpecErrs[spec][0].fileName, Equals, "FILE")
	// c.Assert(se.errMap.SpecErrs[spec][0].step.LineNo, Equals, 0)
	// c.Assert(se.errMap.SpecErrs[spec][0].step.LineText, Equals, "SPEC_HEADING")
}
Beispiel #7
0
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 := &parallelInfo{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
}
Beispiel #8
0
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
}