Skip to content

Commit bfe6e75

Browse files
author
Sauyon Lee
committedApr 27, 2021
Evaluate symlinks for the dummy file
1 parent d09cb7f commit bfe6e75

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed
 

‎extractor/extractor.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -460,11 +460,17 @@ func (extraction *Extraction) extractError(tw *trap.Writer, err packages.Error,
460460

461461
if pos == "" {
462462
// extract a dummy file
463-
file, e = filepath.Abs(filepath.Join(".", "-"))
463+
wd, e := os.Getwd()
464464
if e != nil {
465-
file = filepath.Join(".", "-")
466-
log.Printf("Warning: failed to get absolute path for for %s", file)
465+
wd = "."
466+
log.Printf("Warning: failed to get working directory")
467+
}
468+
ewd, e := filepath.EvalSymlinks(wd)
469+
if e != nil {
470+
ewd = wd
471+
log.Printf("Warning: failed to evaluate symlinks for %s", wd)
467472
}
473+
file = filepath.Join(ewd, "-")
468474
} else {
469475
var rawfile string
470476
if parts := threePartPos.FindStringSubmatch(pos); parts != nil {
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
| ../Diagnostics:0:0:0:0 | malformed import path "github.com/github/codeql-go/ql/test/query-tests/Diagnostics/invalid{": invalid char '{' |
1+
| -:0:0:0:0 | malformed import path "github.com/github/codeql-go/ql/test/query-tests/Diagnostics/invalid{": invalid char '{' |
22
| bad.go:3:1:3:1 | expected 'package', found avvu |
33
| type.go:11:9:11:9 | cannot use v (variable of type V) as T value in argument to takesT |
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
| Extraction failed in query-tests/Diagnostics/type.go with error cannot use v (variable of type V) as T value in argument to takesT | 2 |
22
| Extraction failed with error expected 'package', found avvu | 2 |
3+
| Extraction failed with error malformed import path "github.com/github/codeql-go/ql/test/query-tests/Diagnostics/invalid{": invalid char '{' | 2 |

0 commit comments

Comments
 (0)
Please sign in to comment.