internal/lsp: better handling of .in files
This walks the list produced by the MustCopyFileTree call instead of scanning the file system It also removes the .in file from the copies, so only the trimmed version will be present in the exported data set. Change-Id: I95b0298ab49021a09f6b26e08158ce162b5a99e6 Reviewed-on: https://go-review.googlesource.com/c/149614 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
parent
f62bfb5415
commit
1a405fd27e
|
@ -7,7 +7,6 @@ package lsp
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"go/token"
|
"go/token"
|
||||||
"io/ioutil"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
|
@ -28,21 +27,10 @@ func testLSP(t *testing.T, exporter packagestest.Exporter) {
|
||||||
const dir = "testdata"
|
const dir = "testdata"
|
||||||
|
|
||||||
files := packagestest.MustCopyFileTree(dir)
|
files := packagestest.MustCopyFileTree(dir)
|
||||||
subdirs, err := ioutil.ReadDir(dir)
|
for fragment, operation := range files {
|
||||||
if err != nil {
|
if trimmed := strings.TrimSuffix(fragment, ".in"); trimmed != fragment {
|
||||||
t.Fatal(err)
|
delete(files, fragment)
|
||||||
}
|
files[trimmed] = operation
|
||||||
for _, subdir := range subdirs {
|
|
||||||
if !subdir.IsDir() {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
dirpath := filepath.Join(dir, subdir.Name())
|
|
||||||
if testFiles, err := ioutil.ReadDir(dirpath); err == nil {
|
|
||||||
for _, file := range testFiles {
|
|
||||||
if trimmed := strings.TrimSuffix(file.Name(), ".in"); trimmed != file.Name() {
|
|
||||||
files[filepath.Join(subdir.Name(), trimmed)] = packagestest.Copy(filepath.Join(dirpath, file.Name()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
modules := []packagestest.Module{
|
modules := []packagestest.Module{
|
||||||
|
|
Loading…
Reference in New Issue