Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools / gopls@v0.5.2 / internal / regtest / generate_test.go
1 // Copyright 2020 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // TODO(rfindley): figure out why go generate fails on android builders.
6
7 // +build !android
8
9 package regtest
10
11 import (
12         "testing"
13
14         "golang.org/x/tools/internal/lsp"
15 )
16
17 func TestGenerateProgress(t *testing.T) {
18         const generatedWorkspace = `
19 -- go.mod --
20 module fake.test
21
22 go 1.14
23 -- lib/generate.go --
24 // +build ignore
25
26 package main
27
28 import "io/ioutil"
29
30 func main() {
31         ioutil.WriteFile("generated.go", []byte("package lib\n\nconst answer = 42"), 0644)
32 }
33 -- lib/lib.go --
34 package lib
35
36 func GetAnswer() int {
37         return answer
38 }
39
40 //go:generate go run generate.go
41 `
42
43         runner.Run(t, generatedWorkspace, func(t *testing.T, env *Env) {
44                 env.Await(
45                         env.DiagnosticAtRegexp("lib/lib.go", "answer"),
46                 )
47                 env.RunGenerate("./lib")
48                 env.Await(
49                         OnceMet(
50                                 CompletedWork(lsp.DiagnosticWorkTitle(lsp.FromDidChangeWatchedFiles), 1),
51                                 EmptyDiagnostics("lib/lib.go")),
52                 )
53         })
54 }