Skip to content

Commit c5d0b5e

Browse files
Merge branch 'getgauge:master' into master
2 parents 4be8b70 + bc05ae1 commit c5d0b5e

35 files changed

+314
-1023
lines changed

.github/dependabot.yml

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,36 @@
11
version: 2
22
updates:
3-
- package-ecosystem: gomod
4-
directory: "/"
5-
schedule:
6-
interval: weekly
7-
allow:
8-
- dependency-type: all
9-
- package-ecosystem: "github-actions"
10-
directory: "/"
11-
schedule:
12-
interval: weekly
13-
groups:
14-
github-actions:
15-
patterns:
16-
- "*"
17-
- package-ecosystem: npm
18-
directory: "/build/npm"
19-
schedule:
20-
interval: weekly
21-
groups:
22-
build-npm:
23-
patterns:
24-
- "*"
25-
- package-ecosystem: pip
26-
directory: "build/pip"
27-
schedule:
28-
interval: weekly
29-
groups:
30-
build-python:
31-
patterns:
32-
- "*"
3+
- package-ecosystem: gomod
4+
directory: "/"
5+
schedule:
6+
interval: monthly
7+
allow:
8+
- dependency-type: all
9+
groups:
10+
go:
11+
patterns:
12+
- "*"
13+
- package-ecosystem: "github-actions"
14+
directory: "/"
15+
schedule:
16+
interval: monthly
17+
groups:
18+
github-actions:
19+
patterns:
20+
- "*"
21+
- package-ecosystem: npm
22+
directory: "/build/npm"
23+
schedule:
24+
interval: monthly
25+
groups:
26+
build-npm:
27+
patterns:
28+
- "*"
29+
- package-ecosystem: pip
30+
directory: "build/pip"
31+
schedule:
32+
interval: monthly
33+
groups:
34+
build-python:
35+
patterns:
36+
- "*"

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ jobs:
178178

179179
- uses: actions/setup-node@v4
180180
with:
181-
node-version: 20
181+
node-version: 22
182182
cache: 'npm'
183183
cache-dependency-path: 'build/npm/package-lock.json'
184184
registry-url: 'https://registry.npmjs.org'

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
- name: Set up Nodejs
4545
uses: actions/setup-node@v4
4646
with:
47-
node-version: 20
47+
node-version: 22
4848
cache: 'npm'
4949
cache-dependency-path: 'build/npm/package-lock.json'
5050

api/lang/diagnostics_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Scenario Heading
6969
Start: lsp.Position{Line: 0, Character: 0},
7070
End: lsp.Position{Line: 1, Character: 21},
7171
},
72-
Message: "Spec should have atleast one scenario",
72+
Message: "Spec should have at least one scenario",
7373
Severity: 1,
7474
},
7575
{
@@ -163,7 +163,7 @@ func TestDiagnosticsForConceptParseErrors(t *testing.T) {
163163
Start: lsp.Position{Line: 0, Character: 0},
164164
End: lsp.Position{Line: 0, Character: 9},
165165
},
166-
Message: "Concept should have atleast one step",
166+
Message: "Concept should have at least one step",
167167
Severity: 1,
168168
},
169169
}

api/lang/format.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,30 @@ func format(request *jsonrpc2.Request) (interface{}, error) {
3232
return nil, err
3333
}
3434
if !parseResult.Ok {
35-
return nil, fmt.Errorf("failed to format document. Fix all the problems first")
35+
return nil, fmt.Errorf("failed to format %s. Fix all the problems first", file)
3636
}
3737
newString := formatter.FormatSpecification(spec)
3838
oldString := getContent(params.TextDocument.URI)
3939
textEdit := createTextEdit(newString, 0, 0, len(strings.Split(oldString, "\n")), len(oldString))
4040
return []lsp.TextEdit{textEdit}, nil
4141
} else if util.IsValidConceptExtension(file) {
4242
conceptsDictionary := gauge.NewConceptDictionary()
43-
_, parseErrs, err := parser.AddConcepts([]string{file}, conceptsDictionary)
43+
conceptSteps, parseResult := new(parser.ConceptParser).Parse(getContent(params.TextDocument.URI), file)
44+
if !parseResult.Ok {
45+
return nil, fmt.Errorf("failed to format %s. Fix all the problems first", file)
46+
}
47+
parseErrs, err := parser.AddConcept(conceptSteps, file, conceptsDictionary)
4448
if err != nil {
4549
return nil, err
4650
}
47-
if parseErrs != nil {
48-
return nil, fmt.Errorf("failed to format document. Fix all the problems first")
51+
if len(parseErrs) > 0 {
52+
return nil, fmt.Errorf("failed to format %s. Fix all the problems first", file)
4953
}
5054
conceptMap := formatter.FormatConcepts(conceptsDictionary)
5155
newString := conceptMap[file]
5256
oldString := getContent(params.TextDocument.URI)
5357
textEdit := createTextEdit(newString, 0, 0, len(strings.Split(oldString, "\n")), len(oldString))
5458
return []lsp.TextEdit{textEdit}, nil
5559
}
56-
return nil, fmt.Errorf("failed to format document. %s is not a valid spec/cpt file", file)
60+
return nil, fmt.Errorf("failed to format %s. Not a valid spec/cpt file", file)
5761
}

