diff options
author | Damian Gryski <[email protected]> | 2023-03-31 09:08:37 -0700 |
---|---|---|
committer | Damian Gryski <[email protected]> | 2023-03-31 13:06:23 -0700 |
commit | 50d681359d79089feeee3118bc8b9dcfac578dca (patch) | |
tree | 77e8815998dd1ba6ab6e43727d8cd1205315f170 /main.go | |
parent | d50c54fce00c542c889027246659935a8599a0a4 (diff) | |
download | tinygo-50d681359d79089feeee3118bc8b9dcfac578dca.tar.gz tinygo-50d681359d79089feeee3118bc8b9dcfac578dca.zip |
main: set WASMTIME_BACKTRACE_DETAILS when running in wasmtime.
I find myself consistently running tests, seeing them panic, and then
immediately running them again with this environment variable set. It's
easier to just have tinygo do this for me.
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -792,6 +792,7 @@ func buildAndRun(pkgName string, config *compileopts.Config, stdout io.Writer, c } } var args, env []string + var extraCmdEnv []string if needsEnvInVars { runtimeGlobals := make(map[string]string) if len(cmdArgs) != 0 { @@ -822,6 +823,11 @@ func buildAndRun(pkgName string, config *compileopts.Config, stdout io.Writer, c args = append(args, "--") args = append(args, cmdArgs...) } + + // Set this for nicer backtraces during tests, but don't override the user. + if _, ok := os.LookupEnv("WASMTIME_BACKTRACE_DETAILS"); !ok { + extraCmdEnv = append(extraCmdEnv, "WASMTIME_BACKTRACE_DETAILS=1") + } } else { // Pass environment variables and command line parameters as usual. // This also works on qemu-aarch64 etc. @@ -873,7 +879,8 @@ func buildAndRun(pkgName string, config *compileopts.Config, stdout io.Writer, c } else { cmd = exec.Command(name, args...) } - cmd.Env = env + cmd.Env = append(cmd.Env, env...) + cmd.Env = append(cmd.Env, extraCmdEnv...) // Configure stdout/stderr. The stdout may go to a buffer, not a real // stdout. |