...

Text file src/cmd/go/testdata/script/telemetry.txt

Documentation: cmd/go/testdata/script

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

View as plain text