Esempio n. 1
0
func (specInfoGatherer *SpecInfoGatherer) addSpec(fileName string) {
	logger.ApiLog.Info("Spec added/modified: %s", fileName)
	specs, parseResults := parser.ParseSpecFiles([]string{fileName}, specInfoGatherer.getDictionary())
	specInfoGatherer.handleParseFailures(parseResults)
	specInfoGatherer.addStepsForSpecs(specs)
	specInfoGatherer.updateAllStepsList()
}
Esempio n. 2
0
func (s *SpecInfoGatherer) getParsedSpecs(specFiles []string) []*gauge.Specification {
	if s.conceptDictionary == nil {
		s.conceptDictionary = gauge.NewConceptDictionary()
	}
	parsedSpecs, parseResults := parser.ParseSpecFiles(specFiles, s.conceptDictionary)
	s.handleParseFailures(parseResults)
	return parsedSpecs
}
Esempio n. 3
0
// Parse all specifications in the project and find all the steps
func (specInfoGatherer *SpecInfoGatherer) findAllStepsFromSpecs() {
	specFiles := util.FindSpecFilesIn(filepath.Join(config.ProjectRoot, common.SpecsDirectoryName))

	availableSpecs, parseResults := parser.ParseSpecFiles(specFiles, specInfoGatherer.getDictionary())
	specInfoGatherer.handleParseFailures(parseResults)

	specInfoGatherer.addStepsForSpecs(availableSpecs)
}
Esempio n. 4
0
func FormatSpecFiles(specFiles ...string) []*parser.ParseResult {
	specs, results := parser.ParseSpecFiles(specFiles, &parser.ConceptDictionary{})
	for i, spec := range specs {
		if err := formatAndSave(spec); err != nil {
			results[i].ParseError = &parser.ParseError{Message: err.Error()}
		}
	}
	return results
}
Esempio n. 5
0
func specsFromArgs(conceptDictionary *gauge.ConceptDictionary, specDirs []string) []*gauge.Specification {
	var allSpecs []*gauge.Specification
	var specs []*gauge.Specification
	var specParseResults []*parser.ParseResult
	for _, arg := range specDirs {
		specSource := arg
		if isIndexedSpec(specSource) {
			specs, specParseResults = getSpecWithScenarioIndex(specSource, conceptDictionary)
		} else {
			specs, specParseResults = parser.ParseSpecFiles(util.GetSpecFiles(specSource), conceptDictionary)
		}
		parser.HandleParseResult(specParseResults...)
		allSpecs = append(allSpecs, specs...)
	}
	return allSpecs
}
Esempio n. 6
0
func PerformRephraseRefactoring(oldStep, newStep string, startChan *runner.StartChannels, specDirs []string) *refactoringResult {
	defer killRunner(startChan)
	if newStep == oldStep {
		return &refactoringResult{Success: true}
	}
	agent, err := getRefactorAgent(oldStep, newStep, startChan)

	if err != nil {
		return rephraseFailure(err.Error())
	}

	result := &refactoringResult{Success: true, Errors: make([]string, 0), warnings: make([]string, 0)}

	var specs []*gauge.Specification
	var specParseResults []*parser.ParseResult

	for _, dir := range specDirs {
		specFiles := util.GetSpecFiles(filepath.Join(config.ProjectRoot, dir))
		specSlice, specParseResultsSlice := parser.ParseSpecFiles(specFiles, &gauge.ConceptDictionary{})
		specs = append(specs, specSlice...)
		specParseResults = append(specParseResults, specParseResultsSlice...)
	}

	addErrorsAndWarningsToRefactoringResult(result, specParseResults...)
	if !result.Success {
		return result
	}

	conceptDictionary, parseResult := parser.CreateConceptsDictionary(false, specDirs)

	addErrorsAndWarningsToRefactoringResult(result, parseResult)
	if !result.Success {
		return result
	}

	refactorResult := agent.performRefactoringOn(specs, conceptDictionary)
	refactorResult.warnings = append(refactorResult.warnings, result.warnings...)
	return refactorResult
}
Esempio n. 7
0
func getSpecWithScenarioIndex(specSource string, conceptDictionary *gauge.ConceptDictionary) ([]*gauge.Specification, []*parser.ParseResult) {
	specName, indexToFilter := GetIndexedSpecName(specSource)
	parsedSpecs, parseResult := parser.ParseSpecFiles(util.GetSpecFiles(specName), conceptDictionary)
	return filterSpecsItems(parsedSpecs, newScenarioIndexFilterToRetain(indexToFilter)), parseResult
}