Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os: TestChdirAndGetwd doesn't restore initial working directory on GOOS=js GOARCH=wasm #37448

Closed
odeke-em opened this issue Feb 25, 2020 · 2 comments
Assignees
Milestone

Comments

@odeke-em
Copy link
Member

@odeke-em odeke-em commented Feb 25, 2020

Coming here from a test failure that we noticed from @randall77's CL https://go-review.googlesource.com/c/go/+/219143, we got mysterious failures https://go-review.googlesource.com/c/go/+/219143/4#message-18f33eac583b2d9ebefb682fd3d154824e8e5b58 in which even with getting the current working directory totally failed after I had suggested:

Could we perhaps use the current working directory:

   wd, err := Getwd()
   if err != nil {
	t.Fatal(err)
   }
and then
   filepath.Join(wd, ...)

@neelance came in, in https://go-review.googlesource.com/c/go/+/219143/4#message-031f21fab344d60320d779d0ac6b523de9061b22 letting us know that TestChdirAndGetwd is broken on GOOS=js, GOARCH=wasm with

I found the reason: The test TestChdirAndGetwd is unable to restore the initial working directory. This is because fd.Chdir() does not work correctly if the path of fd is relative. This is because NodeJS does not support fchdir so it has to be emulated with chdir.

Here's a possible solution:

	if path[0] != '/' {
		cwd := jsProcess.Call("cwd").String()
		path = cwd + "/" + path
	}
	f := &jsFile{
		path:    path,
		entries: entries,
	}

which is unrelated to Keith's current CL.

I am filing this issue so that we can address that separately and not block Keith's CL.

@odeke-em odeke-em added this to the Go1.15 milestone Feb 25, 2020
@cagedmantis
Copy link
Contributor

@cagedmantis cagedmantis commented Feb 26, 2020

@gopherbot
Copy link

@gopherbot gopherbot commented Mar 1, 2020

Change https://golang.org/cl/221717 mentions this issue: syscall: fix Fchdir on js/wasm

@gopherbot gopherbot closed this in e44cda3 Mar 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.