Skip to content

Commit

Permalink
Merge 1c3daee into 4964ec7
Browse files Browse the repository at this point in the history
  • Loading branch information
sriv authored Nov 30, 2020
2 parents 4964ec7 + 1c3daee commit 9d74fa0
Show file tree
Hide file tree
Showing 23 changed files with 77 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
run: |
cd gauge
go run build/make.go && go run build/make.go --install --prefix=/tmp/gauge --verbose
echo "::add-path::/tmp/gauge/bin"
echo "/tmp/gauge/bin" >> $GITHUB_PATH
- name: Install gauge-java
run: gauge install java
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
- v*
branches:
- master
- main
pull_request:
jobs:
golangci:
Expand All @@ -13,16 +14,16 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v1
uses: golangci/golangci-lint-action@v2
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.26
version: v1.29

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true
# only-new-issues: true
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
Expand-Archive -Force -LiteralPath ./nsis.zip -DestinationPath "C:\Program Files (x86)\NSIS\"
echo "::add-path::C:\Program Files (x86)\Windows kits\10\App Certification Kit\"
[IO.File]::WriteAllBytes('.\cert.p12', [Convert]::FromBase64String($Env:SIGNING_CERT))
echo "::set-env name=CERT_FILE::$Env:GITHUB_WORKSPACE/cert.p12"
echo "CERT_FILE=$Env:GITHUB_WORKSPACE/cert.p12" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Compile gauge
run: |
Expand Down Expand Up @@ -146,7 +146,7 @@ jobs:
path: .

- name: Set gauge version
run: echo "::set-env name=GAUGE_VERSION::`cat version.txt`"
run: echo "GAUGE_VERSION=`cat version.txt`" >> $GITHUB_ENV

- name: Deploy to pypi
env:
Expand Down Expand Up @@ -180,7 +180,7 @@ jobs:
path: .

- name: Set gauge version
run: echo "::set-env name=GAUGE_VERSION::`cat version.txt`"
run: echo "GAUGE_VERSION=`cat version.txt`" >> $GITHUB_ENV

- name: Setup Git User
run: |
Expand Down Expand Up @@ -267,7 +267,7 @@ jobs:
path: .

- name: Set gauge version
run: echo "::set-env name=GAUGE_VERSION::`cat version.txt`"
run: echo "GAUGE_VERSION=`cat version.txt`" >> $GITHUB_ENV
shell: bash

- name: Clone chocolatey-packages
Expand Down Expand Up @@ -306,7 +306,7 @@ jobs:
path: .

- name: Set gauge version
run: echo "::set-env name=GAUGE_VERSION::`cat version.txt`"
run: echo "GAUGE_VERSION=`cat version.txt`" >> $GITHUB_ENV

- name: Update brew formula
env:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ jobs:
if: matrix.os == 'windows-latest'
run: |
go run build/make.go --install --verbose
echo "::add-path::C:\\Program Files\\gauge\\bin"
echo "C:\\Program Files\\gauge\\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Install Gauge (linux)
if: matrix.os != 'windows-latest'
run: |
go run build/make.go --install --prefix=/tmp/gauge --verbose
echo "::add-path::/tmp/gauge/bin"
echo "/tmp/gauge/bin" >> $GITHUB_PATH
- name: Add js_simple template
run: |
Expand Down Expand Up @@ -125,13 +125,13 @@ jobs:
if: matrix.os == 'windows-latest'
run: |
go run build/make.go --install --verbose
echo "::add-path::C:\\Program Files\\gauge\\bin"
echo "C:\\Program Files\\gauge\\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Install Gauge (linux)
if: matrix.os != 'windows-latest'
run: |
go run build/make.go --install --prefix=/tmp/gauge --verbose
echo "::add-path::/tmp/gauge/bin"
echo "/tmp/gauge/bin" >> $GITHUB_PATH
- name: Add js_simple template
run: |
Expand Down Expand Up @@ -258,7 +258,7 @@ jobs:
run: |
cd gauge
go run build/make.go && go run build/make.go --install --prefix=/tmp/gauge --verbose
echo "::add-path::/tmp/gauge/bin"
echo "/tmp/gauge/bin" >> $GITHUB_PATH
- name: Install gauge-java
run: gauge install java
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func printJSONVersion() {
}
// logger can not be used, since it breaks the json format,
// The logger adds out, nessage as key which vscode plugin does not understand.
fmt.Println(fmt.Sprintf("%s\n", string(b)))
fmt.Printf("%s\n\n", string(b))
}

