fstest

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 28, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package fstest defines filesystem test cases that help validate host functions implementing WASI and `GOOS=js GOARCH=wasm`. Tests are defined here to reduce duplication and drift.

Here's an example using this inside code that compiles to wasm.

if err := fstest.WriteTestFiles(tmpDir); err != nil {
	log.Panicln(err)
}
if err := fstest.TestFS(os.DirFS(tmpDir)); err != nil {
	log.Panicln(err)
}

Failures found here should result in new tests in the appropriate package, for example, gojs, sysfs or wasi_snapshot_preview1.

This package must have no dependencies. Otherwise, compiling this with TinyGo or `GOOS=js GOARCH=wasm` can become bloated or complicated.

Index

Constants

This section is empty.

Variables

View Source
var FS = func() fstest.MapFS {
	testFS := make(fstest.MapFS, len(files))
	for _, nf := range files {
		testFS[nf.name] = nf.file
	}
	return testFS
}()

FS includes all test files.

Functions

func TestFS

func TestFS(testfs fs.FS) error

TestFS runs fstest.TestFS on the given input which is either FS or includes files written by WriteTestFiles.

func WriteTestFiles

func WriteTestFiles(tmpDir string) (err error)

WriteTestFiles writes files defined in FS to the given directory. This is used for implementations like os.DirFS.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL