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:
Ian Cottrell 2018-11-14 21:05:48 -05:00
parent f62bfb5415
commit 1a405fd27e
1 changed files with 4 additions and 16 deletions

View File

@ -7,7 +7,6 @@ package lsp
import (
"context"
"go/token"
"io/ioutil"
"path/filepath"
"reflect"
"sort"
@ -28,21 +27,10 @@ func testLSP(t *testing.T, exporter packagestest.Exporter) {
const dir = "testdata"
files := packagestest.MustCopyFileTree(dir)
subdirs, err := ioutil.ReadDir(dir)
if err != nil {
t.Fatal(err)
}
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()))
}
}
for fragment, operation := range files {
if trimmed := strings.TrimSuffix(fragment, ".in"); trimmed != fragment {
delete(files, fragment)
files[trimmed] = operation
}
}
modules := []packagestest.Module{