api/lang/format_test.go

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"github.com/sourcegraph/jsonrpc2"
1818
)
1919

20-
func TestFormat(t *testing.T) {
20+
func TestSpecFormat(t *testing.T) {
2121
specText := `# Specification Heading
2222
2323
## Scenario Heading
@@ -50,7 +50,7 @@ func TestFormat(t *testing.T) {
5050
}
5151
}
5252

53-
func TestFormatParseError(t *testing.T) {
53+
func TestSpecFormatParseError(t *testing.T) {
5454
specText := `Specification Heading
5555
=====================
5656
@@ -67,7 +67,7 @@ func TestFormatParseError(t *testing.T) {
6767
b, _ := json.Marshal(lsp.DocumentFormattingParams{TextDocument: lsp.TextDocumentIdentifier{URI: specFile}, Options: lsp.FormattingOptions{}})
6868
p := json.RawMessage(b)
6969

70-
expectedError := fmt.Errorf("failed to format document. Fix all the problems first")
70+
expectedError := fmt.Errorf("failed to format foo.spec. Fix all the problems first")
7171

7272
data, err := format(&jsonrpc2.Request{Params: &p})
7373
if data != nil {
@@ -76,5 +76,58 @@ func TestFormatParseError(t *testing.T) {
7676
if err.Error() != expectedError.Error() {
7777
t.Fatalf(" want : %s\ngot : %s", expectedError.Error(), err.Error())
7878
}
79+
}
80+
81+
func TestConceptFormat(t *testing.T) {
82+
conceptText := `# Concept Scenario Heading
83+
84+
* Step text`
85+
86+
openFilesCache = &files{cache: make(map[lsp.DocumentURI][]string)}
87+
openFilesCache.add("foo.cpt", conceptText)
88+
89+
want := []lsp.TextEdit{
90+
{
91+
Range: lsp.Range{
92+
Start: lsp.Position{Line: 0, Character: 0},
93+
End: lsp.Position{Line: 3, Character: 39},
94+
},
95+
NewText: conceptText + "\n",
96+
},
97+
}
98+
99+
b, _ := json.Marshal(lsp.DocumentFormattingParams{TextDocument: lsp.TextDocumentIdentifier{URI: "foo.cpt"}, Options: lsp.FormattingOptions{}})
100+
p := json.RawMessage(b)
101+
102+
got, err := format(&jsonrpc2.Request{Params: &p})
103+
if err != nil {
104+
t.Fatalf("Expected error == nil in format, got %s", err.Error())
105+
}
79106

107+
if !reflect.DeepEqual(got, want) {
108+
t.Errorf("format failed, want: `%v`, got: `%v`", want, got)
109+
}
110+
}
111+
112+
func TestConceptFormatParseError(t *testing.T) {
113+
conceptText := `Concept Scenario Heading
114+
* Step text`
115+
116+
openFilesCache = &files{cache: make(map[lsp.DocumentURI][]string)}
117+
openFilesCache.add("foo.cpt", conceptText)
118+
119+
conceptFile := lsp.DocumentURI("foo.cpt")
120+
121+
b, _ := json.Marshal(lsp.DocumentFormattingParams{TextDocument: lsp.TextDocumentIdentifier{URI: conceptFile}, Options: lsp.FormattingOptions{}})
122+
p := json.RawMessage(b)
123+
124+
expectedError := fmt.Errorf("failed to format foo.cpt. Fix all the problems first")
125+
126+
data, err := format(&jsonrpc2.Request{Params: &p})
127+
if data != nil {
128+
t.Fatalf("Expected data == nil in format, got %s", data)
129+
}
130+
if err.Error() != expectedError.Error() {
131+
t.Fatalf(" want : %s\ngot : %s", expectedError.Error(), err.Error())
132+
}
80133
}

build/README.md

Lines changed: 0 additions & 44 deletions
This file was deleted.

build/make.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ const (
3636
bin = "bin"
3737
gauge = "gauge"
3838
deploy = "deploy"
39-
CC = "CC"
4039
nightlyDatelayout = "2006-01-02"
4140
)
4241

@@ -159,8 +158,8 @@ var (
159158
{GOARCH: ARM64, GOOS: linux, CGO_ENABLED: "0"},
160159
{GOARCH: X86, GOOS: freebsd, CGO_ENABLED: "0"},
161160
{GOARCH: X86_64, GOOS: freebsd, CGO_ENABLED: "0"},
162-
{GOARCH: X86, GOOS: windows, CC: "i586-mingw32-gcc", CGO_ENABLED: "1"},
163-
{GOARCH: X86_64, GOOS: windows, CC: "x86_64-w64-mingw32-gcc", CGO_ENABLED: "1"},
161+
{GOARCH: X86, GOOS: windows, CGO_ENABLED: "0"},
162+
{GOARCH: X86_64, GOOS: windows, CGO_ENABLED: "0"},
164163
}
165164
osDistroMap = map[string]distroFunc{windows: createWindowsDistro, linux: createLinuxPackage, freebsd: createLinuxPackage, darwin: createDarwinPackage}
166165
)

0 commit comments

Comments
 (0)