Skip to content

Testing: some tests kill the testhost from the inside #19406

@majocha

Description

@majocha

StringInterpolation - interpolated strings executes exit 1 in a fsi session, killing the test run:

[<Fact>]
let ``StringInterpolation - interpolated strings``() =
Fsx """
let name = "World"
let count = 42
let greeting = $"Hello, {name}! Count: {count}"
if greeting <> "Hello, World! Count: 42" then exit 1
let formatted = $"Pi is approximately {System.Math.PI:F2}"
if not (formatted.Contains("3.14")) then exit 1
()
"""
|> withOptions ["--nologo"]
|> runFsi
|> shouldSucceed
|> ignore

A safeguard could be to preemptively shadow exit when creating a fsi session:

script.Eval("let exit _ = ...")

The test fails locally because of system language settings. Apparently, I had CurrentUICulture En-US but CurrentCulture pl-PL. The latter decides about formatting.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions