From 80ee343e6d922589b655fd00933606375ab63bd8 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Sat, 27 Apr 2019 17:46:45 +0200 Subject: [PATCH] main: make tests more portable Windows uses backward slashes instead of forward slashes, so be compatible with that. --- main_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main_test.go b/main_test.go index b25708d6..fa85a82c 100644 --- a/main_test.go +++ b/main_test.go @@ -20,12 +20,12 @@ import ( const TESTDATA = "testdata" func TestCompiler(t *testing.T) { - matches, err := filepath.Glob(TESTDATA + "/*.go") + matches, err := filepath.Glob(filepath.Join(TESTDATA, "*.go")) if err != nil { t.Fatal("could not read test files:", err) } - dirMatches, err := filepath.Glob(TESTDATA + "/*/main.go") + dirMatches, err := filepath.Glob(filepath.Join(TESTDATA, "*", "main.go")) if err != nil { t.Fatal("could not read test packages:", err) } @@ -66,7 +66,7 @@ func TestCompiler(t *testing.T) { if runtime.GOOS == "linux" { t.Log("running tests for linux/arm...") for _, path := range matches { - if path == "testdata/cgo/" { + if path == filepath.Join("testdata", "cgo")+string(filepath.Separator) { continue // TODO: improve CGo } t.Run(path, func(t *testing.T) { @@ -76,7 +76,7 @@ func TestCompiler(t *testing.T) { t.Log("running tests for linux/arm64...") for _, path := range matches { - if path == "testdata/cgo/" { + if path == filepath.Join("testdata", "cgo")+string(filepath.Separator) { continue // TODO: improve CGo } t.Run(path, func(t *testing.T) { @@ -86,7 +86,7 @@ func TestCompiler(t *testing.T) { t.Log("running tests for WebAssembly...") for _, path := range matches { - if path == "testdata/gc.go" { + if path == filepath.Join("testdata", "gc.go") { continue // known to fail } t.Run(path, func(t *testing.T) { @@ -99,7 +99,7 @@ func TestCompiler(t *testing.T) { func runTest(path, tmpdir string, target string, t *testing.T) { // Get the expected output for this test. txtpath := path[:len(path)-3] + ".txt" - if path[len(path)-1] == '/' { + if path[len(path)-1] == os.PathSeparator { txtpath = path + "out.txt" } f, err := os.Open(txtpath)