.gitignore added
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools / gopls@v0.6.9 / internal / regtest / misc / 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 //go:build !android
8 // +build !android
9
10 package misc
11
12 import (
13         "testing"
14
15         . "golang.org/x/tools/gopls/internal/regtest"
16 )
17
18 func TestGenerateProgress(t *testing.T) {
19         const generatedWorkspace = `
20 -- go.mod --
21 module fake.test
22
23 go 1.14
24 -- lib/generate.go --
25 // +build ignore
26
27 package main
28
29 import "io/ioutil"
30
31 func main() {
32         ioutil.WriteFile("generated.go", []byte("package lib\n\nconst answer = 42"), 0644)
33 }
34 -- lib/lib.go --
35 package lib
36
37 func GetAnswer() int {
38         return answer
39 }
40
41 //go:generate go run generate.go
42 `
43
44         Run(t, generatedWorkspace, func(t *testing.T, env *Env) {
45                 env.Await(
46                         env.DiagnosticAtRegexp("lib/lib.go", "answer"),
47                 )
48                 env.RunGenerate("./lib")
49                 env.Await(
50                         OnceMet(
51                                 env.DoneWithChangeWatchedFiles(),
52                                 EmptyDiagnostics("lib/lib.go")),
53                 )
54         })
55 }