# Test passing environment variables to scripts with the go command on PATH # # Below where we check the output of testscript -v, we have to match against # the string literal $WORK because testscript rewrites the actual directory # to $WORK. Hence we don't want to expand this script's $WORK in such a comparison. # # This is the counterpart to env_var_no_go.txt unquote noproxy.txt unquote withproxy.txt # Baseline testscript -v noproxy.txt stdout ^BANANA=$ stdout '^GOPATH=\$WORK[/\\]gopath'$ [!go1.13] stdout ^GOPROXY=$ [go1.13] stdout ^GOPROXY=https://proxy.golang.org,direct$ ! stderr .+ env BANANA=banana env GOPATH=$WORK/ourgopath env GOPROXY= # no GOPROXY, no pass-through, no proxy testscript -v noproxy.txt stdout ^BANANA=$ stdout '^GOPATH=\$WORK[/\\]gopath'$ [!go1.13] stdout ^GOPROXY=$ [go1.13] stdout ^GOPROXY=https://proxy.golang.org,direct$ ! stderr .+ # no GOPROXY, no pass-through, with proxy testscript -v withproxy.txt stdout ^BANANA=$ stdout '^GOPATH=\$WORK[/\\]gopath'$ stdout ^GOPROXY=http://.*/mod$ ! stderr .+ # no GOPROXY, with pass-through, no proxy testscript -v -e BANANA -e GOPATH -e GOPROXY noproxy.txt stdout ^BANANA=banana$ stdout ^GOPATH=${WORK@R}[/\\]ourgopath$ stdout ^GOPROXY=$ ! stderr .+ # no GOPROXY, with pass-through, with proxy testscript -v -e BANANA -e GOPATH -e GOPROXY withproxy.txt stdout ^BANANA=banana$ stdout ^GOPATH=${WORK@R}[/\\]ourgopath$ stdout ^GOPROXY=$ ! stderr .+ setfilegoproxy $WORK/proxy # with GOPROXY, no pass-through, no proxy testscript -v noproxy.txt stdout ^BANANA=$ stdout '^GOPATH=\$WORK[/\\]gopath'$ stdout ^GOPROXY=$GOPROXY$ ! stderr .+ # with GOPROXY, no pass-through, with proxy testscript -v withproxy.txt stdout ^BANANA=$ stdout '^GOPATH=\$WORK[/\\]gopath'$ stdout ^GOPROXY=http://.*/mod$ ! stderr .+ # with GOPROXY, with pass-through, no proxy testscript -v -e BANANA -e GOPATH -e GOPROXY noproxy.txt stdout ^BANANA=banana$ stdout ^GOPATH=${WORK@R}[/\\]ourgopath$ stdout ^GOPROXY=$GOPROXY$ ! stderr .+ # with GOPROXY, with pass-through, with proxy testscript -v -e BANANA -e GOPATH -e GOPROXY withproxy.txt stdout ^BANANA=banana$ stdout ^GOPATH=${WORK@R}[/\\]ourgopath$ stdout ^GOPROXY=$GOPROXY$ ! stderr .+ -- noproxy.txt -- >env BANANA >env GOPATH >env GOPROXY -- withproxy.txt -- >env BANANA >env GOPATH >env GOPROXY >-- .gomodproxy/fruit.com_v1.0.0/.mod -- >module fruit.com > >-- .gomodproxy/fruit.com_v1.0.0/.info -- >{"Version":"v1.0.0","Time":"2018-10-22T18:45:39Z"} > >-- .gomodproxy/fruit.com_v1.0.0/go.mod -- >module fruit.com > >-- .gomodproxy/fruit.com_v1.0.0/fruit/fruit.go -- >package fruit > >const Apple = "apple" >-- .gomodproxy/fruit.com_v1.0.0/coretest/coretest.go -- >// package coretest becomes a candidate for the missing >// core import in main above >package coretest > >const Mandarin = "mandarin"