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

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


Copy link

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

Coming here from a test failure that we noticed from @randall77's CL, we got mysterious failures 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 {
and then
   filepath.Join(wd, ...)

@neelance came in, in 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
Copy link

@cagedmantis cagedmantis commented Feb 26, 2020

Copy link

@gopherbot gopherbot commented Mar 1, 2020

Change 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
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.