Skip to content

Commit c940c28

Browse files
authored
Merge pull request #449 from carlosms/297-workaround
srcd parse: do not check the list of languages
2 parents f1a2335 + 1f158ea commit c940c28

File tree

3 files changed

+37
-26
lines changed

3 files changed

+37
-26
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@
3232

3333
- The commands fail gracefully if an incompatible Docker installation is found, such as Docker Toolbox ([#417](https://github.com/src-d/engine/issues/417)).
3434

35+
### Known Issues
36+
37+
- [#297](https://github.com/src-d/engine/issues/297): `srcd parse` does not detect the language automatically for bash files. For this language you will need to set `--lang` manually. For example:
38+
```
39+
$ srcd parse uast file.bash --lang bash
40+
```
41+
3542
</details>
3643

3744
## [v0.12.0](https://github.com/src-d/engine/releases/tag/v0.12.0) - 2019-04-04

cmd/srcd/cmd/parse.go

+13-15
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ func (cmd *parseUASTCmd) Execute(args []string) error {
7878
}
7979

8080
lang := cmd.Lang
81-
var resp *api.ListDriversResponse
82-
8381
if lang == "" {
8482
lang, err = parseLang(ctx, c, cmd.Args.Path, b)
8583
started()
@@ -89,21 +87,10 @@ func (cmd *parseUASTCmd) Execute(args []string) error {
8987
}
9088

9189
log.Infof("detected language: %s", lang)
92-
resp, err = c.ListDrivers(ctx, &api.ListDriversRequest{})
9390
} else {
94-
resp, err = c.ListDrivers(ctx, &api.ListDriversRequest{})
9591
started()
9692
}
9793

98-
if err != nil {
99-
return humanizef(err, "could not list drivers")
100-
}
101-
102-
err = checkSupportedLanguage(resp.Drivers, lang)
103-
if err != nil {
104-
return err
105-
}
106-
10794
stream, err := c.ParseWithLogs(ctx, &api.ParseRequest{
10895
Kind: api.ParseRequest_UAST,
10996
Name: cmd.Args.Path,
@@ -123,6 +110,12 @@ func (cmd *parseUASTCmd) Execute(args []string) error {
123110
}
124111

125112
if err != nil {
113+
if strings.Contains(err.Error(), "missing driver for language") {
114+
if err := checkSupportedLanguage(ctx, c, lang); err != nil {
115+
return err
116+
}
117+
}
118+
126119
return humanizef(err, "could not stream")
127120
}
128121

@@ -211,10 +204,15 @@ func parseLang(ctx context.Context, client api.EngineClient, path string, b []by
211204
return res.Lang, nil
212205
}
213206

214-
func checkSupportedLanguage(supportedDrivers []*api.ListDriversResponse_DriverInfo, desired string) error {
207+
func checkSupportedLanguage(ctx context.Context, c api.EngineClient, desired string) error {
208+
resp, errList := c.ListDrivers(ctx, &api.ListDriversRequest{})
209+
if errList != nil {
210+
return humanizef(errList, "could not list drivers")
211+
}
212+
215213
var langs []string
216214
isSupported := false
217-
for _, driver := range supportedDrivers {
215+
for _, driver := range resp.Drivers {
218216
langs = append(langs, driver.Lang)
219217
if driver.Lang == desired {
220218
isSupported = true

cmdtests/parse_test.go

+17-11
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,14 @@ var testCases = []testCase{
4242
filename: "hello-py3.py",
4343
lang: "python",
4444
},
45-
{
46-
path: filepath.FromSlash("testdata/hello.cpp"),
47-
filename: "hello.cpp",
48-
lang: "c++",
49-
},
45+
// Disabled cpp parsing, see https://github.com/bblfsh/cpp-driver/issues/31
46+
/*
47+
{
48+
path: filepath.FromSlash("testdata/hello.cpp"),
49+
filename: "hello.cpp",
50+
lang: "c++",
51+
},
52+
*/
5053
{
5154
path: filepath.FromSlash("testdata/hello.java"),
5255
filename: "hello.java",
@@ -72,11 +75,14 @@ var testCases = []testCase{
7275
filename: "hello.go",
7376
lang: "go",
7477
},
75-
{
76-
path: filepath.FromSlash("testdata/hello.cs"),
77-
filename: "hello.cs",
78-
lang: "c#",
79-
},
78+
// Disabled csharp parsing, see https://github.com/bblfsh/bblfshd/issues/259
79+
/*
80+
{
81+
path: filepath.FromSlash("testdata/hello.cs"),
82+
filename: "hello.cs",
83+
lang: "c#",
84+
},
85+
*/
8086
{
8187
path: filepath.FromSlash("testdata/hello.php"),
8288
filename: "hello.php",
@@ -177,7 +183,7 @@ func (s *ParseTestSuite) TestUast() {
177183
// ----------------
178184
// TODO Temporary test skip, it fails for cpp, bash, and csharp.
179185
// See https://github.com/src-d/engine/issues/297
180-
if tc.lang == "c++" || tc.lang == "shell" || tc.lang == "c#" {
186+
if tc.lang == "shell" {
181187
// This Error assertion will fail when #297 is fixed, to remind us to remove this skip
182188
require.Error(r.Error)
183189
t.Skip("TEST FAILURE IS A KNOWN ISSUE (#297): " + r.Stdout())

0 commit comments

Comments
 (0)