Skip to content

Commit 61bf0d1

Browse files
committed
path/filepath: add test for directory junction walk
For #10424. Change-Id: Ie4e87503b0ed04f65d2444652bd1db647d3529f4 Reviewed-on: https://go-review.googlesource.com/36851 Reviewed-by: Brad Fitzpatrick <[email protected]> Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 45c6f59 commit 61bf0d1

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

src/path/filepath/path_windows_test.go

+42
Original file line numberDiff line numberDiff line change
@@ -433,3 +433,45 @@ func TestUNC(t *testing.T) {
433433
defer debug.SetMaxStack(debug.SetMaxStack(1e6))
434434
filepath.Glob(`\\?\c:\*`)
435435
}
436+
437+
func TestWalkDirectoryJunction(t *testing.T) {
438+
t.Skip("skipping broken test: see issue 10424")
439+
440+
output, _ := exec.Command("cmd", "/c", "mklink", "/?").Output()
441+
if !strings.Contains(string(output), " /J ") {
442+
t.Skip(`skipping test; mklink does not supports directory junctions`)
443+
}
444+
445+
tmpdir, err := ioutil.TempDir("", "TestWalkDirectoryJunction")
446+
if err != nil {
447+
t.Fatal(err)
448+
}
449+
defer os.RemoveAll(tmpdir)
450+
451+
wd, err := os.Getwd()
452+
if err != nil {
453+
t.Fatal(err)
454+
}
455+
defer os.Chdir(wd)
456+
457+
err = os.Chdir(tmpdir)
458+
if err != nil {
459+
t.Fatal(err)
460+
}
461+
462+
output, err = exec.Command("cmd", "/c", "mklink", "/J", "link", tmpdir).CombinedOutput()
463+
if err != nil {
464+
t.Errorf(`"mklink link %v" command failed: %v\n%v`, tmpdir, err, string(output))
465+
}
466+
467+
walkfunc := func(path string, info os.FileInfo, err error) error {
468+
if err != nil {
469+
t.Log(err)
470+
}
471+
return nil
472+
}
473+
err = filepath.Walk(tmpdir, walkfunc)
474+
if err != nil {
475+
t.Fatal(err)
476+
}
477+
}

0 commit comments

Comments
 (0)