ADAPT-Chase commited on
Commit
fb948da
·
verified ·
1 Parent(s): 6a16f9d

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/check_goexperiment.txt +10 -0
  2. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/clean_binary.txt +78 -0
  3. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/clean_cache_n.txt +28 -0
  4. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/clean_testcache.txt +28 -0
  5. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cmd_import_error.txt +16 -0
  6. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_asm.txt +33 -0
  7. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_atomic_pkgall.txt +25 -0
  8. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_blank_func_decl.txt +35 -0
  9. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_build_cmdline_pkgs.txt +73 -0
  10. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_build_pkg_select.txt +114 -0
  11. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_build_simple.txt +149 -0
  12. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_cgo.txt +42 -0
  13. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_cgo_extra_file.txt +48 -0
  14. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_cgo_extra_test.txt +49 -0
  15. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_cgo_xtest.txt +45 -0
  16. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_coverpkg_partial.txt +149 -0
  17. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_coverpkg_with_init.txt +130 -0
  18. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_coverprofile_multipkg.txt +193 -0
  19. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_dash_c.txt +31 -0
  20. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_dep_loop.txt +36 -0
  21. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_dot_import.txt +29 -0
  22. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_error.txt +45 -0
  23. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_import_main_loop.txt +26 -0
  24. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_list.txt +65 -0
  25. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_main_import_path.txt +55 -0
  26. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_mod_empty.txt +9 -0
  27. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_modes.txt +25 -0
  28. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_pattern.txt +41 -0
  29. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_pkgall_imports.txt +48 -0
  30. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_pkgall_multiple_mains.txt +46 -0
  31. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_pkgall_runtime.txt +23 -0
  32. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_runs.txt +13 -0
  33. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_statements.txt +96 -0
  34. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_swig.txt +72 -0
  35. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_sync_atomic_import.txt +44 -0
  36. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_test_localpkg_filepath.txt +40 -0
  37. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_test_pkgselect.txt +80 -0
  38. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_test_race_issue56370.txt +54 -0
  39. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_var_init_order.txt +55 -0
  40. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cpu_profile_twice.txt +22 -0
  41. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/darwin_lto_library_ldflag.txt +17 -0
  42. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/devnull.txt +26 -0
  43. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/dist_list_missing.txt +57 -0
  44. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/doc.txt +75 -0
  45. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/embed.txt +130 -0
  46. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/embed_brackets.txt +18 -0
  47. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/embed_fmt.txt +22 -0
  48. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/env_cache.txt +5 -0
  49. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/env_cross_build.txt +29 -0
  50. platform/dbops/binaries/go/go/src/cmd/go/testdata/script/env_exp.txt +17 -0
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/check_goexperiment.txt ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ # Test that [GOEXPERIMENT:x] is accepted.
2
+ # Here fieldtrack is picked arbitrarily.
3
+
4
+ [GOEXPERIMENT:nofieldtrack] env
5
+
6
+ [GOEXPERIMENT:fieldtrack] env
7
+
8
+ #[GOEXPERIMENT:crashme] env
9
+
10
+
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/clean_binary.txt ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Build something to create the executable, including several cases
2
+ [short] skip
3
+
4
+ # --------------------- clean executables -------------------------
5
+
6
+ # case1: test file-named executable 'main'
7
+ env GO111MODULE=on
8
+
9
+ ! exists main$GOEXE
10
+ go build main.go
11
+ exists -exec main$GOEXE
12
+ go clean
13
+ ! exists main$GOEXE
14
+
15
+ # case2: test module-named executable 'a.b.c'
16
+ ! exists a.b.c$GOEXE
17
+ go build
18
+ exists -exec a.b.c$GOEXE
19
+ go clean
20
+ ! exists a.b.c$GOEXE
21
+
22
+ # case3: directory-named executable 'src'
23
+ env GO111MODULE=off
24
+
25
+ ! exists src$GOEXE
26
+ go build
27
+ exists -exec src$GOEXE
28
+ go clean
29
+ ! exists src$GOEXE
30
+
31
+ # --------------------- clean test files -------------------------
32
+
33
+ # case1: test file-named test file
34
+ env GO111MODULE=on
35
+
36
+ ! exists main.test$GOEXE
37
+ go test -c main_test.go
38
+ exists -exec main.test$GOEXE
39
+ go clean
40
+ ! exists main.test$GOEXE
41
+
42
+ # case2: test module-named test file
43
+ ! exists a.b.c.test$GOEXE
44
+ go test -c
45
+ exists -exec a.b.c.test$GOEXE
46
+ go clean
47
+ ! exists a.b.c.test$GOEXE
48
+
49
+ # case3: test directory-based test file
50
+ env GO111MODULE=off
51
+
52
+ ! exists src.test$GOEXE
53
+ go test -c
54
+ exists -exec src.test$GOEXE
55
+ go clean
56
+ ! exists src.test$GOEXE
57
+
58
+ -- main.go --
59
+ package main
60
+
61
+ import "fmt"
62
+
63
+ func main() {
64
+ fmt.Println("hello!")
65
+ }
66
+
67
+ -- main_test.go --
68
+ package main
69
+
70
+ import "testing"
71
+
72
+ func TestSomething(t *testing.T) {
73
+ }
74
+
75
+ -- go.mod --
76
+ module example.com/a.b.c/v2
77
+
78
+ go 1.12
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/clean_cache_n.txt ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # We're testing cache behavior, so start with a clean GOCACHE.
2
+ env GOCACHE=$WORK/cache
3
+
4
+ # Build something so that the cache gets populates
5
+ go build main.go
6
+
7
+ # Check that cache contains directories before running
8
+ exists $GOCACHE/00
9
+
10
+ # Run go clean -cache -n and ensure that directories weren't deleted
11
+ go clean -cache -n
12
+ exists $GOCACHE/00
13
+
14
+ # Re-run go clean cache without the -n flag go ensure that directories were properly removed
15
+ go clean -cache
16
+ ! exists $GOCACHE/00
17
+
18
+ ! go clean -cache .
19
+ stderr 'go: clean -cache cannot be used with package arguments'
20
+
21
+ -- main.go --
22
+ package main
23
+
24
+ import "fmt"
25
+
26
+ func main() {
27
+ fmt.Println("hello!")
28
+ }
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/clean_testcache.txt ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ env GO111MODULE=off
2
+ [short] skip
3
+
4
+ # go clean -testcache
5
+ # should work (see golang.org/issue/29757).
6
+ cd x
7
+ go test x_test.go
8
+ go clean -testcache
9
+ go test x_test.go
10
+ ! stdout 'cached'
11
+ ! go clean -testcache ../x
12
+ stderr 'go: clean -testcache cannot be used with package arguments'
13
+
14
+ # golang.org/issue/29100: 'go clean -testcache' should succeed
15
+ # if the cache directory doesn't exist at all.
16
+ # It should not write a testexpire.txt file, since there are no
17
+ # test results that need to be invalidated in the first place.
18
+ env GOCACHE=$WORK/nonexistent
19
+ go clean -testcache
20
+ ! exists $WORK/nonexistent
21
+
22
+ -- x/x_test.go --
23
+ package x_test
24
+ import (
25
+ "testing"
26
+ )
27
+ func TestMain(t *testing.T) {
28
+ }
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cmd_import_error.txt ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ env GO111MODULE=on
2
+
3
+ # Regression test for golang.org/issue/31031:
4
+ # Importing or loading a non-existent package in cmd/ should print
5
+ # a clear error in module mode.
6
+
7
+ ! go list cmd/unknown
8
+ stderr '^package cmd/unknown is not in std \('$GOROOT'[/\\]src[/\\]cmd[/\\]unknown\)$'
9
+
10
+ go list -f '{{range .DepsErrors}}{{.Err}}{{end}}' x.go
11
+ stdout '^package cmd/unknown is not in std \('$GOROOT'[/\\]src[/\\]cmd[/\\]unknown\)$'
12
+
13
+ -- x.go --
14
+ package x
15
+
16
+ import _ "cmd/unknown"
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_asm.txt ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [short] skip
2
+ [compiler:gccgo] skip # gccgo has no cover tool
3
+
4
+ # Test cover for a package that has an assembly function.
5
+
6
+ go test -outputdir=$WORK -coverprofile=cover.out coverasm
7
+ go tool cover -func=$WORK/cover.out
8
+ stdout '\tg\t*100.0%' # Check g is 100% covered.
9
+ ! stdout '\tf\t*[0-9]' # Check for no coverage on the assembly function
10
+
11
+ -- go.mod --
12
+ module coverasm
13
+
14
+ go 1.16
15
+ -- p.go --
16
+ package p
17
+
18
+ func f()
19
+
20
+ func g() {
21
+ println("g")
22
+ }
23
+ -- p.s --
24
+ // empty asm file,
25
+ // so go test doesn't complain about declaration of f in p.go.
26
+ -- p_test.go --
27
+ package p
28
+
29
+ import "testing"
30
+
31
+ func Test(t *testing.T) {
32
+ g()
33
+ }
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_atomic_pkgall.txt ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ env GO111MODULE=off
2
+
3
+ [short] skip
4
+
5
+ go test -coverpkg=all -covermode=atomic x
6
+ stdout ok[\s\S]+?coverage
7
+
8
+ [!race] stop
9
+
10
+ go test -coverpkg=all -race x
11
+ stdout ok[\s\S]+?coverage
12
+
13
+ -- x/x.go --
14
+ package x
15
+
16
+ import _ "sync/atomic"
17
+
18
+ func F() {}
19
+
20
+ -- x/x_test.go --
21
+ package x
22
+
23
+ import "testing"
24
+
25
+ func TestF(t *testing.T) { F() }
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_blank_func_decl.txt ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [short] skip
2
+ go test -cover coverblank
3
+ stdout 'coverage: 100.0% of statements'
4
+
5
+
6
+ -- go.mod --
7
+ module coverblank
8
+
9
+ go 1.16
10
+ -- a.go --
11
+ package coverblank
12
+
13
+ func _() {
14
+ println("unreachable")
15
+ }
16
+
17
+ type X int
18
+
19
+ func (x X) Print() {
20
+ println(x)
21
+ }
22
+
23
+ func (x X) _() {
24
+ println("unreachable")
25
+ }
26
+
27
+ -- a_test.go --
28
+ package coverblank
29
+
30
+ import "testing"
31
+
32
+ func TestX(t *testing.T) {
33
+ var x X
34
+ x.Print()
35
+ }
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_build_cmdline_pkgs.txt ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # This test is intended to verify that when a user does "go run -cover ..."
3
+ # or "go build -cover ...", packages named on the command line are
4
+ # always instrumented (but not their dependencies). This rule applies
5
+ # inside and outside the standard library.
6
+
7
+ [short] skip
8
+ [!GOEXPERIMENT:coverageredesign] skip
9
+
10
+ # Compile an object.
11
+ go tool compile -p tiny tiny/tiny.go tiny/tiny2.go
12
+
13
+ # Build a stdlib command with coverage.
14
+ go build -o $WORK/nm.exe -cover cmd/nm
15
+
16
+ # Save off old GOCOVERDIR setting
17
+ env SAVEGOCOVERDIR=$GOCOVERDIR
18
+
19
+ # Collect a coverage profile from running 'cmd/nm' on the object.
20
+ mkdir $WORK/covdata
21
+ env GOCOVERDIR=$WORK/covdata
22
+ exec $WORK/nm.exe tiny.o
23
+
24
+ # Restore previous GOCOVERDIR setting
25
+ env GOCOVERDIR=$SAVEGOCOVERDIR
26
+
27
+ # Check to make sure we instrumented just the main package, not
28
+ # any dependencies.
29
+ go tool covdata pkglist -i=$WORK/covdata
30
+ stdout cmd/nm
31
+ ! stdout cmd/internal/goobj pkglist.txt
32
+
33
+ # ... now collect a coverage profile from a Go file
34
+ # listed on the command line.
35
+ go build -cover -o $WORK/another.exe testdata/another.go
36
+ mkdir $WORK/covdata2
37
+ env GOCOVERDIR=$WORK/covdata2
38
+ exec $WORK/another.exe
39
+
40
+ # Restore previous GOCOVERDIR setting
41
+ env GOCOVERDIR=$SAVEGOCOVERDIR
42
+
43
+ # Check to make sure we instrumented just the main package.
44
+ go tool covdata pkglist -i=$WORK/covdata2
45
+ stdout command-line-arguments
46
+ ! stdout fmt
47
+
48
+ -- go.mod --
49
+
50
+ module example.prog
51
+
52
+ -- testdata/another.go --
53
+
54
+ package main
55
+
56
+ import "fmt"
57
+
58
+ func main() {
59
+ fmt.Println("Hi dad")
60
+ }
61
+
62
+ -- tiny/tiny.go --
63
+
64
+ package tiny
65
+
66
+ var Tvar int
67
+
68
+ -- tiny/tiny2.go --
69
+
70
+ package tiny
71
+
72
+ var Tvar2 bool
73
+
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_build_pkg_select.txt ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This test checks more of the "go build -cover" functionality,
2
+ # specifically which packages get selected when building.
3
+
4
+ [short] skip
5
+
6
+ # Skip if new coverage is not enabled.
7
+ [!GOEXPERIMENT:coverageredesign] skip
8
+
9
+ #-------------------------------------------
10
+
11
+ # Build for coverage.
12
+ go build -mod=mod -o $WORK/modex.exe -cover mod.example/main
13
+
14
+ # Save off old GOCOVERDIR setting
15
+ env SAVEGOCOVERDIR=$GOCOVERDIR
16
+
17
+ # Execute.
18
+ mkdir $WORK/covdata
19
+ env GOCOVERDIR=$WORK/covdata
20
+ exec $WORK/modex.exe
21
+
22
+ # Restore previous GOCOVERDIR setting
23
+ env GOCOVERDIR=$SAVEGOCOVERDIR
24
+
25
+ # Examine the result.
26
+ go tool covdata percent -i=$WORK/covdata
27
+ stdout 'coverage: 100.0% of statements'
28
+
29
+ # By default we want to see packages resident in the module covered,
30
+ # but not dependencies.
31
+ go tool covdata textfmt -i=$WORK/covdata -o=$WORK/covdata/out.txt
32
+ grep 'mode: set' $WORK/covdata/out.txt
33
+ grep 'mod.example/main/main.go:' $WORK/covdata/out.txt
34
+ grep 'mod.example/sub/sub.go:' $WORK/covdata/out.txt
35
+ ! grep 'rsc.io' $WORK/covdata/out.txt
36
+
37
+ rm $WORK/covdata
38
+ rm $WORK/modex.exe
39
+
40
+ #-------------------------------------------
41
+
42
+ # Repeat the build but with -coverpkg=all
43
+
44
+ go build -mod=mod -coverpkg=all -o $WORK/modex.exe -cover mod.example/main
45
+
46
+ # Execute.
47
+ mkdir $WORK/covdata
48
+ env GOCOVERDIR=$WORK/covdata
49
+ exec $WORK/modex.exe
50
+
51
+ # Restore previous GOCOVERDIR setting
52
+ env GOCOVERDIR=$SAVEGOCOVERDIR
53
+
54
+ # Examine the result.
55
+ go tool covdata percent -i=$WORK/covdata
56
+ stdout 'coverage:.*[1-9][0-9.]+%'
57
+
58
+ # The whole enchilada.
59
+ go tool covdata textfmt -i=$WORK/covdata -o=$WORK/covdata/out.txt
60
+ grep 'mode: set' $WORK/covdata/out.txt
61
+ grep 'mod.example/main/main.go:' $WORK/covdata/out.txt
62
+ grep 'mod.example/sub/sub.go:' $WORK/covdata/out.txt
63
+ grep 'rsc.io' $WORK/covdata/out.txt
64
+ grep 'bufio/bufio.go:' $WORK/covdata/out.txt
65
+
66
+ # Use the covdata tool to select a specific set of module paths
67
+ mkdir $WORK/covdata2
68
+ go tool covdata merge -pkg=rsc.io/quote -i=$WORK/covdata -o=$WORK/covdata2
69
+
70
+ # Examine the result.
71
+ go tool covdata percent -i=$WORK/covdata2
72
+ stdout 'coverage:.*[1-9][0-9.]+%'
73
+
74
+ # Check for expected packages + check that we don't see things from stdlib.
75
+ go tool covdata textfmt -i=$WORK/covdata2 -o=$WORK/covdata2/out.txt
76
+ grep 'mode: set' $WORK/covdata2/out.txt
77
+ ! grep 'mod.example/main/main.go:' $WORK/covdata2/out.txt
78
+ ! grep 'mod.example/sub/sub.go:' $WORK/covdata2/out.txt
79
+ grep 'rsc.io' $WORK/covdata2/out.txt
80
+ ! grep 'bufio/bufio.go:' $WORK/covdata2/out.txt
81
+
82
+ #-------------------------------------------
83
+ # end of test cmds, start of harness and related files.
84
+
85
+ -- go.mod --
86
+ module mod.example
87
+
88
+ go 1.20
89
+
90
+ require rsc.io/quote/v3 v3.0.0
91
+
92
+ -- main/main.go --
93
+ package main
94
+
95
+ import (
96
+ "fmt"
97
+ "mod.example/sub"
98
+
99
+ "rsc.io/quote"
100
+ )
101
+
102
+ func main() {
103
+ fmt.Println(quote.Go(), sub.F())
104
+ }
105
+
106
+ -- sub/sub.go --
107
+
108
+ package sub
109
+
110
+ func F() int {
111
+ return 42
112
+ }
113
+
114
+
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_build_simple.txt ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This test checks basic "go build -cover" functionality.
2
+
3
+ [short] skip
4
+
5
+ # Hard-wire new coverage for this test.
6
+ env GOEXPERIMENT=coverageredesign
7
+
8
+ # Build for coverage.
9
+ go build -gcflags=-m -o example.exe -cover example/main &
10
+ [race] go build -o examplewithrace.exe -race -cover example/main &
11
+ wait
12
+
13
+ # First execute without GOCOVERDIR set...
14
+ env GOCOVERDIR=
15
+ exec ./example.exe normal
16
+ stderr '^warning: GOCOVERDIR not set, no coverage data emitted'
17
+
18
+ # ... then with GOCOVERDIR set.
19
+ env GOCOVERDIR=data/normal
20
+ exec ./example.exe normal
21
+ ! stderr '^warning: GOCOVERDIR not set, no coverage data emitted'
22
+ go tool covdata percent -i=data/normal
23
+ stdout 'coverage:.*[1-9][0-9.]+%'
24
+
25
+ # Program makes a direct call to os.Exit(0).
26
+ env GOCOVERDIR=data/goodexit
27
+ exec ./example.exe goodexit
28
+ ! stderr '^warning: GOCOVERDIR not set, no coverage data emitted'
29
+ go tool covdata percent -i=data/goodexit
30
+ stdout 'coverage:.*[1-9][0-9.]+%'
31
+
32
+ # Program makes a direct call to os.Exit(1).
33
+ env GOCOVERDIR=data/badexit
34
+ ! exec ./example.exe badexit
35
+ ! stderr '^warning: GOCOVERDIR not set, no coverage data emitted'
36
+ go tool covdata percent -i=data/badexit
37
+ stdout 'coverage:.*[1-9][0-9.]+%'
38
+
39
+ # Program invokes panic.
40
+ env GOCOVERDIR=data/panic
41
+ ! exec ./example.exe panic
42
+ ! stderr '^warning: GOCOVERDIR not set, no coverage data emitted'
43
+ go tool covdata percent -i=data/panic
44
+ stdout 'coverage:.*[0-9.]+%'
45
+
46
+ # Skip remainder if no race detector support.
47
+ [!race] skip
48
+
49
+ env GOCOVERDIR=data2/normal
50
+ exec ./examplewithrace.exe normal
51
+ ! stderr '^warning: GOCOVERDIR not set, no coverage data emitted'
52
+ go tool covdata percent -i=data2/normal
53
+ stdout 'coverage:.*[1-9][0-9.]+%'
54
+
55
+ # Program makes a direct call to os.Exit(0).
56
+ env GOCOVERDIR=data2/goodexit
57
+ exec ./examplewithrace.exe goodexit
58
+ ! stderr '^warning: GOCOVERDIR not set, no coverage data emitted'
59
+ go tool covdata percent -i=data2/goodexit
60
+ stdout 'coverage:.*[1-9][0-9.]+%'
61
+
62
+ # Program makes a direct call to os.Exit(1).
63
+ env GOCOVERDIR=data2/badexit
64
+ ! exec ./examplewithrace.exe badexit
65
+ ! stderr '^warning: GOCOVERDIR not set, no coverage data emitted'
66
+ go tool covdata percent -i=data2/badexit
67
+ stdout 'coverage:.*[1-9][0-9.]+%'
68
+
69
+ # Program invokes panic.
70
+ env GOCOVERDIR=data2/panic
71
+ ! exec ./examplewithrace.exe panic
72
+ ! stderr '^warning: GOCOVERDIR not set, no coverage data emitted'
73
+ go tool covdata percent -i=data2/panic
74
+ stdout 'coverage:.*[0-9.]+%'
75
+
76
+ # end of test cmds, start of harness and related files.
77
+
78
+ -- go.mod --
79
+ module example
80
+
81
+ go 1.18
82
+
83
+ -- main/example.go --
84
+ package main
85
+
86
+ import "example/sub"
87
+
88
+ func main() {
89
+ sub.S()
90
+ }
91
+
92
+ -- sub/sub.go --
93
+
94
+ package sub
95
+
96
+ import "os"
97
+
98
+ func S() {
99
+ switch os.Args[1] {
100
+ case "normal":
101
+ println("hi")
102
+ case "goodexit":
103
+ os.Exit(0)
104
+ case "badexit":
105
+ os.Exit(1)
106
+ case "panic":
107
+ panic("something bad happened")
108
+ }
109
+ }
110
+
111
+ -- data/README.txt --
112
+
113
+ Just a location where we can write coverage profiles.
114
+
115
+ -- data/normal/f.txt --
116
+
117
+ X
118
+
119
+ -- data/goodexit/f.txt --
120
+
121
+ X
122
+
123
+ -- data/badexit/f.txt --
124
+
125
+ X
126
+
127
+ -- data/panic/f.txt --
128
+
129
+ X
130
+
131
+ -- data2/README.txt --
132
+
133
+ Just a location where we can write coverage profiles.
134
+
135
+ -- data2/normal/f.txt --
136
+
137
+ X
138
+
139
+ -- data2/goodexit/f.txt --
140
+
141
+ X
142
+
143
+ -- data2/badexit/f.txt --
144
+
145
+ X
146
+
147
+ -- data2/panic/f.txt --
148
+
149
+ X
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_cgo.txt ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [short] skip
2
+ [!cgo] skip
3
+ [compiler:gccgo] skip # gccgo has no cover tool
4
+
5
+ # Test coverage on cgo code.
6
+
7
+ go test -short -cover cgocover
8
+ stdout 'coverage:.*[1-9][0-9.]+%'
9
+ ! stderr '[^0-9]0\.0%'
10
+
11
+ -- go.mod --
12
+ module cgocover
13
+
14
+ go 1.16
15
+ -- p.go --
16
+ package p
17
+
18
+ /*
19
+ void
20
+ f(void)
21
+ {
22
+ }
23
+ */
24
+ import "C"
25
+
26
+ var b bool
27
+
28
+ func F() {
29
+ if b {
30
+ for {
31
+ }
32
+ }
33
+ C.f()
34
+ }
35
+ -- p_test.go --
36
+ package p
37
+
38
+ import "testing"
39
+
40
+ func TestF(t *testing.T) {
41
+ F()
42
+ }
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_cgo_extra_file.txt ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [short] skip
2
+ [!cgo] skip
3
+ [compiler:gccgo] skip # gccgo has no cover tool
4
+
5
+ # Test coverage on cgo code. This test case includes an
6
+ # extra empty non-cgo file in the package being checked.
7
+
8
+ go test -short -cover cgocover4
9
+ stdout 'coverage:.*[1-9][0-9.]+%'
10
+ ! stderr '[^0-9]0\.0%'
11
+
12
+ -- go.mod --
13
+ module cgocover4
14
+
15
+ go 1.16
16
+ -- notcgo.go --
17
+ package p
18
+ -- p.go --
19
+ package p
20
+
21
+ /*
22
+ void
23
+ f(void)
24
+ {
25
+ }
26
+ */
27
+ import "C"
28
+
29
+ var b bool
30
+
31
+ func F() {
32
+ if b {
33
+ for {
34
+ }
35
+ }
36
+ C.f()
37
+ }
38
+ -- x_test.go --
39
+ package p_test
40
+
41
+ import (
42
+ . "cgocover4"
43
+ "testing"
44
+ )
45
+
46
+ func TestF(t *testing.T) {
47
+ F()
48
+ }
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_cgo_extra_test.txt ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [short] skip
2
+ [!cgo] skip
3
+ [compiler:gccgo] skip # gccgo has no cover tool
4
+
5
+ # Test coverage on cgo code. This test case has an external
6
+ # test that tests the code and an in-package test file with
7
+ # no test cases.
8
+
9
+ go test -short -cover cgocover3
10
+ stdout 'coverage:.*[1-9][0-9.]+%'
11
+ ! stderr '[^0-9]0\.0%'
12
+
13
+ -- go.mod --
14
+ module cgocover3
15
+
16
+ go 1.16
17
+ -- p.go --
18
+ package p
19
+
20
+ /*
21
+ void
22
+ f(void)
23
+ {
24
+ }
25
+ */
26
+ import "C"
27
+
28
+ var b bool
29
+
30
+ func F() {
31
+ if b {
32
+ for {
33
+ }
34
+ }
35
+ C.f()
36
+ }
37
+ -- p_test.go --
38
+ package p
39
+ -- x_test.go --
40
+ package p_test
41
+
42
+ import (
43
+ . "cgocover3"
44
+ "testing"
45
+ )
46
+
47
+ func TestF(t *testing.T) {
48
+ F()
49
+ }
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_cgo_xtest.txt ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [short] skip
2
+ [!cgo] skip
3
+ [compiler:gccgo] skip # gccgo has no cover tool
4
+
5
+ # Test cgo coverage with an external test.
6
+
7
+ go test -short -cover cgocover2
8
+ stdout 'coverage:.*[1-9][0-9.]+%'
9
+ ! stderr '[^0-9]0\.0%'
10
+
11
+ -- go.mod --
12
+ module cgocover2
13
+
14
+ go 1.16
15
+ -- p.go --
16
+ package p
17
+
18
+ /*
19
+ void
20
+ f(void)
21
+ {
22
+ }
23
+ */
24
+ import "C"
25
+
26
+ var b bool
27
+
28
+ func F() {
29
+ if b {
30
+ for {
31
+ }
32
+ }
33
+ C.f()
34
+ }
35
+ -- x_test.go --
36
+ package p_test
37
+
38
+ import (
39
+ . "cgocover2"
40
+ "testing"
41
+ )
42
+
43
+ func TestF(t *testing.T) {
44
+ F()
45
+ }
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_coverpkg_partial.txt ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # Testcase related to #58770 and #24570. This is intended to ensure
3
+ # that coverage collection works in situations where we're testing a
4
+ # collection of packages and supplying a -coverpkg pattern that
5
+ # matches some but not all of the collection. In addition, some of the
6
+ # packages have Go code but no tests, and other packages have tests
7
+ # but no Go code. Package breakdown:
8
+ #
9
+ # Package Code? Tests? Stmts Imports
10
+ # a yes yes 2 f
11
+ # b yes yes 1 a, d
12
+ # c yes yes 3 ---
13
+ # d yes no 1 ---
14
+ # e no yes 0 a, b
15
+ # f yes no 3 ---
16
+ #
17
+
18
+ [short] skip
19
+ [!GOEXPERIMENT:coverageredesign] skip
20
+
21
+ # Test all packages with -coverpkg=./...
22
+ go test -coverprofile=cov.p -coverpkg=./... ./...
23
+ stdout '^ok\s+M/a\s+\S+\s+coverage: 50.0% of statements in ./...'
24
+ stdout '^ok\s+M/b\s+\S+\s+coverage: 60.0% of statements in ./...'
25
+ stdout '^ok\s+M/c\s+\S+\s+coverage: 30.0% of statements in ./...'
26
+ stdout '^\s*M/d\s+coverage: 0.0% of statements'
27
+ stdout '^\s*M/f\s+coverage: 0.0% of statements'
28
+
29
+ # Test just the test-only package ./e but with -coverpkg=./...
30
+ # Total number of statements should be 7 (e.g. a/b/d/f but not c)
31
+ # and covered percent should be 6/7 (we hit everything in the
32
+ # coverpkg pattern except the func in "d").
33
+ go test -coverprofile=bar.p -coverpkg=./... ./e
34
+ stdout '^ok\s+M/e\s+\S+\s+coverage: 85.7% of statements in ./...'
35
+
36
+ # Test b and f with -coverpkg set to a/d/f. Total of 6 statements
37
+ # in a/d/f, again we hit everything except DFunc.
38
+ go test -coverprofile=baz.p -coverpkg=./a,./d,./f ./b ./f
39
+ stdout '^ok\s+M/b\s+\S+\s+coverage: 83.3% of statements in ./a, ./d, ./f'
40
+ stdout '^\s*M/f\s+coverage: 0.0% of statements'
41
+
42
+ # This sub-test inspired by issue 65653: if package P is is matched
43
+ # via the package pattern supplied as the argument to "go test -cover"
44
+ # but P is not part of "-coverpkg", then we don't want coverage for P
45
+ # (including the specific case where P has no test files).
46
+ go test -coverpkg=./a ./...
47
+ stdout '^ok\s+M/a\s+\S+\s+coverage: 100.0% of statements in ./a'
48
+ stdout '^\s*\?\s+M/f\s+\[no test files\]'
49
+
50
+ -- a/a.go --
51
+ package a
52
+
53
+ import "M/f"
54
+
55
+ var G int
56
+
57
+ func AFunc() int {
58
+ G = 1
59
+ return f.Id()
60
+ }
61
+ -- a/a_test.go --
62
+ package a
63
+
64
+ import "testing"
65
+
66
+ func TestA(t *testing.T) {
67
+ if AFunc() != 42 {
68
+ t.Fatalf("bad!")
69
+ }
70
+ }
71
+ -- b/b.go --
72
+ package b
73
+
74
+ import (
75
+ "M/a"
76
+ "M/d"
77
+ )
78
+
79
+ func BFunc() int {
80
+ return -d.FortyTwo + a.AFunc()
81
+ }
82
+ -- b/b_test.go --
83
+ package b
84
+
85
+ import "testing"
86
+
87
+ func TestB(t *testing.T) {
88
+ if BFunc() == 1010101 {
89
+ t.Fatalf("bad!")
90
+ }
91
+ }
92
+ -- c/c.go --
93
+ package c
94
+
95
+ var G int
96
+
97
+ func CFunc(x, y int) int {
98
+ G += x
99
+ G -= y
100
+ return x + y
101
+ }
102
+ -- c/c_test.go --
103
+ package c
104
+
105
+ import "testing"
106
+
107
+ func TestC(t *testing.T) {
108
+ if CFunc(10, 10) == 1010101 {
109
+ t.Fatalf("bad!")
110
+ }
111
+ }
112
+ -- d/d.go --
113
+ package d
114
+
115
+ const FortyTwo = 42
116
+
117
+ func DFunc() int {
118
+ return FortyTwo
119
+ }
120
+
121
+ -- e/e_test.go --
122
+ package e
123
+
124
+ import (
125
+ "M/a"
126
+ "M/b"
127
+ "testing"
128
+ )
129
+
130
+ func TestBlah(t *testing.T) {
131
+ if b.BFunc() == 1010101 {
132
+ t.Fatalf("bad")
133
+ }
134
+ a.AFunc()
135
+ }
136
+ -- f/f.go --
137
+ package f
138
+
139
+ var F int
140
+
141
+ func Id() int {
142
+ F += 9
143
+ F *= 2
144
+ return 42
145
+ }
146
+ -- go.mod --
147
+ module M
148
+
149
+ go 1.21
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_coverpkg_with_init.txt ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # Testcase inspired by issue #58770, intended to verify that we're
3
+ # doing the right thing when running "go test -coverpkg=./... ./..."
4
+ # on a collection of packages where some have init functions and some
5
+ # do not, some have tests and some do not.
6
+
7
+ [short] skip
8
+ [!GOEXPERIMENT:coverageredesign] skip
9
+
10
+ # Verify correct statements percentages. We have a total of 10
11
+ # statements in the packages matched by "./..."; package "a" (for
12
+ # example) has two statements so we expect 20.0% stmts covered. Go
13
+ # 1.19 would print 50% here (due to force importing of all ./...
14
+ # packages); prior to the fix for #58770 Go 1.20 would show 100%
15
+ # coverage. For packages "x" and "f" (which have no tests), check for
16
+ # 0% stmts covered (as opposed to "no test files").
17
+
18
+ go test -count=1 -coverprofile=cov.dat -coverpkg=./... ./...
19
+ stdout '^\s*\?\s+M/n\s+\[no test files\]'
20
+ stdout '^\s*M/x\s+coverage: 0.0% of statements'
21
+ stdout '^\s*M/f\s+coverage: 0.0% of statements'
22
+ stdout '^ok\s+M/a\s+\S+\s+coverage: 30.0% of statements in ./...'
23
+ stdout '^ok\s+M/b\s+\S+\s+coverage: 20.0% of statements in ./...'
24
+ stdout '^ok\s+M/main\s+\S+\s+coverage: 80.0% of statements in ./...'
25
+
26
+ # Check for selected elements in the collected coverprofile as well.
27
+
28
+ go tool cover -func=cov.dat
29
+ stdout '^M/x/x.go:3:\s+XFunc\s+0.0%'
30
+ stdout '^M/b/b.go:7:\s+BFunc\s+100.0%'
31
+ stdout '^total:\s+\(statements\)\s+80.0%'
32
+
33
+ -- go.mod --
34
+ module M
35
+
36
+ go 1.21
37
+ -- a/a.go --
38
+ package a
39
+
40
+ import "M/f"
41
+
42
+ func init() {
43
+ println("package 'a' init: launch the missiles!")
44
+ }
45
+
46
+ func AFunc() int {
47
+ return f.Id()
48
+ }
49
+ -- a/a_test.go --
50
+ package a
51
+
52
+ import "testing"
53
+
54
+ func TestA(t *testing.T) {
55
+ if AFunc() != 42 {
56
+ t.Fatalf("bad!")
57
+ }
58
+ }
59
+ -- b/b.go --
60
+ package b
61
+
62
+ func init() {
63
+ println("package 'b' init: release the kraken")
64
+ }
65
+
66
+ func BFunc() int {
67
+ return -42
68
+ }
69
+ -- b/b_test.go --
70
+ package b
71
+
72
+ import "testing"
73
+
74
+ func TestB(t *testing.T) {
75
+ if BFunc() != -42 {
76
+ t.Fatalf("bad!")
77
+ }
78
+ }
79
+ -- f/f.go --
80
+ package f
81
+
82
+ func Id() int {
83
+ return 42
84
+ }
85
+ -- main/main.go --
86
+ package main
87
+
88
+ import (
89
+ "M/a"
90
+ "M/b"
91
+ )
92
+
93
+ func MFunc() string {
94
+ return "42"
95
+ }
96
+
97
+ func M2Func() int {
98
+ return a.AFunc() + b.BFunc()
99
+ }
100
+
101
+ func init() {
102
+ println("package 'main' init")
103
+ }
104
+
105
+ func main() {
106
+ println(a.AFunc() + b.BFunc())
107
+ }
108
+ -- main/main_test.go --
109
+ package main
110
+
111
+ import "testing"
112
+
113
+ func TestMain(t *testing.T) {
114
+ if MFunc() != "42" {
115
+ t.Fatalf("bad!")
116
+ }
117
+ if M2Func() != 0 {
118
+ t.Fatalf("also bad!")
119
+ }
120
+ }
121
+ -- n/n.go --
122
+ package n
123
+
124
+ type N int
125
+ -- x/x.go --
126
+ package x
127
+
128
+ func XFunc() int {
129
+ return 2 * 2
130
+ }
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_coverprofile_multipkg.txt ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # Testcase for #63356. In this bug we're doing a "go test -coverprofile"
3
+ # run for a collection of packages, mostly independent (hence tests can
4
+ # be done in parallel) and in the original bug, temp coverage profile
5
+ # files were not being properly qualified and were colliding, resulting
6
+ # in a corrupted final profile. Actual content of the packages doesn't
7
+ # especially matter as long as we have a mix of packages with tests and
8
+ # multiple packages without tests.
9
+
10
+ [short] skip
11
+
12
+ # Kick off test.
13
+ go test -p=10 -vet=off -count=1 -coverprofile=cov.p ./...
14
+
15
+ # Make sure resulting profile is digestible.
16
+ go tool cover -func=cov.p
17
+
18
+ # No extraneous extra files please.
19
+ ! exists _cover_.out
20
+
21
+ -- a/a.go --
22
+ package a
23
+
24
+ func init() {
25
+ println("package 'a' init: launch the missiles!")
26
+ }
27
+
28
+ func AFunc() int {
29
+ return 42
30
+ }
31
+ -- a/a_test.go --
32
+ package a
33
+
34
+ import "testing"
35
+
36
+ func TestA(t *testing.T) {
37
+ if AFunc() != 42 {
38
+ t.Fatalf("bad!")
39
+ }
40
+ }
41
+ -- aa/aa.go --
42
+ package aa
43
+
44
+ import "M/it"
45
+
46
+ func AA(y int) int {
47
+ c := it.Conc{}
48
+ x := it.Callee(&c)
49
+ println(x, y)
50
+ return 0
51
+ }
52
+ -- aa/aa_test.go --
53
+ package aa
54
+
55
+ import "testing"
56
+
57
+ func TestMumble(t *testing.T) {
58
+ AA(3)
59
+ }
60
+ -- b/b.go --
61
+ package b
62
+
63
+ func init() {
64
+ println("package 'b' init: release the kraken")
65
+ }
66
+
67
+ func BFunc() int {
68
+ return -42
69
+ }
70
+ -- b/b_test.go --
71
+ package b
72
+
73
+ import "testing"
74
+
75
+ func TestB(t *testing.T) {
76
+ if BFunc() != -42 {
77
+ t.Fatalf("bad!")
78
+ }
79
+ }
80
+ -- deadstuff/deadstuff.go --
81
+ package deadstuff
82
+
83
+ func downStreamOfPanic(x int) {
84
+ panic("bad")
85
+ if x < 10 {
86
+ println("foo")
87
+ }
88
+ }
89
+ -- deadstuff/deadstuff_test.go --
90
+ package deadstuff
91
+
92
+ import "testing"
93
+
94
+ func TestMumble(t *testing.T) {
95
+ defer func() {
96
+ if x := recover(); x != nil {
97
+ println("recovered")
98
+ }
99
+ }()
100
+ downStreamOfPanic(10)
101
+ }
102
+ -- go.mod --
103
+ module M
104
+
105
+ go 1.21
106
+ -- it/it.go --
107
+ package it
108
+
109
+ type Ctr interface {
110
+ Count() int
111
+ }
112
+
113
+ type Conc struct {
114
+ X int
115
+ }
116
+
117
+ func (c *Conc) Count() int {
118
+ return c.X
119
+ }
120
+
121
+ func DoCall(c *Conc) {
122
+ c2 := Callee(c)
123
+ println(c2.Count())
124
+ }
125
+
126
+ func Callee(ii Ctr) Ctr {
127
+ q := ii.Count()
128
+ return &Conc{X: q}
129
+ }
130
+ -- main/main.go --
131
+ package main
132
+
133
+ import (
134
+ "M/a"
135
+ "M/b"
136
+ )
137
+
138
+ func MFunc() string {
139
+ return "42"
140
+ }
141
+
142
+ func M2Func() int {
143
+ return a.AFunc() + b.BFunc()
144
+ }
145
+
146
+ func init() {
147
+ println("package 'main' init")
148
+ }
149
+
150
+ func main() {
151
+ println(a.AFunc() + b.BFunc())
152
+ }
153
+ -- main/main_test.go --
154
+ package main
155
+
156
+ import "testing"
157
+
158
+ func TestMain(t *testing.T) {
159
+ if MFunc() != "42" {
160
+ t.Fatalf("bad!")
161
+ }
162
+ if M2Func() != 0 {
163
+ t.Fatalf("also bad!")
164
+ }
165
+ }
166
+ -- n/n.go --
167
+ package n
168
+
169
+ type N int
170
+ -- onlytest/mumble_test.go --
171
+ package onlytest
172
+
173
+ import "testing"
174
+
175
+ func TestFoo(t *testing.T) {
176
+ t.Logf("Whee\n")
177
+ }
178
+ -- x/x.go --
179
+ package x
180
+
181
+ func XFunc() int {
182
+ return 2 * 2
183
+ }
184
+ -- xinternal/i.go --
185
+ package i
186
+
187
+ func I() int { return 32 }
188
+ -- xinternal/q/q.go --
189
+ package q
190
+
191
+ func Q() int {
192
+ return 42
193
+ }
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_dash_c.txt ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [short] skip
2
+ [compiler:gccgo] skip
3
+
4
+ # Test for issue 24588
5
+
6
+ go test -c -o $WORK/coverdep -coverprofile=$WORK/no/such/dir/cover.out coverdep
7
+ exists -exec $WORK/coverdep
8
+
9
+ -- go.mod --
10
+ module coverdep
11
+
12
+ go 1.16
13
+ -- p.go --
14
+ package p
15
+
16
+ import _ "coverdep/p1"
17
+
18
+ func F() {
19
+ }
20
+ -- p1/p1.go --
21
+ package p1
22
+
23
+ import _ "errors"
24
+ -- p_test.go --
25
+ package p
26
+
27
+ import "testing"
28
+
29
+ func Test(t *testing.T) {
30
+ F()
31
+ }
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_dep_loop.txt ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [short] skip
2
+ [compiler:gccgo] skip
3
+
4
+ # coverdep2/p1's xtest imports coverdep2/p2 which imports coverdep2/p1.
5
+ # Make sure that coverage on coverdep2/p2 recompiles coverdep2/p2.
6
+
7
+ go test -short -cover coverdep2/p1
8
+ stdout 'coverage: 100.0% of statements' # expect 100.0% coverage
9
+
10
+ -- go.mod --
11
+ module coverdep2
12
+
13
+ go 1.16
14
+ -- p1/p.go --
15
+ package p1
16
+
17
+ func F() int { return 1 }
18
+ -- p1/p_test.go --
19
+ package p1_test
20
+
21
+ import (
22
+ "coverdep2/p2"
23
+ "testing"
24
+ )
25
+
26
+ func Test(t *testing.T) {
27
+ p2.F()
28
+ }
29
+ -- p2/p2.go --
30
+ package p2
31
+
32
+ import "coverdep2/p1"
33
+
34
+ func F() {
35
+ p1.F()
36
+ }
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_dot_import.txt ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [short] skip
2
+ [compiler:gccgo] skip # gccgo has no cover tool
3
+
4
+ go test -coverpkg=coverdot/a,coverdot/b coverdot/b
5
+ ! stderr '[^0-9]0\.0%'
6
+ ! stdout '[^0-9]0\.0%'
7
+
8
+ -- go.mod --
9
+ module coverdot
10
+
11
+ go 1.16
12
+ -- a/a.go --
13
+ package a
14
+
15
+ func F() {}
16
+ -- b/b.go --
17
+ package b
18
+
19
+ import . "coverdot/a"
20
+
21
+ func G() { F() }
22
+ -- b/b_test.go --
23
+ package b
24
+
25
+ import "testing"
26
+
27
+ func TestG(t *testing.T) {
28
+ G()
29
+ }
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_error.txt ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [short] skip
2
+ [compiler:gccgo] skip
3
+
4
+ # Test line numbers in cover errors.
5
+
6
+ # Get errors from a go test into stderr.txt
7
+ ! go test coverbad
8
+ stderr 'p\.go:4:2' # look for error at coverbad/p.go:4
9
+ [cgo] stderr 'p1\.go:6:2' # look for error at coverbad/p.go:6
10
+ ! stderr $WORK # make sure temporary directory isn't in error
11
+
12
+ cp stderr $WORK/stderr.txt
13
+
14
+ # Get errors from coverage into stderr2.txt
15
+ ! go test -cover coverbad
16
+ cp stderr $WORK/stderr2.txt
17
+
18
+ wait # for go run above
19
+
20
+ cmp $WORK/stderr.txt $WORK/stderr2.txt
21
+
22
+ -- go.mod --
23
+ module coverbad
24
+
25
+ go 1.16
26
+ -- p.go --
27
+ package p
28
+
29
+ func f() {
30
+ g()
31
+ }
32
+ -- p1.go --
33
+ package p
34
+
35
+ import "C"
36
+
37
+ func h() {
38
+ j()
39
+ }
40
+ -- p_test.go --
41
+ package p
42
+
43
+ import "testing"
44
+
45
+ func Test(t *testing.T) {}
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_import_main_loop.txt ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [compiler:gccgo] skip # gccgo has no cover tool
2
+
3
+ ! go test -n importmain/test
4
+ stderr 'not an importable package' # check that import main was detected
5
+ ! go test -n -cover importmain/test
6
+ stderr 'not an importable package' # check that import main was detected
7
+
8
+ -- go.mod --
9
+ module importmain
10
+
11
+ go 1.16
12
+ -- ismain/main.go --
13
+ package main
14
+
15
+ import _ "importmain/test"
16
+
17
+ func main() {}
18
+ -- test/test.go --
19
+ package test
20
+ -- test/test_test.go --
21
+ package test_test
22
+
23
+ import "testing"
24
+ import _ "importmain/ismain"
25
+
26
+ func TestCase(t *testing.T) {}
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_list.txt ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # This test is intended to verify that "go list" accepts coverage related
3
+ # build arguments (such as -cover, -covermode). See issue #57785.
4
+
5
+ [short] skip
6
+ [!GOEXPERIMENT:coverageredesign] skip
7
+
8
+ env GOBIN=$WORK/bin
9
+
10
+ # Install a target and then do an ordinary staleness check on it.
11
+ go install m/example
12
+ ! stale m/example
13
+
14
+ # Run a second staleness check with "-cover" as a build flag. The
15
+ # installed target should indeed be stale, since we didn't build it
16
+ # with -cover.
17
+ stale -cover m/example
18
+
19
+ # Collect build ID from for m/example built with -cover.
20
+ go list -cover -export -f '{{.BuildID}}' m/example
21
+ cp stdout $WORK/listbuildid.txt
22
+
23
+ # Now build the m/example binary with coverage.
24
+ go build -cover -o $WORK/m.exe m/example
25
+
26
+ # Ask for the binary build ID by running "go tool buildid".
27
+ go tool buildid $WORK/m.exe
28
+ cp stdout $WORK/rawtoolbuildid.txt
29
+
30
+ # Make sure that the two build IDs agree with respect to the
31
+ # m/example package. Build IDs from binaries are of the form X/Y/Z/W
32
+ # where Y/Z is the package build ID; running the program below will
33
+ # pick out the parts of the ID that we want.
34
+ env GOCOVERDIR=$WORK
35
+ exec $WORK/m.exe $WORK/rawtoolbuildid.txt
36
+ cp stdout $WORK/toolbuildid.txt
37
+
38
+ # Build IDs should match here.
39
+ cmp $WORK/toolbuildid.txt $WORK/listbuildid.txt
40
+
41
+ -- go.mod --
42
+ module m
43
+
44
+ go 1.20
45
+ -- example/main.go --
46
+ package main
47
+
48
+ import (
49
+ "fmt"
50
+ "os"
51
+ "strings"
52
+ )
53
+
54
+ func main() {
55
+ println(os.Args[1])
56
+ content, err := os.ReadFile(os.Args[1])
57
+ if err != nil {
58
+ os.Exit(1)
59
+ }
60
+ fields := strings.Split(strings.TrimSpace(string(content)), "/")
61
+ if len(fields) != 4 {
62
+ os.Exit(2)
63
+ }
64
+ fmt.Println(fields[1] + "/" + fields[2])
65
+ }
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_main_import_path.txt ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # This test is intended to verify that coverage reporting is consistent
3
+ # between "go test -cover" and "go build -cover" with respect to how
4
+ # the "main" package is handled. See issue 57169 for details.
5
+
6
+ [short] skip
7
+ [!GOEXPERIMENT:coverageredesign] skip
8
+
9
+ # Build this program with -cover and run to collect a profile.
10
+
11
+ go build -cover -o $WORK/prog.exe .
12
+
13
+ # Save off old GOCOVERDIR setting
14
+ env SAVEGOCOVERDIR=$GOCOVERDIR
15
+
16
+ mkdir $WORK/covdata
17
+ env GOCOVERDIR=$WORK/covdata
18
+ exec $WORK/prog.exe
19
+
20
+ # Restore previous GOCOVERDIR setting
21
+ env GOCOVERDIR=$SAVEGOCOVERDIR
22
+
23
+ # Report percent lines covered.
24
+ go tool covdata percent -i=$WORK/covdata
25
+ stdout '\s*mainwithtest\s+coverage:'
26
+ ! stdout 'main\s+coverage:'
27
+
28
+ # Go test -cover should behave the same way.
29
+ go test -cover .
30
+ stdout 'ok\s+mainwithtest\s+\S+\s+coverage:'
31
+ ! stdout 'ok\s+main\s+.*'
32
+
33
+
34
+ -- go.mod --
35
+ module mainwithtest
36
+
37
+ go 1.20
38
+ -- mymain.go --
39
+ package main
40
+
41
+ func main() {
42
+ println("hi mom")
43
+ }
44
+
45
+ func Mainer() int {
46
+ return 42
47
+ }
48
+ -- main_test.go --
49
+ package main
50
+
51
+ import "testing"
52
+
53
+ func TestCoverage(t *testing.T) {
54
+ println(Mainer())
55
+ }
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_mod_empty.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ go tool cover -func=cover.out
2
+ stdout total.*statements.*0.0%
3
+
4
+ go mod init golang.org/issue/33855
5
+
6
+ go tool cover -func=cover.out
7
+ stdout total.*statements.*0.0%
8
+
9
+ -- cover.out --
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_modes.txt ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ env GO111MODULE=off
2
+
3
+ # Coverage analysis should use 'set' mode by default,
4
+ # and should merge coverage profiles correctly.
5
+
6
+ [short] skip
7
+ [compiler:gccgo] skip # gccgo has no cover tool
8
+
9
+ go test -short -cover encoding/binary errors -coverprofile=$WORK/cover.out
10
+ ! stderr '[^0-9]0\.0%'
11
+ ! stdout '[^0-9]0\.0%'
12
+
13
+ grep -count=1 '^mode: set$' $WORK/cover.out
14
+ grep 'errors\.go' $WORK/cover.out
15
+ grep 'binary\.go' $WORK/cover.out
16
+
17
+ [!race] stop
18
+
19
+ go test -short -race -cover encoding/binary errors -coverprofile=$WORK/cover.out
20
+ ! stderr '[^0-9]0\.0%'
21
+ ! stdout '[^0-9]0\.0%'
22
+
23
+ grep -count=1 '^mode: atomic$' $WORK/cover.out
24
+ grep 'errors\.go' $WORK/cover.out
25
+ grep 'binary\.go' $WORK/cover.out
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_pattern.txt ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [compiler:gccgo] skip
2
+
3
+ # If coverpkg=m/sleepy... expands by package loading
4
+ # (as opposed to pattern matching on deps)
5
+ # then it will try to load sleepybad, which does not compile,
6
+ # and the test command will fail.
7
+ ! go list m/sleepy...
8
+ go test -c -n -coverprofile=$TMPDIR/cover.out -coverpkg=m/sleepy... -run=^$ m/sleepy1
9
+
10
+ -- go.mod --
11
+ module m
12
+
13
+ go 1.16
14
+ -- sleepy1/p_test.go --
15
+ package p
16
+
17
+ import (
18
+ "testing"
19
+ "time"
20
+ )
21
+
22
+ func Test1(t *testing.T) {
23
+ time.Sleep(200 * time.Millisecond)
24
+ }
25
+ -- sleepy2/p_test.go --
26
+ package p
27
+
28
+ import (
29
+ "testing"
30
+ "time"
31
+ )
32
+
33
+ func Test1(t *testing.T) {
34
+ time.Sleep(200 * time.Millisecond)
35
+ }
36
+ -- sleepybad/p.go --
37
+ package p
38
+
39
+ import ^
40
+
41
+ var _ = io.DoesNotExist
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_pkgall_imports.txt ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This test checks that -coverpkg=all can be used
2
+ # when the package pattern includes packages
3
+ # which only have tests.
4
+ # Verifies golang.org/issue/27333, golang.org/issue/43242.
5
+
6
+ [short] skip
7
+ cd $GOPATH/src/example.com/cov
8
+
9
+ env GO111MODULE=on
10
+ go test -coverpkg=all ./...
11
+
12
+ env GO111MODULE=off
13
+ go test -coverpkg=all ./...
14
+
15
+ -- $GOPATH/src/example.com/cov/go.mod --
16
+ module example.com/cov
17
+
18
+ -- $GOPATH/src/example.com/cov/notest/notest.go --
19
+ package notest
20
+
21
+ func Foo() {}
22
+
23
+ -- $GOPATH/src/example.com/cov/onlytest/onlytest_test.go --
24
+ package onlytest_test
25
+
26
+ import (
27
+ "testing"
28
+
29
+ "example.com/cov/notest"
30
+ )
31
+
32
+ func TestFoo(t *testing.T) {
33
+ notest.Foo()
34
+ }
35
+
36
+ -- $GOPATH/src/example.com/cov/withtest/withtest.go --
37
+ package withtest
38
+
39
+ func Bar() {}
40
+
41
+ -- $GOPATH/src/example.com/cov/withtest/withtest_test.go --
42
+ package withtest
43
+
44
+ import "testing"
45
+
46
+ func TestBar(t *testing.T) {
47
+ Bar()
48
+ }
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_pkgall_multiple_mains.txt ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This test checks that multiple main packages can be tested
2
+ # with -coverpkg=all without duplicate symbol errors.
3
+ # Verifies golang.org/issue/30374, golang.org/issue/34114.
4
+
5
+ [short] skip
6
+ cd $GOPATH/src/example.com/cov
7
+
8
+ env GO111MODULE=on
9
+ go test -coverpkg=all ./...
10
+
11
+ env GO111MODULE=off
12
+ go test -coverpkg=all ./...
13
+
14
+ -- $GOPATH/src/example.com/cov/go.mod --
15
+ module example.com/cov
16
+
17
+ -- $GOPATH/src/example.com/cov/mainonly/mainonly.go --
18
+ package main
19
+
20
+ func main() {}
21
+
22
+ -- $GOPATH/src/example.com/cov/mainwithtest/mainwithtest.go --
23
+ package main
24
+
25
+ func main() {}
26
+
27
+ func Foo() {}
28
+
29
+ -- $GOPATH/src/example.com/cov/mainwithtest/mainwithtest_test.go --
30
+ package main
31
+
32
+ import "testing"
33
+
34
+ func TestFoo(t *testing.T) {
35
+ Foo()
36
+ }
37
+
38
+ -- $GOPATH/src/example.com/cov/xtest/x.go --
39
+ package x
40
+
41
+ -- $GOPATH/src/example.com/cov/xtest/x_test.go --
42
+ package x_test
43
+
44
+ import "testing"
45
+
46
+ func TestX(t *testing.T) {}
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_pkgall_runtime.txt ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ env GO111MODULE=off
2
+
3
+ # Issue 23882
4
+
5
+ [short] skip
6
+
7
+ go test -coverpkg=all x
8
+ stdout ok[\s\S]+?coverage
9
+
10
+ [!race] stop
11
+
12
+ go test -coverpkg=all -race x
13
+ stdout ok[\s\S]+?coverage
14
+
15
+ -- x/x.go --
16
+ package x
17
+ import _ "runtime"
18
+ func F() {}
19
+
20
+ -- x/x_test.go --
21
+ package x
22
+ import "testing"
23
+ func TestF(t *testing.T) { F() }
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_runs.txt ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [compiler:gccgo] skip 'gccgo has no cover tool'
2
+ [short] skip
3
+
4
+ go test -short -coverpkg=strings strings regexp
5
+ ! stdout '[^0-9]0\.0%'
6
+ stdout 'strings.*coverage:.*[1-9][0-9.]+%'
7
+ stdout 'regexp.*coverage:.*[1-9][0-9.]+%'
8
+
9
+ go test -short -cover strings math regexp
10
+ ! stdout '[^0-9]0\.0%'
11
+ stdout 'strings.*coverage:.*[1-9][0-9.]+%'
12
+ stdout 'math.*coverage:.*[1-9][0-9.]+%'
13
+ stdout 'regexp.*coverage:.*[1-9][0-9.]+%'
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_statements.txt ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [short] skip
2
+
3
+ # Workaround for issue 64014 -- for the portion of this test that
4
+ # verifies that caching works correctly, the cache should theoretically
5
+ # always behave reliably/deterministically, however if other tests are
6
+ # concurrently accessing the cache while this test is running, it can
7
+ # lead to cache lookup failures, which manifest as test failures here.
8
+ # To avoid such flakes, use a separate isolated GOCACHE for this test.
9
+ env GOCACHE=$WORK/cache
10
+
11
+ # Initial run with simple coverage.
12
+ go test -cover ./pkg1 ./pkg2 ./pkg3 ./pkg4
13
+ [!GOEXPERIMENT:coverageredesign] stdout 'pkg1 \[no test files\]'
14
+ [GOEXPERIMENT:coverageredesign] stdout 'pkg1 coverage: 0.0% of statements'
15
+ stdout 'pkg2 \S+ coverage: 0.0% of statements \[no tests to run\]'
16
+ stdout 'pkg3 \S+ coverage: 100.0% of statements'
17
+ stdout 'pkg4 \S+ coverage: \[no statements\]'
18
+
19
+ # Second run to make sure that caching works properly.
20
+ go test -x -cover ./pkg1 ./pkg2 ./pkg3 ./pkg4
21
+ [!GOEXPERIMENT:coverageredesign] stdout 'pkg1 \[no test files\]'
22
+ [GOEXPERIMENT:coverageredesign] stdout 'pkg1 coverage: 0.0% of statements'
23
+ stdout 'pkg2 \S+ coverage: 0.0% of statements \[no tests to run\]'
24
+ stdout 'pkg3 \S+ coverage: 100.0% of statements'
25
+ stdout 'pkg4 \S+ coverage: \[no statements\]'
26
+ [GOEXPERIMENT:coverageredesign] ! stderr 'link(\.exe"?)? -'
27
+ ! stderr 'compile(\.exe"?)? -'
28
+ ! stderr 'cover(\.exe"?)? -'
29
+ [GOEXPERIMENT:coverageredesign] stderr 'covdata(\.exe"?)? percent'
30
+
31
+ # Now add in -coverprofile.
32
+ go test -cover -coverprofile=cov.dat ./pkg1 ./pkg2 ./pkg3 ./pkg4
33
+ [!GOEXPERIMENT:coverageredesign] stdout 'pkg1 \[no test files\]'
34
+ [GOEXPERIMENT:coverageredesign] stdout 'pkg1 coverage: 0.0% of statements'
35
+ stdout 'pkg2 \S+ coverage: 0.0% of statements \[no tests to run\]'
36
+ stdout 'pkg3 \S+ coverage: 100.0% of statements'
37
+ stdout 'pkg4 \S+ coverage: \[no statements\]'
38
+
39
+ # Validate
40
+ go tool cover -func=cov.dat
41
+ [GOEXPERIMENT:coverageredesign] stdout 'pkg1/a.go:5:\s+F\s+0.0%'
42
+
43
+ -- go.mod --
44
+ module m
45
+
46
+ go 1.16
47
+ -- pkg1/a.go --
48
+ package pkg1
49
+
50
+ import "fmt"
51
+
52
+ func F() {
53
+ fmt.Println("pkg1")
54
+ }
55
+ -- pkg2/a.go --
56
+ package pkg2
57
+
58
+ import "fmt"
59
+
60
+ func F() {
61
+ fmt.Println("pkg2")
62
+ }
63
+ -- pkg2/a_test.go --
64
+ package pkg2
65
+ -- pkg3/a.go --
66
+ package pkg3
67
+
68
+ import "fmt"
69
+
70
+ func F() {
71
+ fmt.Println("pkg3")
72
+ }
73
+ -- pkg3/a_test.go --
74
+ package pkg3
75
+
76
+ import "testing"
77
+
78
+ func TestF(t *testing.T) {
79
+ F()
80
+ }
81
+ -- pkg4/a.go --
82
+ package pkg4
83
+
84
+ type T struct {
85
+ X bool
86
+ }
87
+ -- pkg4/a_test.go --
88
+ package pkg4
89
+
90
+ import (
91
+ "testing"
92
+ )
93
+
94
+ func TestT(t *testing.T) {
95
+ _ = T{}
96
+ }
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_swig.txt ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # Testcase for issue 64661. This testcase is intended to verify that
3
+ # we don't try to send swig-generated Go files through the cover tool
4
+ # for "go test -cover" runs on packages that have *.swig source files.
5
+
6
+ [!exec:swig] skip
7
+ [!cgo] skip
8
+
9
+ go test -v -count=1 -coverprofile=foo.p
10
+ stdout 'coverage: 100.0% of statements'
11
+
12
+ -- go.mod --
13
+ module simple
14
+
15
+ go 1.21
16
+ -- main.c --
17
+ /* A global variable */
18
+ double Foo = 3.0;
19
+
20
+ /* Compute the greatest common divisor of positive integers */
21
+ int gcd(int x, int y) {
22
+ int g;
23
+ g = y;
24
+ while (x > 0) {
25
+ g = x;
26
+ x = y % x;
27
+ y = g;
28
+ }
29
+ return g;
30
+ }
31
+
32
+
33
+ -- main.go --
34
+ package main
35
+
36
+ import (
37
+ "fmt"
38
+ )
39
+
40
+ func main() {
41
+ // Call our gcd() function
42
+ x := 42
43
+ y := 105
44
+ g := Gcd(x, y)
45
+ fmt.Println("The gcd of", x, "and", y, "is", g)
46
+
47
+ // Manipulate the Foo global variable
48
+
49
+ // Output its current value
50
+ fmt.Println("Foo =", GetFoo())
51
+
52
+ // Change its value
53
+ SetFoo(3.1415926)
54
+
55
+ // See if the change took effect
56
+ fmt.Println("Foo =", GetFoo())
57
+ }
58
+ -- main.swig --
59
+ %module main
60
+
61
+ %inline %{
62
+ extern int gcd(int x, int y);
63
+ extern double Foo;
64
+ %}
65
+ -- main_test.go --
66
+ package main
67
+
68
+ import "testing"
69
+
70
+ func TestSwigFuncs(t *testing.T) {
71
+ main()
72
+ }
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_sync_atomic_import.txt ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [short] skip
2
+ [compiler:gccgo] skip # gccgo has no cover tool
3
+ [!GOEXPERIMENT:coverageredesign] skip
4
+
5
+ go test -short -cover -covermode=atomic -coverpkg=coverdep/p1 coverdep
6
+
7
+ # In addition to the above, test to make sure there is no funny
8
+ # business if we try "go test -cover" in atomic mode targeting
9
+ # sync/atomic itself (see #57445). Just a short test run is needed
10
+ # since we're mainly interested in making sure the test builds and can
11
+ # execute at least one test.
12
+
13
+ go test -short -covermode=atomic -run=TestStoreInt64 sync/atomic
14
+ go test -short -covermode=atomic -run=TestAnd8 runtime/internal/atomic
15
+
16
+ # Skip remainder if no race detector support.
17
+ [!race] skip
18
+
19
+ go test -short -cover -race -run=TestStoreInt64 sync/atomic
20
+ go test -short -cover -race -run=TestAnd8 runtime/internal/atomic
21
+
22
+ -- go.mod --
23
+ module coverdep
24
+
25
+ go 1.16
26
+ -- p.go --
27
+ package p
28
+
29
+ import _ "coverdep/p1"
30
+
31
+ func F() {
32
+ }
33
+ -- p1/p1.go --
34
+ package p1
35
+
36
+ import _ "errors"
37
+ -- p_test.go --
38
+ package p
39
+
40
+ import "testing"
41
+
42
+ func Test(t *testing.T) {
43
+ F()
44
+ }
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_test_localpkg_filepath.txt ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ [short] skip
3
+
4
+ # collect coverage profile in text format
5
+ go test -coverprofile=blah.prof prog.go prog_test.go
6
+
7
+ # should not contain cmd-line pseudo-import-path
8
+ grep prog.go blah.prof
9
+ grep $PWD blah.prof
10
+ ! grep command-line-arguments blah.prof
11
+
12
+ -- prog.go --
13
+ package main
14
+
15
+ func Mumble(x int) int {
16
+ if x < 0 {
17
+ return -x
18
+ }
19
+ return 42
20
+ }
21
+
22
+ func Grumble(y int) int {
23
+ return -y
24
+ }
25
+
26
+ func main() {
27
+ }
28
+
29
+ -- prog_test.go --
30
+ package main
31
+
32
+ import (
33
+ "testing"
34
+ )
35
+
36
+ func TestMumble(t *testing.T) {
37
+ if x := Mumble(10); x != 42 {
38
+ t.Errorf("Mumble(%d): got %d want %d", 10, x, 42)
39
+ }
40
+ }
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_test_pkgselect.txt ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ [short] skip
3
+
4
+ # Hard-wire new coverage for this test.
5
+ env GOEXPERIMENT=coverageredesign
6
+
7
+ # Baseline run.
8
+ go test -cover example/foo
9
+ stdout 'coverage: 50.0% of statements$'
10
+
11
+ # Coverage percentage output should mention -coverpkg selection.
12
+ go test -coverpkg=example/foo example/foo
13
+ stdout 'coverage: 50.0% of statements in example/foo'
14
+
15
+ # Try to ask for coverage of a package that doesn't exist.
16
+ go test -coverpkg nonexistent example/bar
17
+ stderr 'no packages being tested depend on matches for pattern nonexistent'
18
+ stdout 'coverage: \[no statements\]'
19
+
20
+ # Ask for foo coverage, but test bar.
21
+ go test -coverpkg=example/foo example/bar
22
+ stdout 'coverage: 50.0% of statements in example/foo'
23
+
24
+ # end of test cmds, start of harness and related files.
25
+
26
+ -- go.mod --
27
+ module example
28
+
29
+ go 1.18
30
+
31
+ -- foo/foo.go --
32
+ package foo
33
+
34
+ func FooFunc() int {
35
+ return 42
36
+ }
37
+ func FooFunc2() int {
38
+ return 42
39
+ }
40
+
41
+ -- foo/foo_test.go --
42
+ package foo
43
+
44
+ import "testing"
45
+
46
+ func TestFoo(t *testing.T) {
47
+ if FooFunc() != 42 {
48
+ t.Fatalf("bad")
49
+ }
50
+ }
51
+
52
+ -- bar/bar.go --
53
+ package bar
54
+
55
+ import "example/foo"
56
+
57
+ func BarFunc() int {
58
+ return foo.FooFunc2()
59
+ }
60
+
61
+ -- bar/bar_test.go --
62
+ package bar_test
63
+
64
+ import (
65
+ "example/bar"
66
+ "testing"
67
+ )
68
+
69
+ func TestBar(t *testing.T) {
70
+ if bar.BarFunc() != 42 {
71
+ t.Fatalf("bad")
72
+ }
73
+ }
74
+
75
+ -- baz/baz.go --
76
+ package baz
77
+
78
+ func BazFunc() int {
79
+ return -42
80
+ }
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_test_race_issue56370.txt ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [short] skip
2
+ [!race] skip
3
+
4
+ go test -race -cover issue.56370/filter
5
+
6
+ -- go.mod --
7
+ module issue.56370
8
+
9
+ go 1.20
10
+
11
+ -- filter/filter.go --
12
+
13
+ package filter
14
+
15
+ func New() func(error) bool {
16
+ return func(error) bool {
17
+ return false
18
+ }
19
+ }
20
+
21
+ -- filter/filter_test.go --
22
+
23
+ package filter_test
24
+
25
+ import (
26
+ "testing"
27
+
28
+ "issue.56370/filter"
29
+ )
30
+
31
+ func Test1(t *testing.T) {
32
+ t.Parallel()
33
+
34
+ _ = filter.New()
35
+ }
36
+
37
+ func Test2(t *testing.T) {
38
+ t.Parallel()
39
+
40
+ _ = filter.New()
41
+ }
42
+
43
+ func Test3(t *testing.T) {
44
+ t.Parallel()
45
+
46
+ _ = filter.New()
47
+ }
48
+
49
+ func Test4(t *testing.T) {
50
+ t.Parallel()
51
+
52
+ _ = filter.New()
53
+ }
54
+
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cover_var_init_order.txt ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This test verifies that issue 56293 has been fixed, and that the
2
+ # insertion of coverage instrumentation doesn't perturb package
3
+ # initialization order.
4
+
5
+ [short] skip
6
+
7
+ # Skip if new coverage is turned off.
8
+ [!GOEXPERIMENT:coverageredesign] skip
9
+
10
+ go test -cover example
11
+
12
+ -- go.mod --
13
+ module example
14
+
15
+ go 1.20
16
+
17
+ -- m.go --
18
+
19
+ package main
20
+
21
+ import (
22
+ "flag"
23
+ )
24
+
25
+ var (
26
+ fooFlag = flag.String("foo", "", "this should be ok")
27
+ foo = flag.Lookup("foo")
28
+
29
+ barFlag = flag.String("bar", "", "this should be also ok, but is "+notOK()+".")
30
+ bar = flag.Lookup("bar")
31
+ )
32
+
33
+ func notOK() string {
34
+ return "not OK"
35
+ }
36
+
37
+ -- m_test.go --
38
+
39
+ package main
40
+
41
+ import (
42
+ "testing"
43
+ )
44
+
45
+ func TestFoo(t *testing.T) {
46
+ if foo == nil {
47
+ t.Fatal()
48
+ }
49
+ }
50
+
51
+ func TestBar(t *testing.T) {
52
+ if bar == nil {
53
+ t.Fatal()
54
+ }
55
+ }
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/cpu_profile_twice.txt ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ env GO111MODULE=off
2
+
3
+ # Issue 23150
4
+
5
+ [short] skip
6
+
7
+ go test -o=$WORK/x.test -cpuprofile=$WORK/cpu_profile_twice.out x
8
+ rm $WORK/cpu_profile_twice.out
9
+
10
+ go test -o=$WORK/x.test -cpuprofile=$WORK/cpu_profile_twice.out x
11
+ exists $WORK/cpu_profile_twice.out
12
+
13
+
14
+ -- x/x_test.go --
15
+ package x_test
16
+ import (
17
+ "testing"
18
+ "time"
19
+ )
20
+ func TestSleep(t *testing.T) {
21
+ time.Sleep(10 * time.Millisecond)
22
+ }
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/darwin_lto_library_ldflag.txt ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [!GOOS:darwin] skip
2
+ [!cgo] skip
3
+
4
+ ! go build
5
+ stderr 'invalid flag in #cgo LDFLAGS: -lto_library'
6
+
7
+ -- go.mod --
8
+ module ldflag
9
+
10
+ -- main.go --
11
+ package main
12
+
13
+ // #cgo CFLAGS: -flto
14
+ // #cgo LDFLAGS: -lto_library bad.dylib
15
+ import "C"
16
+
17
+ func main() {}
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/devnull.txt ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ env GO111MODULE=off
2
+
3
+ # Issue 28035: go test -c -o NUL should work.
4
+ # Issue 28549: go test -c -o /dev/null should not overwrite /dev/null when run as root.
5
+ cd x
6
+ cmp $devnull $WORK/empty.txt
7
+ go test -o=$devnull -c
8
+ ! exists x.test$GOEXE
9
+ cmp $devnull $WORK/empty.txt
10
+
11
+ # Issue 12407: go build -o /dev/null should succeed.
12
+ cd ..
13
+ go build -o $devnull y
14
+ cmp $devnull $WORK/empty.txt
15
+
16
+ -- x/x_test.go --
17
+ package x_test
18
+ import (
19
+ "testing"
20
+ )
21
+ func TestNUL(t *testing.T) {
22
+ }
23
+ -- y/y.go --
24
+ package y
25
+ func main() {}
26
+ -- $WORK/empty.txt --
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/dist_list_missing.txt ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Regression test for #60939: when 'go tool dist' is missing,
2
+ # 'go tool dist list' should inject its output.
3
+
4
+
5
+ # Set GOROOT to a directory that definitely does not include
6
+ # a compiled 'dist' tool. 'go tool dist list' should still
7
+ # work, because 'cmd/go' itself can impersonate this command.
8
+
9
+ mkdir $WORK/goroot/bin
10
+ mkdir $WORK/goroot/pkg/tool/${GOOS}_${GOARCH}
11
+ env GOROOT=$WORK/goroot
12
+
13
+ ! go tool -n dist
14
+ stderr 'go: no such tool "dist"'
15
+
16
+ go tool dist list
17
+ stdout linux/amd64
18
+ cp stdout tool.txt
19
+
20
+ go tool dist list -v
21
+ stdout linux/amd64
22
+ cp stdout tool-v.txt
23
+
24
+ go tool dist list -broken
25
+ stdout $GOOS/$GOARCH
26
+ cp stdout tool-broken.txt
27
+
28
+ go tool dist list -json
29
+ stdout '"GOOS": "linux",\n\s*"GOARCH": "amd64",\n'
30
+ cp stdout tool-json.txt
31
+
32
+ go tool dist list -json -broken
33
+ stdout '"GOOS": "'$GOOS'",\n\s*"GOARCH": "'$GOARCH'",\n'
34
+ cp stdout tool-json-broken.txt
35
+
36
+ [short] stop
37
+
38
+
39
+ # Check against the real cmd/dist as the source of truth.
40
+
41
+ env GOROOT=$TESTGO_GOROOT
42
+ go build -o dist.exe cmd/dist
43
+
44
+ exec ./dist.exe list
45
+ cmp stdout tool.txt
46
+
47
+ exec ./dist.exe list -v
48
+ cmp stdout tool-v.txt
49
+
50
+ exec ./dist.exe list -broken
51
+ cmp stdout tool-broken.txt
52
+
53
+ exec ./dist.exe list -json
54
+ cmp stdout tool-json.txt
55
+
56
+ exec ./dist.exe list -json -broken
57
+ cmp stdout tool-json-broken.txt
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/doc.txt ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # go doc --help
2
+ ! go doc --help
3
+ stderr 'go doc'
4
+ stderr 'go doc <pkg>'
5
+ stderr 'go doc <sym>\[\.<methodOrField>\]'
6
+ stderr 'go doc \[<pkg>\.\]<sym>\[\.<methodOrField>\]'
7
+ stderr 'go doc \[<pkg>\.\]\[<sym>\.\]<methodOrField>'
8
+ stderr 'go doc <pkg> <sym>\[\.<methodOrField>\]'
9
+
10
+ # go help doc
11
+ go help doc
12
+ stdout 'go doc'
13
+ stdout 'go doc <pkg>'
14
+ stdout 'go doc <sym>\[\.<methodOrField>\]'
15
+ stdout 'go doc \[<pkg>\.\]<sym>\[\.<methodOrField>\]'
16
+ stdout 'go doc \[<pkg>\.\]\[<sym>\.\]<methodOrField>'
17
+ stdout 'go doc <pkg> <sym>\[\.<methodOrField>\]'
18
+
19
+ # go doc <pkg>
20
+ go doc p/v2
21
+ stdout .
22
+
23
+ # go doc <pkg> <sym>
24
+ go doc p/v2 Symbol
25
+ stdout .
26
+
27
+ # go doc <pkg> <sym> <method>
28
+ ! go doc p/v2 Symbol Method
29
+ stderr .
30
+
31
+ # go doc <pkg>.<sym>
32
+ go doc p/v2.Symbol
33
+ stdout .
34
+
35
+ # go doc <pkg>.<sym>.<method>
36
+ go doc p/v2.Symbol.Method
37
+ stdout .
38
+
39
+ # go doc <sym>
40
+ go doc Symbol
41
+ stdout .
42
+
43
+ # go doc <sym> <method>
44
+ ! go doc Symbol Method
45
+ stderr .
46
+
47
+ # go doc <sym>.<method>
48
+ go doc Symbol.Method
49
+ stdout .
50
+
51
+ # go doc <pkg>.<method>
52
+ go doc p/v2.Method
53
+ stdout .
54
+
55
+ # go doc <pkg> <method>
56
+ go doc p/v2 Method
57
+ stdout .
58
+
59
+ # go doc <method>
60
+ go doc Method
61
+ stdout .
62
+
63
+ -- go.mod --
64
+ module p/v2
65
+
66
+ go 1.13
67
+
68
+ -- p.go --
69
+ package p
70
+
71
+ type Symbol struct{}
72
+
73
+ func (Symbol) Method() error {
74
+ return nil
75
+ }
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/embed.txt ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # go list shows patterns and files
2
+ go list -f '{{.EmbedPatterns}}'
3
+ stdout '\[x\*t\*t\]'
4
+ go list -f '{{.EmbedFiles}}'
5
+ stdout '\[x.txt\]'
6
+ go list -test -f '{{.TestEmbedPatterns}}'
7
+ stdout '\[y\*t\*t\]'
8
+ go list -test -f '{{.TestEmbedFiles}}'
9
+ stdout '\[y.txt\]'
10
+ go list -test -f '{{.XTestEmbedPatterns}}'
11
+ stdout '\[z\*t\*t\]'
12
+ go list -test -f '{{.XTestEmbedFiles}}'
13
+ stdout '\[z.txt\]'
14
+
15
+ # build embeds x.txt
16
+ go build -x
17
+ stderr 'x.txt'
18
+
19
+ # build uses cache correctly
20
+ go build -x
21
+ ! stderr 'x.txt'
22
+ cp x.txt2 x.txt
23
+ go build -x
24
+ stderr 'x.txt'
25
+
26
+ # build rejects invalid names
27
+ cp x.go2 x.go
28
+ go build -x
29
+ cp x.txt .git
30
+ ! go build -x
31
+ stderr '^x.go:5:12: pattern [*]t: cannot embed file [.]git: invalid name [.]git$'
32
+ rm .git
33
+
34
+ # build rejects symlinks
35
+ [symlink] symlink x.tzt -> x.txt
36
+ [symlink] ! go build -x
37
+ [symlink] stderr 'pattern [*]t: cannot embed irregular file x.tzt'
38
+ [symlink] rm x.tzt
39
+
40
+ # build rejects empty directories
41
+ mkdir t
42
+ ! go build -x
43
+ stderr '^x.go:5:12: pattern [*]t: cannot embed directory t: contains no embeddable files$'
44
+
45
+ # build ignores symlinks and invalid names in directories
46
+ cp x.txt t/.git
47
+ ! go build -x
48
+ stderr '^x.go:5:12: pattern [*]t: cannot embed directory t: contains no embeddable files$'
49
+ go list -e -f '{{.Incomplete}}'
50
+ stdout 'true'
51
+ [symlink] symlink t/x.link -> ../x.txt
52
+ [symlink] ! go build -x
53
+ [symlink] stderr '^x.go:5:12: pattern [*]t: cannot embed directory t: contains no embeddable files$'
54
+
55
+ cp x.txt t/x.txt
56
+ go build -x
57
+
58
+ # build reports errors with positions in imported packages
59
+ rm t/x.txt
60
+ ! go build m/use
61
+ stderr '^x.go:5:12: pattern [*]t: cannot embed directory t: contains no embeddable files$'
62
+
63
+ # all still ignores .git and symlinks
64
+ cp x.go3 x.go
65
+ ! go build -x
66
+ stderr '^x.go:5:12: pattern all:t: cannot embed directory t: contains no embeddable files$'
67
+
68
+ # all finds dot files and underscore files
69
+ cp x.txt t/.x.txt
70
+ go build -x
71
+ rm t/.x.txt
72
+ cp x.txt t/_x.txt
73
+ go build -x
74
+
75
+ -- x.go --
76
+ package p
77
+
78
+ import "embed"
79
+
80
+ //go:embed x*t*t
81
+ var X embed.FS
82
+
83
+ -- x_test.go --
84
+ package p
85
+
86
+ import "embed"
87
+
88
+ //go:embed y*t*t
89
+ var Y string
90
+
91
+ -- x_x_test.go --
92
+ package p_test
93
+
94
+ import "embed"
95
+
96
+ //go:embed z*t*t
97
+ var Z string
98
+
99
+ -- x.go2 --
100
+ package p
101
+
102
+ import "embed"
103
+
104
+ //go:embed *t
105
+ var X embed.FS
106
+
107
+ -- x.go3 --
108
+ package p
109
+
110
+ import "embed"
111
+
112
+ //go:embed all:t
113
+ var X embed.FS
114
+
115
+ -- x.txt --
116
+ hello
117
+
118
+ -- y.txt --
119
+ -- z.txt --
120
+ -- x.txt2 --
121
+ not hello
122
+
123
+ -- use/use.go --
124
+ package use
125
+
126
+ import _ "m"
127
+ -- go.mod --
128
+ module m
129
+
130
+ go 1.16
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/embed_brackets.txt ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # issue 53314
2
+ [GOOS:windows] skip
3
+ cd [pkg]
4
+ go build
5
+
6
+ -- [pkg]/go.mod --
7
+ module m
8
+
9
+ go 1.19
10
+ -- [pkg]/x.go --
11
+ package p
12
+
13
+ import _ "embed"
14
+
15
+ //go:embed t.txt
16
+ var S string
17
+
18
+ -- [pkg]//t.txt --
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/embed_fmt.txt ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # go fmt ignores file not found
2
+ go fmt xnofmt.go
3
+ cmp xnofmt.go xfmt.ref
4
+ ! go build xnofmt.go
5
+ stderr 'xnofmt.go:5:12: pattern missing.txt: no matching files found'
6
+
7
+ -- xnofmt.go --
8
+ package p
9
+
10
+ import "embed"
11
+
12
+ //go:embed missing.txt
13
+ var X embed.FS
14
+ -- xfmt.ref --
15
+ package p
16
+
17
+ import "embed"
18
+
19
+ //go:embed missing.txt
20
+ var X embed.FS
21
+ -- go.mod --
22
+ module m
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/env_cache.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # go env should caches compiler results
2
+ go env
3
+ go env -x
4
+ ! stdout '\|\| true'
5
+
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/env_cross_build.txt ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Test that the correct default GOEXPERIMENT is used when cross
2
+ # building with GOENV (#46815).
3
+
4
+ # Unset variables set by the TestScript harness. Users typically won't
5
+ # explicitly configure these, and #46815 doesn't repro if they are.
6
+ env GOOS=
7
+ env GOARCH=
8
+ env GOEXPERIMENT=
9
+
10
+ env GOENV=windows-amd64
11
+ go build internal/abi
12
+
13
+ env GOENV=ios-arm64
14
+ go build internal/abi
15
+
16
+ env GOENV=linux-mips
17
+ go build internal/abi
18
+
19
+ -- windows-amd64 --
20
+ GOOS=windows
21
+ GOARCH=amd64
22
+
23
+ -- ios-arm64 --
24
+ GOOS=ios
25
+ GOARCH=arm64
26
+
27
+ -- linux-mips --
28
+ GOOS=linux
29
+ GOARCH=mips
platform/dbops/binaries/go/go/src/cmd/go/testdata/script/env_exp.txt ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Test GOEXPERIMENT variable
2
+
3
+ # go env shows default empty GOEXPERIMENT
4
+ go env
5
+ stdout GOEXPERIMENT=
6
+
7
+ # go env shows valid experiments
8
+ env GOEXPERIMENT=fieldtrack,staticlockranking
9
+ go env GOEXPERIMENT
10
+ stdout '.*fieldtrack.*staticlockranking.*'
11
+ go env
12
+ stdout 'GOEXPERIMENT=.*fieldtrack.*staticlockranking.*'
13
+
14
+ # go env rejects unknown experiments
15
+ env GOEXPERIMENT=bad
16
+ ! go env GOEXPERIMENT
17
+ stderr 'unknown GOEXPERIMENT bad'