-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/testscript: add support to pass through env vars with -e (#54)
- Loading branch information
Showing
5 changed files
with
302 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# 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" |
Oops, something went wrong.