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: unknown go command variable GOTELEMETRY$'
50 ! go env -w GOTELEMETRYDIR=foo
51 stderr '^go: unknown go command variable GOTELEMETRYDIR$'
View as plain text