...
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.
9go help telemetry
10env TEST_TELEMETRY_DIR=
11
12# Set userconfig dir, which is determined by os.UserConfigDir.
13# The telemetry dir is determined using that.
14mkdir $WORK/userconfig
15env AppData=$WORK\userconfig # windows
16[GOOS:windows] env userconfig=$AppData
17env 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
21env home=$WORK/userconfig # plan9
22[GOOS:plan9] env userconfig=$home/lib
23
24go telemetry
25stdout 'local'
26
27go telemetry off
28go telemetry
29stdout 'off'
30go env GOTELEMETRY
31stdout 'off'
32
33go telemetry local
34go telemetry
35stdout 'local'
36go env GOTELEMETRY
37stdout 'local'
38
39go telemetry on
40go telemetry
41stdout 'on'
42go env GOTELEMETRY
43stdout 'on'
44
45go env
46stdout 'GOTELEMETRY=''?on''?'
47stdout 'GOTELEMETRYDIR=''?'$userconfig'[\\/]go[\\/]telemetry''?'
48! go env -w GOTELEMETRY=off
49stderr '^go: GOTELEMETRY cannot be modified$'
50! go env -w GOTELEMETRYDIR=foo
51stderr '^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.
58rm $userconfig/go/telemetry/local
59go telemetry off
60! exists $userconfig/go/telemetry/local
61# Check for the behavior with -C, the only flag 'go telemetry off' can take.
62go telemetry local
63go -C $WORK telemetry off
64! exists $userconfig/go/telemetry/local
65go telemetry local
66go telemetry -C=$WORK off
67! exists $userconfig/go/telemetry/local
68go telemetry local
69go 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
View as plain text