From 9b4867661458e45b5bd6d7e29a49cd091329d742 Mon Sep 17 00:00:00 2001 From: Jakub Majocha <1760221+majocha@users.noreply.github.com> Date: Fri, 1 Aug 2025 15:59:44 +0200 Subject: [PATCH 1/2] fix runFsi not picking up source from file --- .../resources/tests/Conformance/Printing/WidthForAFormatter.fs | 2 +- tests/FSharp.Test.Utilities/Compiler.fs | 2 +- tests/FSharp.Test.Utilities/CompilerAssert.fs | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/Printing/WidthForAFormatter.fs b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/Printing/WidthForAFormatter.fs index 965eba372f9..849f66782b1 100644 --- a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/Printing/WidthForAFormatter.fs +++ b/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/Printing/WidthForAFormatter.fs @@ -6,7 +6,7 @@ let test = sprintf "%1A" [1..5] = "[1;\n 2;\n 3;\n 4;\n 5]" && sprintf "%13A" [|1..5|] = "[|1; 2; 3; 4;\n 5|]" && - sprintf "%3.1A" {1..3} = "seq\n [1;\n ...]" + sprintf "%3.1A" (seq {1..3}) = "seq\n [1;\n ...]" match test with | false -> raise (new System.Exception("LazyValues03 failed - this should never be forced")) diff --git a/tests/FSharp.Test.Utilities/Compiler.fs b/tests/FSharp.Test.Utilities/Compiler.fs index 2d0695c7369..b155b8bae76 100644 --- a/tests/FSharp.Test.Utilities/Compiler.fs +++ b/tests/FSharp.Test.Utilities/Compiler.fs @@ -1191,7 +1191,7 @@ module rec Compiler = let runFsi (cUnit: CompilationUnit) : CompilationResult = match cUnit with | FS fs -> - let source = fs.Source.GetSourceText |> Option.defaultValue "" + let source = fs.Source.GetSourceText |> Option.defaultWith fs.Source.LoadSourceText let name = fs.Name |> Option.defaultValue "unnamed" let options = fs.Options |> Array.ofList let outputDirectory = diff --git a/tests/FSharp.Test.Utilities/CompilerAssert.fs b/tests/FSharp.Test.Utilities/CompilerAssert.fs index f52a66e92bc..e7f1f98d93a 100644 --- a/tests/FSharp.Test.Utilities/CompilerAssert.fs +++ b/tests/FSharp.Test.Utilities/CompilerAssert.fs @@ -136,6 +136,8 @@ type SourceCodeFileKind = | Fsi s -> s.FileName | Cs s -> s.FileName + member this.LoadSourceText() = FileSystem.OpenFileForReadShim(this.GetSourceFileName).ReadAllText() + member this.GetSourceText = match this with | Fs s -> s.SourceText From 2ff5d19f76e1e7d7a2da7b6588a7a59162784b69 Mon Sep 17 00:00:00 2001 From: Jakub Majocha <1760221+majocha@users.noreply.github.com> Date: Fri, 1 Aug 2025 21:41:12 +0200 Subject: [PATCH 2/2] another --- tests/FSharp.Test.Utilities/Compiler.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/FSharp.Test.Utilities/Compiler.fs b/tests/FSharp.Test.Utilities/Compiler.fs index b155b8bae76..cf227b57a19 100644 --- a/tests/FSharp.Test.Utilities/Compiler.fs +++ b/tests/FSharp.Test.Utilities/Compiler.fs @@ -1137,7 +1137,7 @@ module rec Compiler = let private evalFSharp (fs: FSharpCompilationSource) (script:FSharpScript) : CompilationResult = - let source = fs.Source.GetSourceText |> Option.defaultValue "" + let source = fs.Source.GetSourceText |> Option.defaultWith fs.Source.LoadSourceText use capture = new TestConsole.ExecutionCapture() let result = script.Eval(source) let outputWritten, errorsWritten = capture.OutText, capture.ErrorText