Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/testscript: allow -e flag to pass env value
The -e flag for testscript currently allows the caller to specify that environment variables are inherited from the current environment. However this falls when the current environment does not have a value set and you need to set a specific value. For example: GOBUILD=$(go env GOBUILD) testscript -e GOBUILD script.txt Instead, allow -e to also specify a value: testscript -e GOBUILD=$(go env GOBUILD) script.txt which feels more fluent/natural.
- Loading branch information
Showing
4 changed files
with
33 additions
and
4 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,19 @@ | ||
# Test that passing env values, e.g. ENV1=val, works | ||
|
||
unquote test.txt | ||
|
||
env BLAH2=junk | ||
|
||
testscript -e BLAH1=rubbish -e BLAH2 test.txt | ||
|
||
-- test.txt -- | ||
>exec printf $BLAH1'\n' | ||
>cmp stdout stdout1.txt | ||
> | ||
>exec printf $BLAH2'\n' | ||
>cmp stdout stdout2.txt | ||
> | ||
>-- stdout1.txt -- | ||
>rubbish | ||
>-- stdout2.txt -- | ||
>junk |