Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Trying to get tests to pass again
  • Loading branch information
TIHan committed Apr 5, 2019
commit 185e86f1c4551336b7dcf8efae3d422c5d115b6a
36 changes: 21 additions & 15 deletions tests/fsharp/Compiler/CompilerAssert.fs
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,26 @@ module CompilerAssert =
Assert.AreEqual(expectedErrorMsg, info.Message, "expectedErrorMsg")
)

let RunScript (source: string) (expectedOutput: string) =
let tmp = Path.GetTempFileName()
let tmpFsx = Path.ChangeExtension(tmp, ".fsx")
let RunScript (source: string) (_expectedOutput: string) =
// Intialize output and input streams
let sbOut = new StringBuilder()
let sbErr = new StringBuilder()
use inStream = new StringReader("")
use outStream = new StringWriter(sbOut)
use errStream = new StringWriter(sbErr)

// Build command line arguments & start FSI session
let argv = [| "C:\\fsi.exe" |]
#if NET472
let allArgs = Array.append argv [|"--noninteractive"|]
#else
let allArgs = Array.append argv [|"--noninteractive"; "--targetprofile:netcore"|]
#endif

let fsiConfig = FsiEvaluationSession.GetDefaultConfiguration()
use fsiSession = FsiEvaluationSession.Create(fsiConfig, allArgs, inStream, outStream, errStream)

try
File.WriteAllText(tmpFsx, source)
let output, errors, exitCode = exec config.FSI [tmpFsx]

if errors.Length > 0 || exitCode <> 0 then
Assert.Fail(sprintf "Exit Code: %i" exitCode)
Assert.Fail(sprintf "%A" errors)

Assert.AreEqual(expectedOutput, output)

finally
try File.Delete(tmp) with | _ -> ()
try File.Delete(tmpFsx) with | _ -> ()
fsiSession.EvalInteraction source |> ignore
with
| _ -> Assert.Fail(errStream.ToString())
2 changes: 1 addition & 1 deletion tests/fsharp/Compiler/Language/SpanTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ test ()
"""

CompilerAssert.RunScript script ""
#endif
#endif