Documentation ¶
Overview ¶
Package parser parses all the specs in the list of directories given and also de-duplicates all specs passed through `specDirs` before parsing specs.
Gets all the specs files in the given directory and generates token for each spec file. While parsing a concept file, concepts are inlined i.e. concept in the spec file is replaced with steps that concept has in the concept file. While creating a specification file parser applies the converter functions. Parsing a spec file gives a specification with parseresult. ParseResult contains ParseErrors, CriticalErrors, Warnings and FileName Errors can be generated, While - Generating tokens - Applying converters - After Applying converters If a parse error is found in a spec, only that spec is ignored and others will continue execution. This doesn't invoke the language runner. Eg : Multiple spec headings found in same file. Scenario should be defined after the spec heading. Critical error : Circular reference of concepts - Doesn't parse specs becz it goes in recursion and crashes
Index ¶
- func ConvertToStepText(fragments []*gauge_messages.Fragment) string
- func CreateStepValue(step *gauge.Step) gauge.StepValue
- func ExtractStepArgsFromToken(stepToken *Token) ([]gauge.StepArg, error)
- func ExtractStepValueAndParams(stepText string, hasInlineTable bool) (*gauge.StepValue, error)
- func FilterTableRelatedScenarios(scenarios []*gauge.Scenario, fun func(*gauge.Scenario) bool) (otherScenarios, tableRelatedScenarios []*gauge.Scenario)
- func GetResolvedDataTablerows(table gauge.Table)
- func GetSpecsForDataTableRows(s []*gauge.Specification, errMap *gauge.BuildErrors) (specs []*gauge.Specification)
- func GetUnescapedString(string1 string) string
- func HandleParseResult(results ...*ParseResult) bool
- func ParseSpecs(args []string, conceptsDictionary *gauge.ConceptDictionary, ...) ([]*gauge.Specification, bool)
- func PopulateConceptDynamicParams(concept *gauge.Step, dataTableLookup *gauge.ArgLookup) error
- type ConceptParser
- type ParamResolver
- type ParseError
- type ParseResult
- func CreateConceptsDictionary() (*gauge.ConceptDictionary, *ParseResult, error)
- func CreateStepUsingLookup(stepToken *Token, lookup *gauge.ArgLookup, specFileName string) (*gauge.Step, *ParseResult)
- func ParseConcepts() (*gauge.ConceptDictionary, *ParseResult, error)
- func ParseSpecFiles(specFiles []string, conceptDictionary *gauge.ConceptDictionary, ...) ([]*gauge.Specification, []*ParseResult)
- func ValidateConcepts(conceptDictionary *gauge.ConceptDictionary) *ParseResult
- type SpecParser
- func (parser *SpecParser) CreateSpecification(tokens []*Token, conceptDictionary *gauge.ConceptDictionary, specFile string) (*gauge.Specification, *ParseResult, error)
- func (parser *SpecParser) GenerateTokens(specText, fileName string) ([]*Token, []ParseError)
- func (parser *SpecParser) Parse(specText string, conceptDictionary *gauge.ConceptDictionary, specFile string) (*gauge.Specification, *ParseResult, error)
- func (parser *SpecParser) ParseSpecText(specText string, specFile string) (*gauge.Specification, *ParseResult)
- type Token
- type Warning
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertToStepText ¶
func ConvertToStepText(fragments []*gauge_messages.Fragment) string
ConvertToStepText accumulates fragments of a step, (ex. parameters) and returns the step text used to generate the annotation text in a step implementation
func CreateStepValue ¶
CreateStepValue converts a Step to StepValue
func ExtractStepArgsFromToken ¶ added in v0.9.1
ExtractStepArgsFromToken extracts step args(Static and Dynamic) from the given step token.
func ExtractStepValueAndParams ¶
ExtractStepValueAndParams parses a stepText string into a StepValue struct
func FilterTableRelatedScenarios ¶ added in v0.8.5
func FilterTableRelatedScenarios(scenarios []*gauge.Scenario, fun func(*gauge.Scenario) bool) (otherScenarios, tableRelatedScenarios []*gauge.Scenario)
FilterTableRelatedScenarios filters Scenarios that are using dynamic params from data table.
func GetResolvedDataTablerows ¶ added in v1.0.1
GetResolvedDataTablerows resolves any dynamic parameters in a table cell
func GetSpecsForDataTableRows ¶ added in v0.8.4
func GetSpecsForDataTableRows(s []*gauge.Specification, errMap *gauge.BuildErrors) (specs []*gauge.Specification)
GetSpecsForDataTableRows creates a spec for each data table row
func GetUnescapedString ¶
GetUnescapedString uses the go escape sequences to escape control characters and non printable characters.
func HandleParseResult ¶
func HandleParseResult(results ...*ParseResult) bool
HandleParseResult collates list of parse result and determines if gauge has to break flow.
func ParseSpecs ¶ added in v0.6.2
func ParseSpecs(args []string, conceptsDictionary *gauge.ConceptDictionary, buildErrors *gauge.BuildErrors) ([]*gauge.Specification, bool)
ParseSpecs parses specs in the give directory and gives specification and pass/fail status, used in validation.
Types ¶
type ConceptParser ¶
type ConceptParser struct {
// contains filtered or unexported fields
}
ConceptParser is used for parsing concepts. Similar, but not the same as a SpecParser
func (*ConceptParser) Parse ¶
func (parser *ConceptParser) Parse(text, fileName string) ([]*gauge.Step, *ParseResult)
Parse Generates token for the given concept file and cretes concepts(array of steps) and parse results. concept file can have multiple concept headings.
func (*ConceptParser) ParseFile ¶ added in v0.1.8
func (parser *ConceptParser) ParseFile(file string) ([]*gauge.Step, *ParseResult)
ParseFile Reads file contents from a give file and parses the file.
type ParamResolver ¶
type ParamResolver struct { }
ParamResolver resolves dynamic parameters
func (*ParamResolver) GetResolvedParams ¶
func (paramResolver *ParamResolver) GetResolvedParams(step *gauge.Step, parent *gauge.Step, lookup *gauge.ArgLookup) ([]*gauge_messages.Parameter, error)
GetResolvedParams based on the arg type(static, dynamic, table, special_string, special_table) resolves the parameter of a step.
type ParseError ¶
ParseError holds information about a parse failure
func AddConcept ¶ added in v0.9.4
func AddConcept(concepts []*gauge.Step, file string, conceptDictionary *gauge.ConceptDictionary) ([]ParseError, error)
AddConcept adds the concept in the ConceptDictionary.
func AddConcepts ¶
func AddConcepts(conceptFiles []string, conceptDictionary *gauge.ConceptDictionary) ([]*gauge.Step, []ParseError, error)
AddConcepts parses the given concept file and adds each concept to the concept dictionary.
func (ParseError) Error ¶
func (se ParseError) Error() string
Error prints error with filename, line number, error message and step text.
type ParseResult ¶
type ParseResult struct { ParseErrors []ParseError Warnings []*Warning Ok bool FileName string }
ParseResult is a collection of parse errors and warnings in a file.
func CreateConceptsDictionary ¶
func CreateConceptsDictionary() (*gauge.ConceptDictionary, *ParseResult, error)
CreateConceptsDictionary generates a ConceptDictionary which is map of concept text to concept. ConceptDictionary is used to search for a concept.
func CreateStepUsingLookup ¶ added in v0.3.2
func CreateStepUsingLookup(stepToken *Token, lookup *gauge.ArgLookup, specFileName string) (*gauge.Step, *ParseResult)
CreateStepUsingLookup generates gauge steps from step token and args lookup.
func ParseConcepts ¶ added in v0.6.2
func ParseConcepts() (*gauge.ConceptDictionary, *ParseResult, error)
ParseConcepts creates concept dictionary and concept parse result.
func ParseSpecFiles ¶
func ParseSpecFiles(specFiles []string, conceptDictionary *gauge.ConceptDictionary, buildErrors *gauge.BuildErrors) ([]*gauge.Specification, []*ParseResult)
ParseSpecFiles gets all the spec files and parse each spec file. Generates specifications and parse results. TODO: Use single channel instead of one for spec and another for result, so that mapping is consistent
func ValidateConcepts ¶ added in v0.9.4
func ValidateConcepts(conceptDictionary *gauge.ConceptDictionary) *ParseResult
ValidateConcepts ensures that there are no circular references within
func (*ParseResult) Errors ¶ added in v0.5.0
func (result *ParseResult) Errors() (errors []string)
Errors Prints parse errors and critical errors.
type SpecParser ¶
type SpecParser struct {
// contains filtered or unexported fields
}
SpecParser is responsible for parsing a Specification. It delegates to respective processors composed sub-entities
func (*SpecParser) CreateSpecification ¶
func (parser *SpecParser) CreateSpecification(tokens []*Token, conceptDictionary *gauge.ConceptDictionary, specFile string) (*gauge.Specification, *ParseResult, error)
CreateSpecification creates specification from the given set of tokens.
func (*SpecParser) GenerateTokens ¶
func (parser *SpecParser) GenerateTokens(specText, fileName string) ([]*Token, []ParseError)
GenerateTokens generates tokens based on the parsed line.
func (*SpecParser) Parse ¶
func (parser *SpecParser) Parse(specText string, conceptDictionary *gauge.ConceptDictionary, specFile string) (*gauge.Specification, *ParseResult, error)
Parse generates tokens for the given spec text and creates the specification.
func (*SpecParser) ParseSpecText ¶ added in v0.9.4
func (parser *SpecParser) ParseSpecText(specText string, specFile string) (*gauge.Specification, *ParseResult)
ParseSpecText without validating and replacing concepts.