Skip to content

Commit 9239c61

Browse files
dkegel-fastlydeadprogram
authored andcommitted
TestChdir: avoid cd .., as wasi does not really support it yet. Tiptoes around #2799.
1 parent 008b373 commit 9239c61

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/os/file_anyos_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,14 @@ func TestTempDir(t *testing.T) {
3131

3232
func TestChdir(t *testing.T) {
3333
// create and cd into a new directory
34+
oldDir, err := Getwd()
35+
if err != nil {
36+
t.Errorf("Getwd() returned %v", err)
37+
return
38+
}
3439
dir := "_os_test_TestChDir"
3540
Remove(dir)
36-
err := Mkdir(dir, 0755)
41+
err = Mkdir(dir, 0755)
3742
defer Remove(dir) // even though not quite sure which directory it will execute in
3843
if err != nil {
3944
t.Errorf("Mkdir(%s, 0755) returned %v", dir, err)
@@ -55,7 +60,9 @@ func TestChdir(t *testing.T) {
5560
t.Errorf("Close %s: %s", file, err)
5661
}
5762
// cd back to original directory
58-
err = Chdir("..")
63+
// TODO: emulate "cd .." in wasi-libc better?
64+
//err = Chdir("..")
65+
err = Chdir(oldDir)
5966
if err != nil {
6067
t.Errorf("Chdir ..: %s", err)
6168
}

0 commit comments

Comments
 (0)