Allow passing fs.FS when calling functions (#571)
Fixes #563 Signed-off-by: knqyf263 <knqyf263@gmail.com> Co-authored-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"testing/fstest"
|
||||
|
||||
"github.com/tetratelabs/wazero/api"
|
||||
"github.com/tetratelabs/wazero/internal/fs"
|
||||
"github.com/tetratelabs/wazero/internal/testing/require"
|
||||
"github.com/tetratelabs/wazero/internal/wasm"
|
||||
)
|
||||
@@ -438,7 +439,7 @@ func TestModuleConfig_toSysContext(t *testing.T) {
|
||||
nil, // stdout
|
||||
nil, // stderr
|
||||
nil, // randSource
|
||||
map[uint32]*wasm.FileEntry{ // openedFiles
|
||||
map[uint32]*fs.FileEntry{ // openedFiles
|
||||
3: {Path: "/", FS: testFS},
|
||||
4: {Path: ".", FS: testFS},
|
||||
},
|
||||
@@ -455,7 +456,7 @@ func TestModuleConfig_toSysContext(t *testing.T) {
|
||||
nil, // stdout
|
||||
nil, // stderr
|
||||
nil, // randSource
|
||||
map[uint32]*wasm.FileEntry{ // openedFiles
|
||||
map[uint32]*fs.FileEntry{ // openedFiles
|
||||
3: {Path: "/", FS: testFS2},
|
||||
4: {Path: ".", FS: testFS2},
|
||||
},
|
||||
@@ -472,7 +473,7 @@ func TestModuleConfig_toSysContext(t *testing.T) {
|
||||
nil, // stdout
|
||||
nil, // stderr
|
||||
nil, // randSource
|
||||
map[uint32]*wasm.FileEntry{ // openedFiles
|
||||
map[uint32]*fs.FileEntry{ // openedFiles
|
||||
3: {Path: ".", FS: testFS},
|
||||
},
|
||||
),
|
||||
@@ -488,7 +489,7 @@ func TestModuleConfig_toSysContext(t *testing.T) {
|
||||
nil, // stdout
|
||||
nil, // stderr
|
||||
nil, // randSource
|
||||
map[uint32]*wasm.FileEntry{ // openedFiles
|
||||
map[uint32]*fs.FileEntry{ // openedFiles
|
||||
3: {Path: "/", FS: testFS},
|
||||
4: {Path: ".", FS: testFS2},
|
||||
},
|
||||
@@ -505,7 +506,7 @@ func TestModuleConfig_toSysContext(t *testing.T) {
|
||||
nil, // stdout
|
||||
nil, // stderr
|
||||
nil, // randSource
|
||||
map[uint32]*wasm.FileEntry{ // openedFiles
|
||||
map[uint32]*fs.FileEntry{ // openedFiles
|
||||
3: {Path: ".", FS: testFS},
|
||||
4: {Path: "/", FS: testFS2},
|
||||
},
|
||||
@@ -576,7 +577,7 @@ func TestModuleConfig_toSysContext_Errors(t *testing.T) {
|
||||
}
|
||||
|
||||
// requireSysContext ensures wasm.NewSysContext doesn't return an error, which makes it usable in test matrices.
|
||||
func requireSysContext(t *testing.T, max uint32, args, environ []string, stdin io.Reader, stdout, stderr io.Writer, randsource io.Reader, openedFiles map[uint32]*wasm.FileEntry) *wasm.SysContext {
|
||||
func requireSysContext(t *testing.T, max uint32, args, environ []string, stdin io.Reader, stdout, stderr io.Writer, randsource io.Reader, openedFiles map[uint32]*fs.FileEntry) *wasm.SysContext {
|
||||
sys, err := wasm.NewSysContext(max, args, environ, stdin, stdout, stderr, randsource, openedFiles)
|
||||
require.NoError(t, err)
|
||||
return sys
|
||||
|
||||
Reference in New Issue
Block a user