It is now possible for tests to pass on windows

This commit is contained in:
Sasha Koshka 2024-03-31 00:39:43 -04:00
parent 93d4aea1b1
commit 88e10158ae
2 changed files with 21 additions and 12 deletions

View File

@ -111,7 +111,7 @@ func testUnit (
} }
// run the executable file (with timeout) and check its output // 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) ctx, cancel := context.WithTimeout(context.Background(), timeoutDuration)
defer cancel() defer cancel()
executableCommand := exec.CommandContext(ctx, executablePath, args...) executableCommand := exec.CommandContext(ctx, executablePath, args...)

View File

@ -1,18 +1,26 @@
package compiler package compiler
import "testing" import "testing"
import "runtime"
var nativeLineBreak = "\n"
func init () {
if runtime.GOOS == "windows" {
nativeLineBreak = "\r\n"
}
}
func TestHelloWorld (test *testing.T) { func TestHelloWorld (test *testing.T) {
testUnit (test, testUnit (test,
"/test-data/data/hello", nil, "/test-data/data/hello", nil,
"", "Hello, world!\n", "", "Hello, world!" + nativeLineBreak,
0, 0,
)} )}
func TestPuts (test *testing.T) { func TestPuts (test *testing.T) {
testUnit (test, testUnit (test,
"/test-data/data/puts", nil, "/test-data/data/puts", nil,
"", "hello\n", "", "hello" + nativeLineBreak,
0, 0,
)} )}
@ -26,7 +34,7 @@ testUnit (test,
func TestSystemInclude (test *testing.T) { func TestSystemInclude (test *testing.T) {
testUnit (test, testUnit (test,
"/test-data/data/system-include", nil, "/test-data/data/system-include", nil,
"", "Hello, /usr/include!\n", "", "Hello, /usr/include!" + nativeLineBreak,
0, 0,
)} )}
@ -36,7 +44,7 @@ dependencies := []string {
} }
testUnit (test, testUnit (test,
"/test-data/data/system-src", dependencies, "/test-data/data/system-src", dependencies,
"", "Hello, /usr/src!\n", "", "Hello, /usr/src!" + nativeLineBreak,
0, 0,
)} )}
@ -68,7 +76,7 @@ dependencies := []string {
} }
testUnit (test, testUnit (test,
"/test-data/data/writer", dependencies, "/test-data/data/writer", dependencies,
"", "well hello their\n", "", "well hello their" + nativeLineBreak,
0, 0,
)} )}
@ -85,7 +93,7 @@ dependencies := []string {
} }
testUnit (test, testUnit (test,
"/test-data/data/match-print", dependencies, "/test-data/data/match-print", dependencies,
"", "F64\n", "", "F64" + nativeLineBreak,
0, 0,
)} )}
@ -95,7 +103,7 @@ dependencies := []string {
} }
testUnit (test, testUnit (test,
"/test-data/data/match-default-print", dependencies, "/test-data/data/match-default-print", dependencies,
"", "something else\n", "", "something else" + nativeLineBreak,
0, 0,
)} )}
@ -112,7 +120,7 @@ dependencies := []string {
} }
testUnit (test, testUnit (test,
"/test-data/data/return-assign", dependencies, "/test-data/data/return-assign", dependencies,
"", "false\n", "", "false" + nativeLineBreak,
0, 0,
)} )}
@ -143,7 +151,8 @@ dependencies := []string {
} }
testUnit (test, testUnit (test,
"/test-data/data/for-string-array", dependencies, "/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, 0,
)} )}
@ -153,7 +162,7 @@ dependencies := []string {
} }
testUnit (test, testUnit (test,
"/test-data/data/for-string-array-once", dependencies, "/test-data/data/for-string-array-once", dependencies,
"", "abc\n", "", "abc" + nativeLineBreak,
0, 0,
)} )}
@ -163,6 +172,6 @@ dependencies := []string {
} }
testUnit (test, testUnit (test,
"/test-data/data/for-break-branch", dependencies, "/test-data/data/for-break-branch", dependencies,
"", "iter\niter\n", "", "iter" + nativeLineBreak + "iter" + nativeLineBreak,
0, 0,
)} )}