@@ -26,12 +26,31 @@ open System.IO
2626
2727[<TestFixture>]
2828type CompilerTest () =
29- let sourceFilename = @" ..\..\..\tests\test.naggum"
29+ static let testExtension = " naggum"
30+ static let resultExtension = " result"
31+ static let executableExtension = " exe"
32+
33+ static let directory = @" ..\..\..\tests"
34+ static let filenames = [ @" test" ]
3035
31- [<Test>]
32- member this.RunTest () =
33- let filename = " test.exe"
36+ static member private RunTest testName =
37+ let basePath = Path.Combine( directory, testName)
38+ let testPath = Path.ChangeExtension( basePath, testExtension)
39+ let resultPath = Path.ChangeExtension( basePath, resultExtension)
40+ let executablePath = Path.ChangeExtension( testName, executableExtension)
41+
42+ use stream = File.Open( testPath, FileMode.Open)
43+ Generator.compile stream testName executablePath []
44+
45+ let startInfo = new ProcessStartInfo( executablePath, UseShellExecute = false , RedirectStandardOutput = true )
46+ let ``process`` = Process.Start startInfo
47+ `` process `` .WaitForExit()
48+ let result = `` process `` .StandardOutput.ReadToEnd()
3449
35- use stream = File.Open( sourceFilename, FileMode.Open)
36- Generator.compile stream " test" filename []
37- ignore <| ( Process.Start filename) .WaitForExit( 30000 ) // 30 sec should be enough
50+ let reference = File.ReadAllText resultPath
51+ Assert.AreEqual( reference, result)
52+
53+ [<Test>]
54+ member this.RunTests () =
55+ filenames
56+ |> List.iter CompilerTest.RunTest
0 commit comments