Run windows valid path test cases only if runtime.GOOS == "windows"

This commit is contained in:
Elliot Morrison-Reed 2016-08-26 18:11:33 +02:00
parent 6296a316b8
commit 895387ad4b

View file

@ -52,28 +52,23 @@ func TestInPath(t *testing.T) {
{"/bar/foo", "/bar/foo/baz", true}, {"/bar/foo", "/bar/foo/baz", true},
{"/bar/foo/baz", "/bar/foo", false}, {"/bar/foo/baz", "/bar/foo", false},
{"/bar/foo", "/bar/foo/.wierd..dirname/", true}, {"/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" { if runtime.GOOS == "windows" {
cases = append( cases = append(
cases, cases,
inPathTestCase{"C:/Bar/foo", "c:/bar/foo/baz", true}, inPathTestCase{"C:/Bar/foo", "c:/bar/foo/baz", true},
) inPathTestCase{"c:\\bar\\foo", "C:\\bar\\foo", false},
} else { inPathTestCase{"c:\\bar\\..\\bar\\foo", "C:\\bar\\foo\\baz", true},
cases = append(
cases,
inPathTestCase{"C:/Bar/foo", "c:/bar/foo/baz", false},
) )
} }
for _, tc := range cases { for _, tc := range cases {
ip := inPath(tc.Src, tc.Prj) ip := inPath(tc.Src, tc.Prj)
if tc.InPath != ip { if tc.InPath != ip {
if tc.InPath { if ip {
t.Errorf("Unexpected %s determined as inside %s", tc.Prj, tc.Src)
} else {
t.Errorf("Unexpected %s determined as not inside %s", tc.Prj, tc.Src) 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)
} }
} }
} }