# Tests for the telemetry subcommand, # The script test framework sets TEST_TELEMETRY_DIR (overriding the # default telemetry dir location) and then checks that at least one # counter has been written per script tests. # Run go before unsetting TEST_TELEMETRY_DIR to make the tests happy. # We want to unset it so the environment we're testing is as close # to a user's environment. go help telemetry env TEST_TELEMETRY_DIR= # Set userconfig dir, which is determined by os.UserConfigDir. # The telemetry dir is determined using that. mkdir $WORK/userconfig env AppData=$WORK\userconfig # windows [GOOS:windows] env userconfig=$AppData env HOME=$WORK/userconfig # darwin,unix,ios [GOOS:darwin] env userconfig=$HOME'/Library/Application Support' [GOOS:ios] env userconfig=$HOME'/Library/Application Support' [!GOOS:windows] [!GOOS:darwin] [!GOOS:ios] [!GOOS:plan9] env userconfig=$HOME/.config env home=$WORK/userconfig # plan9 [GOOS:plan9] env userconfig=$home/lib go telemetry stdout 'local' go telemetry off go telemetry stdout 'off' go env GOTELEMETRY stdout 'off' go telemetry local go telemetry stdout 'local' go env GOTELEMETRY stdout 'local' go telemetry on go telemetry stdout 'on' go env GOTELEMETRY stdout 'on' go env stdout 'GOTELEMETRY=''?on''?' stdout 'GOTELEMETRYDIR=''?'$userconfig'[\\/]go[\\/]telemetry''?' ! go env -w GOTELEMETRY=off stderr '^go: GOTELEMETRY cannot be modified$' ! go env -w GOTELEMETRYDIR=foo stderr '^go: GOTELEMETRYDIR cannot be modified$' # Test issue #69269: 'go telemetry off' should not increment counters. # Establish that previous commands did write telemetry files. # Only check for the existence of telemetry data on supported platforms. [!GOOS:openbsd] [!GOOS:solaris] [!GOOS:android] [!GOOS:illumos] [!GOOS:js] [!GOOS:wasip1] [!GOOS:plan9] [!GOARCH:mips] [!GOARCH:mipsle] exists $userconfig/go/telemetry/local # Now check for go telemetry off behavior. rm $userconfig/go/telemetry/local go telemetry off ! exists $userconfig/go/telemetry/local # Check for the behavior with -C, the only flag 'go telemetry off' can take. go telemetry local go -C $WORK telemetry off ! exists $userconfig/go/telemetry/local go telemetry local go telemetry -C=$WORK off ! exists $userconfig/go/telemetry/local go telemetry local go help telemetry [!GOOS:openbsd] [!GOOS:solaris] [!GOOS:android] [!GOOS:illumos] [!GOOS:js] [!GOOS:wasip1] [!GOOS:plan9] [!GOARCH:mips] [!GOARCH:mipsle] exists $userconfig/go/telemetry/local