From 895387ad4b2436395dbbe94ed3d48b6ab4dcf564 Mon Sep 17 00:00:00 2001 From: Elliot Morrison-Reed Date: Fri, 26 Aug 2016 18:11:33 +0200 Subject: [PATCH] Run windows valid path test cases only if runtime.GOOS == "windows" --- cobra/cmd/helpers_test.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/cobra/cmd/helpers_test.go b/cobra/cmd/helpers_test.go index 437f9860..f929e19f 100644 --- a/cobra/cmd/helpers_test.go +++ b/cobra/cmd/helpers_test.go @@ -52,28 +52,23 @@ func TestInPath(t *testing.T) { {"/bar/foo", "/bar/foo/baz", true}, {"/bar/foo/baz", "/bar/foo", false}, {"/bar/foo", "/bar/foo/.wierd..dirname/", true}, - {"c:\\bar\\foo", "C:\\bar\\foo", false}, - {"c:\\bar\\..\\bar\\foo", "C:\\bar\\foo\\baz", true}, } if runtime.GOOS == "windows" { cases = append( cases, inPathTestCase{"C:/Bar/foo", "c:/bar/foo/baz", true}, - ) - } else { - cases = append( - cases, - inPathTestCase{"C:/Bar/foo", "c:/bar/foo/baz", false}, + inPathTestCase{"c:\\bar\\foo", "C:\\bar\\foo", false}, + inPathTestCase{"c:\\bar\\..\\bar\\foo", "C:\\bar\\foo\\baz", true}, ) } for _, tc := range cases { ip := inPath(tc.Src, tc.Prj) if tc.InPath != ip { - if tc.InPath { - t.Errorf("Unexpected %s determined as inside %s", tc.Prj, tc.Src) - } else { + if ip { t.Errorf("Unexpected %s determined as not inside %s", tc.Prj, tc.Src) + } else { + t.Errorf("Unexpected %s determined as inside %s", tc.Prj, tc.Src) } } }