1 # Tests for the telemetry subcommand,
2
3 # The script test framework sets TEST_TELEMETRY_DIR (overriding the
4 # default telemetry dir location) and then checks that at least one
5 # counter has been written per script tests.
6 # Run go before unsetting TEST_TELEMETRY_DIR to make the tests happy.
7 # We want to unset it so the environment we're testing is as close
8 # to a user's environment.
9 go help telemetry
10 env TEST_TELEMETRY_DIR=
11
12 # Set userconfig dir, which is determined by os.UserConfigDir.
13 # The telemetry dir is determined using that.
14 mkdir $WORK/userconfig
15 env AppData=$WORK\userconfig # windows
16 [GOOS:windows] env userconfig=$AppData
17 env HOME=$WORK/userconfig # darwin,unix,ios
18 [GOOS:darwin] env userconfig=$HOME'/Library/Application Support'
19 [GOOS:ios] env userconfig=$HOME'/Library/Application Support'
20 [!GOOS:windows] [!GOOS:darwin] [!GOOS:ios] [!GOOS:plan9] env userconfig=$HOME/.config
21 env home=$WORK/userconfig # plan9
22 [GOOS:plan9] env userconfig=$home/lib
23
24 go telemetry
25 stdout 'local'
26
27 go telemetry off
28 go telemetry
29 stdout 'off'
30 go env GOTELEMETRY
31 stdout 'off'
32
33 go telemetry local
34 go telemetry
35 stdout 'local'
36 go env GOTELEMETRY
37 stdout 'local'
38
39 go telemetry on
40 go telemetry
41 stdout 'on'
42 go env GOTELEMETRY
43 stdout 'on'
44
45 go env
46 stdout 'GOTELEMETRY=''?on''?'
47 stdout 'GOTELEMETRYDIR=''?'$userconfig'[\\/]go[\\/]telemetry''?'
48 ! go env -w GOTELEMETRY=off
49 stderr '^go: GOTELEMETRY cannot be modified$'
50 ! go env -w GOTELEMETRYDIR=foo
51 stderr '^go: GOTELEMETRYDIR cannot be modified$'
52
53 # Test issue #69269: 'go telemetry off' should not increment counters.
54 # Establish that previous commands did write telemetry files.
55 # Only check for the existence of telemetry data on supported platforms.
56 [!GOOS:openbsd] [!GOOS:solaris] [!GOOS:android] [!GOOS:illumos] [!GOOS:js] [!GOOS:wasip1] [!GOOS:plan9] [!GOARCH:mips] [!GOARCH:mipsle] exists $userconfig/go/telemetry/local
57 # Now check for go telemetry off behavior.
58 rm $userconfig/go/telemetry/local
59 go telemetry off
60 ! exists $userconfig/go/telemetry/local
61 # Check for the behavior with -C, the only flag 'go telemetry off' can take.
62 go telemetry local
63 go -C $WORK telemetry off
64 ! exists $userconfig/go/telemetry/local
65 go telemetry local
66 go telemetry -C=$WORK off
67 ! exists $userconfig/go/telemetry/local
68 go telemetry local
69 go help telemetry
70 [!GOOS:openbsd] [!GOOS:solaris] [!GOOS:android] [!GOOS:illumos] [!GOOS:js] [!GOOS:wasip1] [!GOOS:plan9] [!GOARCH:mips] [!GOARCH:mipsle] exists $userconfig/go/telemetry/local
71
View as plain text