# Test passing environment variables to scripts with no go command on PATH
#
# This is the counterpart to env_var_with_go.txt

unquote noproxy.txt
unquote withproxy.txt
dropgofrompath

env BANANA=banana
env GOPATH=$WORK/ourgopath

env GOPROXY=

# no GOPROXY, no pass-through, no proxy
testscript -v noproxy.txt
stdout ^BANANA=$
stdout ^GOPATH=$
stdout ^GOPROXY=$
! stderr .+

# no GOPROXY, no pass-through, with proxy
testscript -v withproxy.txt
stdout ^BANANA=$
stdout ^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=$
stdout ^GOPROXY=$
! stderr .+

# with GOPROXY, no pass-through, with proxy
testscript -v withproxy.txt
stdout ^BANANA=$
stdout ^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"
