Improved Windows support

This commit is contained in:
2024-08-14 13:41:22 +02:00
parent 9d0077d1a4
commit 235188e457
3 changed files with 18 additions and 10 deletions

View File

@ -33,12 +33,12 @@ func TestExamples(t *testing.T) {
t.Run(test.Name+"/debug", func(t *testing.T) {
config.ConstantFold = false
run(t, directory, "debug", test.Name, test.Input, test.Output, test.ExitCode)
run(t, directory, "debug", test.Input, test.Output, test.ExitCode)
})
t.Run(test.Name+"/release", func(t *testing.T) {
config.ConstantFold = true
run(t, directory, "release", test.Name, test.Input, test.Output, test.ExitCode)
run(t, directory, "release", test.Input, test.Output, test.ExitCode)
})
}
}

View File

@ -66,12 +66,12 @@ func TestPrograms(t *testing.T) {
t.Run(test.Name+"/debug", func(t *testing.T) {
config.ConstantFold = false
run(t, file, "debug", test.Name, test.Input, test.Output, test.ExitCode)
run(t, file, "debug", test.Input, test.Output, test.ExitCode)
})
t.Run(test.Name+"/release", func(t *testing.T) {
config.ConstantFold = true
run(t, file, "release", test.Name, test.Input, test.Output, test.ExitCode)
run(t, file, "release", test.Input, test.Output, test.ExitCode)
})
}
}
@ -90,16 +90,17 @@ func BenchmarkPrograms(b *testing.B) {
}
// run builds and runs the file to check if the output matches the expected output.
func run(t *testing.T, path string, version string, name string, input string, expectedOutput string, expectedExitCode int) {
func run(t *testing.T, path string, version string, input string, expectedOutput string, expectedExitCode int) {
b := build.New(path)
result, err := b.Run()
assert.Nil(t, err)
directory := filepath.Join(os.TempDir(), "q", version)
err = os.MkdirAll(directory, 0755)
tmpDir := filepath.Join(os.TempDir(), "q", version)
err = os.MkdirAll(tmpDir, 0755)
assert.Nil(t, err)
executable := filepath.Join(directory, name)
executable := b.Executable()
executable = filepath.Join(tmpDir, filepath.Base(executable))
err = result.WriteFile(executable)
assert.Nil(t, err)