Evaluate symlinks for the dummy file

This commit is contained in:
Sauyon Lee
2021-04-27 08:28:56 -07:00
parent d09cb7f228
commit bfe6e7510d
3 changed files with 11 additions and 4 deletions

View File

@@ -460,11 +460,17 @@ func (extraction *Extraction) extractError(tw *trap.Writer, err packages.Error,
if pos == "" {
// extract a dummy file
file, e = filepath.Abs(filepath.Join(".", "-"))
wd, e := os.Getwd()
if e != nil {
file = filepath.Join(".", "-")
log.Printf("Warning: failed to get absolute path for for %s", file)
wd = "."
log.Printf("Warning: failed to get working directory")
}
ewd, e := filepath.EvalSymlinks(wd)
if e != nil {
ewd = wd
log.Printf("Warning: failed to evaluate symlinks for %s", wd)
}
file = filepath.Join(ewd, "-")
} else {
var rawfile string
if parts := threePartPos.FindStringSubmatch(pos); parts != nil {

View File

@@ -1,3 +1,3 @@
| ../Diagnostics:0:0:0:0 | malformed import path "github.com/github/codeql-go/ql/test/query-tests/Diagnostics/invalid{": invalid char '{' |
| -:0:0:0:0 | malformed import path "github.com/github/codeql-go/ql/test/query-tests/Diagnostics/invalid{": invalid char '{' |
| bad.go:3:1:3:1 | expected 'package', found avvu |
| type.go:11:9:11:9 | cannot use v (variable of type V) as T value in argument to takesT |

View File

@@ -1,2 +1,3 @@
| 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 |
| Extraction failed with error expected 'package', found avvu | 2 |
| Extraction failed with error malformed import path "github.com/github/codeql-go/ql/test/query-tests/Diagnostics/invalid{": invalid char '{' | 2 |