Compare commits

...

3 Commits

Author SHA1 Message Date
Hajime Hoshi
098380ce06 .github/workflows: update wasmbrowsertest
Updates #2982
2024-09-06 12:26:58 +09:00
Hajime Hoshi
3e0c2c10bd .github/workflows: specify -test.paniconexit0=false for browsers
Closes #3075
2024-09-06 11:32:21 +09:00
Hajime Hoshi
daa85d17c2 internal/file: bug fix: VirtualFS.Open(".") should always return a new entry
Closes #3081
2024-09-06 10:46:35 +09:00
2 changed files with 19 additions and 7 deletions

View File

@ -42,11 +42,15 @@ jobs:
sudo apt-get update
sudo apt-get install libasound2-dev libgl1-mesa-dev libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev libxxf86vm-dev
- name: Install Chrome
uses: browser-actions/setup-chrome@latest
- name: Install wasmbrowsertest
run: |
go install github.com/agnivade/wasmbrowsertest@ee76d31b7b9b1645576c1f51fec4c09fe6cf1bb3
wasmbrowsertest_version=06679196c7e76f227e71456cdc16fccd6cc33601
go install github.com/agnivade/wasmbrowsertest@${wasmbrowsertest_version}
mv $(go env GOPATH)/bin/wasmbrowsertest${{ runner.os == 'Windows' && '.exe' || '' }} $(go env GOPATH)/bin/go_js_wasm_exec${{ runner.os == 'Windows' && '.exe' || '' }}
go install github.com/agnivade/wasmbrowsertest/cmd/cleanenv@ee76d31b7b9b1645576c1f51fec4c09fe6cf1bb3
go install github.com/agnivade/wasmbrowsertest/cmd/cleanenv@${wasmbrowsertest_version}
- name: Prepare ebitenmobile test
run: |
@ -171,7 +175,7 @@ jobs:
run: |
# Wasm tests don't work on macOS with the headless mode, and the headless mode doesn't work in GitHub Actions (#2972).
# Wasm tests don't work on Windows well due to mysterious timeouts (#2982).
env GOOS=js GOARCH=wasm cleanenv -remove-prefix GITHUB_ -remove-prefix JAVA_ -remove-prefix PSModulePath -remove-prefix STATS_ -remove-prefix RUNNER_ -- go test -shuffle=on -v ./...
env GOOS=js GOARCH=wasm cleanenv -remove-prefix GITHUB_ -remove-prefix JAVA_ -remove-prefix PSModulePath -remove-prefix STATS_ -remove-prefix RUNNER_ -- go test -shuffle=on -v ./... -test.paniconexit0=false
- name: Install ebitenmobile
run: |

View File

@ -29,15 +29,22 @@ import (
)
type VirtualFS struct {
root virtualFSRoot
paths []string
}
func NewVirtualFS(paths []string) *VirtualFS {
fs := &VirtualFS{}
fs.root.addRealPaths(paths)
fs.paths = make([]string, len(paths))
copy(fs.paths, paths)
return fs
}
func (v *VirtualFS) newRootFS() *virtualFSRoot {
var root virtualFSRoot
root.addRealPaths(v.paths)
return &root
}
func (v *VirtualFS) Open(name string) (fs.File, error) {
if !fs.ValidPath(name) {
return nil, &fs.PathError{
@ -48,15 +55,16 @@ func (v *VirtualFS) Open(name string) (fs.File, error) {
}
if name == "." {
return &v.root, nil
return v.newRootFS(), nil
}
// A valid path must not include a token "." or "..", except for "." itself.
es := strings.Split(name, "/")
for _, realPath := range v.root.realPaths {
for _, realPath := range v.paths {
if filepath.Base(realPath) != es[0] {
continue
}
// TODO: Does this work on Windows?
return os.Open(filepath.Join(append([]string{realPath}, es[1:]...)...))
}