diff --git a/compiler/common_test.go b/compiler/common_test.go index 52fbe67..b31de48 100644 --- a/compiler/common_test.go +++ b/compiler/common_test.go @@ -111,7 +111,7 @@ func testUnit ( } // run the executable file (with timeout) and check its output - timeoutDuration := 1000 * time.Millisecond + timeoutDuration := 4000 * time.Millisecond ctx, cancel := context.WithTimeout(context.Background(), timeoutDuration) defer cancel() executableCommand := exec.CommandContext(ctx, executablePath, args...) diff --git a/compiler/compiler_test.go b/compiler/compiler_test.go index cfb15e3..19b7fcf 100644 --- a/compiler/compiler_test.go +++ b/compiler/compiler_test.go @@ -1,18 +1,26 @@ package compiler import "testing" +import "runtime" + +var nativeLineBreak = "\n" +func init () { + if runtime.GOOS == "windows" { + nativeLineBreak = "\r\n" + } +} func TestHelloWorld (test *testing.T) { testUnit (test, "/test-data/data/hello", nil, -"", "Hello, world!\n", +"", "Hello, world!" + nativeLineBreak, 0, )} func TestPuts (test *testing.T) { testUnit (test, "/test-data/data/puts", nil, -"", "hello\n", +"", "hello" + nativeLineBreak, 0, )} @@ -26,7 +34,7 @@ testUnit (test, func TestSystemInclude (test *testing.T) { testUnit (test, "/test-data/data/system-include", nil, -"", "Hello, /usr/include!\n", +"", "Hello, /usr/include!" + nativeLineBreak, 0, )} @@ -36,7 +44,7 @@ dependencies := []string { } testUnit (test, "/test-data/data/system-src", dependencies, -"", "Hello, /usr/src!\n", +"", "Hello, /usr/src!" + nativeLineBreak, 0, )} @@ -68,7 +76,7 @@ dependencies := []string { } testUnit (test, "/test-data/data/writer", dependencies, -"", "well hello their\n", +"", "well hello their" + nativeLineBreak, 0, )} @@ -85,7 +93,7 @@ dependencies := []string { } testUnit (test, "/test-data/data/match-print", dependencies, -"", "F64\n", +"", "F64" + nativeLineBreak, 0, )} @@ -95,7 +103,7 @@ dependencies := []string { } testUnit (test, "/test-data/data/match-default-print", dependencies, -"", "something else\n", +"", "something else" + nativeLineBreak, 0, )} @@ -112,7 +120,7 @@ dependencies := []string { } testUnit (test, "/test-data/data/return-assign", dependencies, -"", "false\n", +"", "false" + nativeLineBreak, 0, )} @@ -143,7 +151,8 @@ dependencies := []string { } testUnit (test, "/test-data/data/for-string-array", dependencies, -"", "a\nb\nc\na\nb\nc\n", +"", "a" + nativeLineBreak + "b" + nativeLineBreak + "c" + nativeLineBreak + + "a" + nativeLineBreak + "b" + nativeLineBreak + "c" + nativeLineBreak, 0, )} @@ -153,7 +162,7 @@ dependencies := []string { } testUnit (test, "/test-data/data/for-string-array-once", dependencies, -"", "abc\n", +"", "abc" + nativeLineBreak, 0, )} @@ -163,6 +172,6 @@ dependencies := []string { } testUnit (test, "/test-data/data/for-break-branch", dependencies, -"", "iter\niter\n", +"", "iter" + nativeLineBreak + "iter" + nativeLineBreak, 0, )}