rogpeppe / go-internal

Selected Go-internal packages factored out from the standard library
BSD 3-Clause "New" or "Revised" License
823 stars 67 forks source link

testscript: Expose Environ() to custom commands #251

Open abhinav opened 1 month ago

abhinav commented 1 month ago

This adds an Environ method to TestScript that looks and acts similarly to os.Environ.

This gives further visibility into the test script state to custom command implementations, allowing them to implement functionality that is otherwise limited only to the built-in commands.

For example, combining this and MkAbs, a custom command can use os/exec to run a command with the same environment as the test script, with different behavior than the built-in TestScript.Exec method.