diff options
| author | Alex Brainman <alex.brainman@gmail.com> | 2017-02-13 14:52:19 +1100 |
|---|---|---|
| committer | Alex Brainman <alex.brainman@gmail.com> | 2017-04-05 02:31:45 +0000 |
| commit | acc1f47299620bb558a21e4144b7535fd904f377 (patch) | |
| tree | 4e7b62abadd35e397d468694d7137a1eb631a557 /src/path/filepath/path_windows_test.go | |
| parent | 4c1622082e493dea24a936930be8b324aae54505 (diff) | |
| download | go-acc1f47299620bb558a21e4144b7535fd904f377.tar.xz | |
path/filepath: add test to walk symlink
For #17540.
Change-Id: Ie01f39797526934fa553f4279cbde6c7cbf14154
Reviewed-on: https://go-review.googlesource.com/36854
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/path/filepath/path_windows_test.go')
| -rw-r--r-- | src/path/filepath/path_windows_test.go | 55 |
1 files changed, 20 insertions, 35 deletions
diff --git a/src/path/filepath/path_windows_test.go b/src/path/filepath/path_windows_test.go index 795b1f1bb8..0663778744 100644 --- a/src/path/filepath/path_windows_test.go +++ b/src/path/filepath/path_windows_test.go @@ -7,6 +7,7 @@ package filepath_test import ( "flag" "fmt" + "internal/testenv" "io/ioutil" "os" "os/exec" @@ -434,44 +435,28 @@ func TestUNC(t *testing.T) { filepath.Glob(`\\?\c:\*`) } -func TestWalkDirectoryJunction(t *testing.T) { - t.Skip("skipping broken test: see issue 10424") - +func testWalkMklink(t *testing.T, linktype string) { output, _ := exec.Command("cmd", "/c", "mklink", "/?").Output() - if !strings.Contains(string(output), " /J ") { - t.Skip(`skipping test; mklink does not supports directory junctions`) - } - - tmpdir, err := ioutil.TempDir("", "TestWalkDirectoryJunction") - if err != nil { - t.Fatal(err) - } - defer os.RemoveAll(tmpdir) - - wd, err := os.Getwd() - if err != nil { - t.Fatal(err) - } - defer os.Chdir(wd) - - err = os.Chdir(tmpdir) - if err != nil { - t.Fatal(err) + if !strings.Contains(string(output), fmt.Sprintf(" /%s ", linktype)) { + t.Skipf(`skipping test; mklink does not supports /%s parameter`, linktype) } - - output, err = exec.Command("cmd", "/c", "mklink", "/J", "link", tmpdir).CombinedOutput() - if err != nil { - t.Errorf(`"mklink link %v" command failed: %v\n%v`, tmpdir, err, string(output)) - } - - walkfunc := func(path string, info os.FileInfo, err error) error { + testWalkSymlink(t, func(target, link string) error { + output, err := exec.Command("cmd", "/c", "mklink", "/"+linktype, link, target).CombinedOutput() if err != nil { - t.Log(err) + return fmt.Errorf(`"mklink /%s %v %v" command failed: %v\n%v`, linktype, link, target, err, string(output)) } return nil - } - err = filepath.Walk(tmpdir, walkfunc) - if err != nil { - t.Fatal(err) - } + }) +} + +func TestWalkDirectoryJunction(t *testing.T) { + testenv.MustHaveSymlink(t) + t.Skip("skipping broken test: see issue 10424") + testWalkMklink(t, "J") +} + +func TestWalkDirectorySymlink(t *testing.T) { + testenv.MustHaveSymlink(t) + t.Skip("skipping broken test: see issue 17540") + testWalkMklink(t, "D") } |
