Many tests failed in gojs due to needing to be resolved against the CWD,
which is atypically stored host side. This fixes that and renames the
"exit" scope to "proc" so we can use it for other proc concerns besides
exit.
This reduces known failures on GOOS=js from 23 to 14:
```bash
$ wazero run -mount=/usr/local/go/src/os:/:ro -mount=/tmp:/tmp -mount=/etc:/etc:ro -mount=/usr:/usr:ro -mount=/dev:/dev:ro os.wasm |grep '^--- FAIL'|wc -l
14
```
See #1222
Signed-off-by: Adrian Cole <adrian@tetrate.io>
33 lines
767 B
Go
33 lines
767 B
Go
package logging
|
|
|
|
import (
|
|
"github.com/tetratelabs/wazero/api"
|
|
. "github.com/tetratelabs/wazero/internal/assemblyscript"
|
|
"github.com/tetratelabs/wazero/internal/logging"
|
|
)
|
|
|
|
func isProcFunction(fnd api.FunctionDefinition) bool {
|
|
return fnd.ExportNames()[0] == AbortName
|
|
}
|
|
|
|
func isRandomFunction(fnd api.FunctionDefinition) bool {
|
|
return fnd.ExportNames()[0] == SeedName
|
|
}
|
|
|
|
// IsInLogScope returns true if the current function is in any of the scopes.
|
|
func IsInLogScope(fnd api.FunctionDefinition, scopes logging.LogScopes) bool {
|
|
if scopes.IsEnabled(logging.LogScopeProc) {
|
|
if isProcFunction(fnd) {
|
|
return true
|
|
}
|
|
}
|
|
|
|
if scopes.IsEnabled(logging.LogScopeRandom) {
|
|
if isRandomFunction(fnd) {
|
|
return true
|
|
}
|
|
}
|
|
|
|
return scopes == logging.LogScopeAll
|
|
}
|