From 1a405fd27e6556a89186464ce4fc110e42b95d52 Mon Sep 17 00:00:00 2001 From: Ian Cottrell Date: Wed, 14 Nov 2018 21:05:48 -0500 Subject: [PATCH] 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 TryBot-Result: Gobot Gobot Reviewed-by: Rebecca Stambler --- internal/lsp/lsp_test.go | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/internal/lsp/lsp_test.go b/internal/lsp/lsp_test.go index 8099328c..9de3887a 100644 --- a/internal/lsp/lsp_test.go +++ b/internal/lsp/lsp_test.go @@ -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{