func printTextVersion() {
Expand Down
8 changes: 4 additions & 4 deletions execution/specExecutor.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (e *specExecutor) execute(executeBefore, execute, executeAfter bool) *resul
if err != nil {
logger.Fatalf(true, "Failed to resolve Specifications : %s", err.Error())
}
e.specResult.AddTableDrivenScenarioResult(r, gauge.ConvertToProtoTable(&s.DataTable.Table),
e.specResult.AddTableDrivenScenarioResult(r, gauge.ConvertToProtoTable(s.DataTable.Table),
s.ScenarioDataTableRowIndex, s.SpecDataTableRowIndex, s.SpecDataTableRow.IsInitialized())
}
e.specResult.ScenarioCount += len(scnMap)
Expand Down Expand Up @@ -259,7 +259,7 @@ func (e *specExecutor) getItemsForScenarioExecution(steps []*gauge.Step) ([]*gau

func (e *specExecutor) dataTableLookup() (*gauge.ArgLookup, error) {
l := new(gauge.ArgLookup)
err := l.ReadDataTableRow(&e.specification.DataTable.Table, 0)
err := l.ReadDataTableRow(e.specification.DataTable.Table, 0)
return l, err
}

Expand Down Expand Up @@ -303,7 +303,7 @@ func (e *specExecutor) executeScenario(scenario *gauge.Scenario) (*result.Scenar
ProtoScenario: gauge.NewProtoScenario(scenario),
ScenarioDataTableRow: gauge.ConvertToProtoTable(&scenario.ScenarioDataTableRow),
ScenarioDataTableRowIndex: scenario.ScenarioDataTableRowIndex,
ScenarioDataTable: gauge.ConvertToProtoTable(&scenario.DataTable.Table),
ScenarioDataTable: gauge.ConvertToProtoTable(scenario.DataTable.Table),
}
if err := e.addAllItemsForScenarioExecution(scenario, scenarioResult); err != nil {
return nil, err
Expand Down Expand Up @@ -338,7 +338,7 @@ func (e *specExecutor) addAllItemsForScenarioExecution(scenario *gauge.Scenario,
return err
}
if scenario.ScenarioDataTableRow.IsInitialized() {
parser.GetResolvedDataTablerows(scenario.ScenarioDataTableRow)
parser.GetResolvedDataTablerows(&scenario.ScenarioDataTableRow)
if err = lookup.ReadDataTableRow(&scenario.ScenarioDataTableRow, 0); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion formatter/formatSpecification.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (formatter *formatter) Table(table *gauge.Table) {

func (formatter *formatter) DataTable(dataTable *gauge.DataTable) {
if !dataTable.IsExternal {
formatter.Table(&(dataTable.Table))
formatter.Table(dataTable.Table)
} else {
formatter.buffer.WriteString(formatExternalDataTable(dataTable))
}
Expand Down
2 changes: 1 addition & 1 deletion formatter/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func formatItem(item gauge.Item) string {
return FormatStep(step)
case gauge.DataTableKind:
dataTable := item.(*gauge.DataTable)
return FormatTable(&dataTable.Table)
return FormatTable(dataTable.Table)
case gauge.TagKind:
tags := item.(*gauge.Tags)
return FormatTags(tags)
Expand Down
5 changes: 4 additions & 1 deletion gauge/protoConverters.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func convertToProtoCommentItem(comment *Comment) *gauge_messages.ProtoItem {
}

func convertToProtoDataTableItem(dataTable *DataTable) *gauge_messages.ProtoItem {
return &gauge_messages.ProtoItem{ItemType: gauge_messages.ProtoItem_Table, Table: ConvertToProtoTable(&dataTable.Table)}
return &gauge_messages.ProtoItem{ItemType: gauge_messages.ProtoItem_Table, Table: ConvertToProtoTable(dataTable.Table)}
}

func convertToProtoParameter(arg *StepArg) *gauge_messages.Parameter {
Expand All @@ -149,6 +149,9 @@ func convertToProtoParameter(arg *StepArg) *gauge_messages.Parameter {
}

func ConvertToProtoTable(table *Table) *gauge_messages.ProtoTable {
if table == nil {
return nil
}
protoTableParam := &gauge_messages.ProtoTable{Rows: make([]*gauge_messages.ProtoTableRow, 0)}
protoTableParam.Headers = &gauge_messages.ProtoTableRow{Cells: table.Headers}
for _, row := range table.Rows() {
Expand Down
2 changes: 1 addition & 1 deletion gauge/protoConverters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (s *MySuite) TestConvertToProtoSpecWithDataTable(c *C) {
Value: "Spec Heading",
},
FileName: "example.spec",
DataTable: DataTable{Table: Table{headerIndexMap: make(map[string]int)}},
DataTable: DataTable{Table: &Table{headerIndexMap: make(map[string]int)}},
}
protoSpec := ConvertToProtoSpec(spec)

Expand Down
2 changes: 1 addition & 1 deletion gauge/scenario.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (scenario *Scenario) AddComment(comment *Comment) {
}

func (scenario *Scenario) AddDataTable(table *Table) {
scenario.DataTable.Table = *table
scenario.DataTable.Table = table
scenario.AddItem(&scenario.DataTable)
}

Expand Down
2 changes: 1 addition & 1 deletion gauge/specification.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (spec *Specification) AddComment(comment *Comment) {
}

func (spec *Specification) AddDataTable(table *Table) {
spec.DataTable.Table = *table
spec.DataTable.Table = table
spec.AddItem(&spec.DataTable)
}

Expand Down
6 changes: 3 additions & 3 deletions gauge/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Table struct {
}

type DataTable struct {
Table Table
Table *Table
Value string
LineNo int
IsExternal bool
Expand All @@ -42,7 +42,7 @@ func NewTable(headers []string, cols [][]TableCell, lineNo int) *Table {
}

func (table *Table) IsInitialized() bool {
return table.headerIndexMap != nil
return table != nil && table.headerIndexMap != nil
}

func (cell *TableCell) GetValue() string {
Expand All @@ -54,7 +54,7 @@ func (cell *TableCell) GetValue() string {
}

func (dataTable *DataTable) IsInitialized() bool {
return dataTable.Table.headerIndexMap != nil
return dataTable.Table != nil && dataTable.Table.headerIndexMap != nil
}

func (table *Table) String() string {
Expand Down
2 changes: 1 addition & 1 deletion logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func addFatalError(module, msg string) {
func getPluginVersions() string {
pis, err := pluginInfo.GetAllInstalledPluginsWithVersion()
if err != nil {
return fmt.Sprintf("Could not retrieve plugin information.")
return "Could not retrieve plugin information."
}
pluginVersions := make([]string, 0)
for _, pi := range pis {
Expand Down
14 changes: 7 additions & 7 deletions parser/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (parser *SpecParser) initializeConverters() []func(*Token, *int, *gauge.Spe
scn := spec.LatestScenario()
if !scn.DataTable.IsInitialized() && env.AllowScenarioDatatable() {
externalTable := &gauge.DataTable{}
externalTable.Table = resolvedArg.Table
externalTable.Table = &resolvedArg.Table
externalTable.LineNo = token.LineNo
externalTable.Value = token.Value
externalTable.IsExternal = true
Expand All @@ -159,7 +159,7 @@ func (parser *SpecParser) initializeConverters() []func(*Token, *int, *gauge.Spe
}
} else if isInState(*state, specScope) && !spec.DataTable.IsInitialized() {
externalTable := &gauge.DataTable{}
externalTable.Table = resolvedArg.Table
externalTable.Table = &resolvedArg.Table
externalTable.LineNo = token.LineNo
externalTable.Value = token.Value
externalTable.IsExternal = true
Expand Down Expand Up @@ -240,19 +240,19 @@ func (parser *SpecParser) initializeConverters() []func(*Token, *int, *gauge.Spe
result = ParseResult{Ok: true}
} else if isInState(*state, stepScope) {
latestScenario := spec.LatestScenario()
tables := []*gauge.Table{&spec.DataTable.Table}
tables := []*gauge.Table{spec.DataTable.Table}
if latestScenario.DataTable.IsInitialized() {
tables = append(tables, &latestScenario.DataTable.Table)
tables = append(tables, latestScenario.DataTable.Table)
}
latestStep := latestScenario.LatestStep()
result = addInlineTableRow(latestStep, token, new(gauge.ArgLookup).FromDataTables(tables...), spec.FileName)
} else if isInState(*state, contextScope) {
latestContext := spec.LatestContext()
result = addInlineTableRow(latestContext, token, new(gauge.ArgLookup).FromDataTables(&spec.DataTable.Table), spec.FileName)
result = addInlineTableRow(latestContext, token, new(gauge.ArgLookup).FromDataTables(spec.DataTable.Table), spec.FileName)
} else if isInState(*state, tearDownScope) {
if len(spec.TearDownSteps) > 0 {
latestTeardown := spec.LatestTeardown()
result = addInlineTableRow(latestTeardown, token, new(gauge.ArgLookup).FromDataTables(&spec.DataTable.Table), spec.FileName)
result = addInlineTableRow(latestTeardown, token, new(gauge.ArgLookup).FromDataTables(spec.DataTable.Table), spec.FileName)
} else {
spec.AddComment(&gauge.Comment{Value: token.LineText(), LineNo: token.LineNo})
}
Expand All @@ -262,7 +262,7 @@ func (parser *SpecParser) initializeConverters() []func(*Token, *int, *gauge.Spe
t = spec.LatestScenario().DataTable
}

tableValues, warnings, err := validateTableRows(token, new(gauge.ArgLookup).FromDataTables(&t.Table), spec.FileName)
tableValues, warnings, err := validateTableRows(token, new(gauge.ArgLookup).FromDataTables(t.Table), spec.FileName)
if len(err) > 0 {
result = ParseResult{Ok: false, Warnings: warnings, ParseErrors: err}
} else {
Expand Down
4 changes: 2 additions & 2 deletions parser/dataTableSpecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func createSpecsForTableRows(spec *gauge.Specification, scns []*gauge.Scenario,
}

func createSpec(scns []*gauge.Scenario, table *gauge.Table, spec *gauge.Specification, errMap *gauge.BuildErrors) *gauge.Specification {
dt := &gauge.DataTable{Table: *table, Value: spec.DataTable.Value, LineNo: spec.DataTable.LineNo, IsExternal: spec.DataTable.IsExternal}
dt := &gauge.DataTable{Table: table, Value: spec.DataTable.Value, LineNo: spec.DataTable.LineNo, IsExternal: spec.DataTable.IsExternal}
s := &gauge.Specification{DataTable: *dt, FileName: spec.FileName, Heading: spec.Heading, Scenarios: scns, Contexts: spec.Contexts, TearDownSteps: spec.TearDownSteps, Tags: spec.Tags}
index := 0
for _, item := range spec.Items {
Expand Down Expand Up @@ -107,7 +107,7 @@ func copyScenarios(scenarios []*gauge.Scenario, table gauge.Table, i int, errMap
return
}

func getTableWithOneRow(t gauge.Table, i int) *gauge.Table {
func getTableWithOneRow(t *gauge.Table, i int) *gauge.Table {
var row [][]gauge.TableCell
for _, c := range t.Columns {
row = append(row, []gauge.TableCell{c[i]})
Expand Down
Loading

0 comments on commit 9d74fa0

Please # to comment.