Exemplo n.º 1
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
}
Exemplo n.º 2
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
}
Exemplo n.º 3
0
func FindSpecs(specSource string, conceptDictionary *ConceptDictionary) ([]*Specification, []*ParseResult) {
	specFiles := util.GetSpecFiles(specSource)

	return ParseSpecFiles(specFiles, conceptDictionary)
}
Exemplo n.º 4
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
}
Exemplo n.º 5
0
func FormatSpecFilesIn(filesLocation string) {
	specFiles := util.GetSpecFiles(filesLocation)
	parseResults := FormatSpecFiles(specFiles...)
	parser.HandleParseResult(parseResults...)
}