mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-18 03:24:00 +00:00
When running tests under wasmtime, provide a fresh TMPDIR.
Also fix a couple os tests that wrote to current directory to write to os.TempDir() instead. After this, os tests pass in wasi, so add them to the list run by "make tinygo-test-wasi".
This commit is contained in:
@@ -254,6 +254,14 @@ func runPackageTest(config *compileopts.Config, stdout, stderr io.Writer, result
|
||||
// Run in an emulator.
|
||||
args := append(config.Target.Emulator[1:], result.Binary)
|
||||
if config.Target.Emulator[0] == "wasmtime" {
|
||||
// create a new temp directory just for this run, announce it to os.TempDir() via TMPDIR
|
||||
tmpdir, err := ioutil.TempDir("", "tinygotmp")
|
||||
if err != nil {
|
||||
return false, &commandError{"failed to create temporary directory", "tinygotmp", err}
|
||||
}
|
||||
args = append(args, "--dir="+tmpdir, "--env=TMPDIR="+tmpdir)
|
||||
// TODO: add option to not delete temp dir for debugging?
|
||||
defer os.RemoveAll(tmpdir)
|
||||
// allow reading from current directory: --dir=.
|
||||
// mark end of wasmtime arguments and start of program ones: --
|
||||
args = append(args, "--dir=.", "--")
|
||||
|
||||
Reference in New Issue
Block a user