From 07608bbfdbcd9901f1adee744ed59e80397d56a0 Mon Sep 17 00:00:00 2001
From: Jakub Majocha <1760221+majocha@users.noreply.github.com>
Date: Sat, 28 Sep 2024 09:43:41 +0200
Subject: [PATCH 1/7] use stdout instead
---
FSharpTests.Directory.Build.targets | 1 +
src/FSharp.Build/Fsi.fs | 9 +
.../ByrefSafetyAnalysis/MigratedTest02.fs | 2 +-
.../Miscellaneous/FsharpSuiteMigrated.fs | 7 +-
.../access.fsx | 2 +-
.../TestCasesForGenerationRoundTrip/array.fsx | 2 +-
.../libtest.fsx | 2 +-
tests/FSharp.Test.Utilities/ScriptHelpers.fs | 63 +++-
tests/FSharp.Test.Utilities/TestFramework.fs | 58 +--
tests/FSharp.Test.Utilities/Utilities.fs | 1 -
.../CodeGen/EmittedIL/StaticMember.fs | 2 +-
tests/fsharp/TypeProviderTests.fs | 27 +-
tests/fsharp/core/access/test.fsx | 2 +-
tests/fsharp/core/anon/test.fsx | 2 +-
tests/fsharp/core/apporder/test.fsx | 2 +-
tests/fsharp/core/array-no-dot/test.fsx | 2 +-
tests/fsharp/core/array/test.fsx | 2 +-
tests/fsharp/core/asyncStackTraces/test.fsx | 2 +-
tests/fsharp/core/attributes/test.fsx | 2 +-
tests/fsharp/core/auto-widen/5.0/test.fsx | 2 +-
tests/fsharp/core/auto-widen/minimal/test.fsx | 2 +-
.../auto-widen/preview-default-warns/test.fsx | 2 +-
tests/fsharp/core/auto-widen/preview/test.fsx | 2 +-
tests/fsharp/core/comprehensions-hw/test.fsx | 2 +-
tests/fsharp/core/comprehensions/test.fsx | 2 +-
tests/fsharp/core/control/test.fsx | 2 +-
tests/fsharp/core/controlChamenos/test.fsx | 2 +-
tests/fsharp/core/controlMailbox/test.fsx | 2 +-
.../fsharp/core/controlStackOverflow/test.fsx | 2 +-
tests/fsharp/core/controlWebExt/test.fsx | 2 +-
tests/fsharp/core/controlWpf/test.fsx | 4 +-
tests/fsharp/core/csext/test.fsx | 2 +-
tests/fsharp/core/enum/test.fsx | 2 +-
tests/fsharp/core/events/test.fs | 2 +-
tests/fsharp/core/fileorder/test.fsx | 2 +-
tests/fsharp/core/forexpression/test.fsx | 2 +-
tests/fsharp/core/fsfromcs/test.cs | 2 +-
tests/fsharp/core/fsfromfsviacs/test.fsx | 2 +-
tests/fsharp/core/fsi-load/test.fsx | 2 +-
tests/fsharp/core/fsi-reference/test.fsx | 2 +-
tests/fsharp/core/fsi-reload/load1.fsx | 2 +-
tests/fsharp/core/fsi-reload/load2.fsx | 2 +-
tests/fsharp/core/fsi-reload/test1.ml | 2 +-
tests/fsharp/core/fsi-shadowcopy/test1.fsx | 3 +-
tests/fsharp/core/fsi-shadowcopy/test2.fsx | 3 +-
tests/fsharp/core/fsiAndModifiers/test.fsx | 2 +-
tests/fsharp/core/genericmeasures/test.fsx | 2 +-
tests/fsharp/core/indent/version46/test.fsx | 2 +-
tests/fsharp/core/indent/version47/test.fsx | 2 +-
tests/fsharp/core/innerpoly/test.fsx | 2 +-
tests/fsharp/core/int32/test.fsx | 2 +-
.../conditionals/LargeConditionals-200.fs | 2 +-
.../LargeConditionals-maxtested.fs | 2 +-
tests/fsharp/core/large/lets/LargeLets-500.fs | 2 +-
.../core/large/lets/LargeLets-maxtested.fs | 2 +-
.../fsharp/core/large/lists/LargeList-500.fs | 2 +-
.../core/large/matches/LargeMatches-200.fs | 2 +-
.../large/matches/LargeMatches-maxtested.fs | 2 +-
.../large/mixed/LargeSequentialLet-500.fs | 2 +-
.../mixed/LargeSequentialLet-maxtested.fs | 2 +-
.../large/sequential/LargeSequential-500.fs | 2 +-
.../sequential/LargeSequential-maxtested.fs | 2 +-
tests/fsharp/core/lazy/test.fsx | 2 +-
tests/fsharp/core/letrec-mutrec/test.fs | 2 +-
tests/fsharp/core/letrec-mutrec2/test.fs | 2 +-
tests/fsharp/core/letrec/test.fsx | 2 +-
tests/fsharp/core/libtest/test.fsx | 2 +-
tests/fsharp/core/lift/test.fsx | 2 +-
tests/fsharp/core/longnames/test.fsx | 2 +-
tests/fsharp/core/map/test.fsx | 2 +-
tests/fsharp/core/math/lalgebra/test.fsx | 2 +-
tests/fsharp/core/math/numbers/test.fsx | 2 +-
tests/fsharp/core/math/numbersVS2008/test.fsx | 2 +-
tests/fsharp/core/measures/test.fsx | 2 +-
.../core/members/basics-hw-mutrec/test.fs | 2 +-
tests/fsharp/core/members/basics-hw/test.fsx | 2 +-
tests/fsharp/core/members/basics/test.fs | 2 +-
tests/fsharp/core/members/ctree/test.fsx | 2 +-
.../core/members/factors-mutrec/test.fs | 2 +-
tests/fsharp/core/members/factors/test.fsx | 2 +-
.../members/incremental-hw-mutrec/test.fsx | 2 +-
.../core/members/incremental-hw/test.fsx | 2 +-
.../fsharp/core/members/incremental/test.fsx | 2 +-
tests/fsharp/core/members/ops-mutrec/test.fs | 2 +-
tests/fsharp/core/members/ops/test.fsx | 2 +-
.../members/self-identifier/version46/test.fs | 2 +-
.../members/self-identifier/version47/test.fs | 2 +-
tests/fsharp/core/nameof/preview/test.fsx | 2 +-
tests/fsharp/core/namespaces/test2.fs | 2 +-
tests/fsharp/core/nested/test.fsx | 2 +-
tests/fsharp/core/patterns/test.fsx | 2 +-
tests/fsharp/core/pinvoke/test.fsx | 2 +-
.../fsharp/core/printf-interpolated/test.fsx | 2 +-
tests/fsharp/core/printf/test.fsx | 2 +-
.../core/queriesCustomQueryOps/test.fsx | 2 +-
.../queriesLeafExpressionConvert/test.fsx | 2 +-
.../core/queriesNullableOperators/test.fsx | 2 +-
.../core/queriesOverIEnumerable/test.fsx | 2 +-
.../core/queriesOverIQueryable/test.fsx | 2 +-
tests/fsharp/core/quotes/test.fsx | 2 +-
tests/fsharp/core/quotesDebugInfo/test.fsx | 2 +-
.../core/quotesInMultipleModules/module2.fsx | 2 +-
tests/fsharp/core/recordResolution/test.fsx | 2 +-
tests/fsharp/core/reflect/test2.fs | 2 +-
tests/fsharp/core/refnormalization/test.fs | 2 +-
tests/fsharp/core/seq/test.fsx | 2 +-
tests/fsharp/core/state-machines/test.fsx | 2 +-
tests/fsharp/core/subtype/test.fsx | 2 +-
tests/fsharp/core/syntax/test.fsx | 2 +-
tests/fsharp/core/tlr/test.fsx | 2 +-
.../core/topinit/test_deterministic_init.fs | 2 +-
tests/fsharp/core/unicode/test.fsx | 2 +-
tests/fsharp/core/unitsOfMeasure/test.fs | 2 +-
tests/fsharp/perf/graph/test.ml | 2 +-
tests/fsharp/perf/nbody/test.ml | 2 +-
tests/fsharp/regression/12322/test.fsx | 2 +-
tests/fsharp/regression/12383/test.fs | 2 +-
tests/fsharp/regression/13219/test.fsx | 2 +-
tests/fsharp/regression/13710/test.fsx | 2 +-
tests/fsharp/regression/26/test.ml | 2 +-
tests/fsharp/regression/321/test.ml | 2 +-
tests/fsharp/regression/655/main.fs | 2 +-
tests/fsharp/regression/656/form.fs | 2 +-
tests/fsharp/regression/83/test.ml | 2 +-
tests/fsharp/regression/84/test.ml | 2 +-
tests/fsharp/regression/86/test.ml | 2 +-
.../OverloadResolution-bug/test.fsx | 2 +-
.../regression/literal-value-bug-2/test.fsx | 2 +-
.../regression/struct-tuple-bug-1/test.fsx | 4 +-
tests/fsharp/regression/tuple-bug-1/test.ml | 2 +-
tests/fsharp/single-test.fs | 96 ++---
tests/fsharp/tests.fs | 335 +++++++-----------
tests/fsharp/tools/eval/test.fsx | 2 +-
.../typeProviders/diamondAssembly/test3.fsx | 2 +-
.../typeProviders/globalNamespace/test.fsx | 2 +-
.../fsharp/typeProviders/helloWorld/test.fsx | 2 +-
.../typeProviders/helloWorldCSharp/test.fsx | 2 +-
.../typeProviders/splitAssemblyTools/test.fsx | 2 +-
.../splitAssemblyTypeproviders/test.fsx | 2 +-
.../typeProviders/wedgeAssembly/test3.fsx | 2 +-
.../typecheck/full-rank-arrays/test.fsx | 2 +-
tests/fsharp/typecheck/misc/test.ml | 2 +-
.../backtickmoduleandtypenames.fsx | 2 +-
tests/scripts/scriptlib.fsx | 5 +-
144 files changed, 388 insertions(+), 488 deletions(-)
diff --git a/FSharpTests.Directory.Build.targets b/FSharpTests.Directory.Build.targets
index 075321e3fb5..bc1e734a1f5 100644
--- a/FSharpTests.Directory.Build.targets
+++ b/FSharpTests.Directory.Build.targets
@@ -33,6 +33,7 @@
WarningLevel="$(WarningLevel)"
WarningsAsErrors="$(WarningsAsErrors)">
+
diff --git a/src/FSharp.Build/Fsi.fs b/src/FSharp.Build/Fsi.fs
index 4e7bd9c4e0a..5359756bb38 100644
--- a/src/FSharp.Build/Fsi.fs
+++ b/src/FSharp.Build/Fsi.fs
@@ -161,6 +161,12 @@ type public Fsi() as this =
builder
+ let outputWriter = new StringWriter()
+
+ override _.LogEventsFromTextOutput(line, msgImportance) =
+ outputWriter.WriteLine(line)
+ base.LogEventsFromTextOutput(line, msgImportance)
+
// --codepage : Specify the codepage to use when opening source files
member _.CodePage
with get () = codePage
@@ -283,6 +289,9 @@ type public Fsi() as this =
with get () = List.toArray commandLineArgs
and set value = commandLineArgs <- List.ofArray value
+ [
-
"
template
|> replace "$(UTILITYSOURCEITEMS)" pc.UtilitySourceItems false false CompileItem.Compile
@@ -209,7 +211,6 @@ let generateProjectArtifacts (pc:ProjectConfiguration) outputType (targetFramewo
|> replaceTokens "$(RestoreFromArtifactsPath)" (Path.GetFullPath(__SOURCE_DIRECTORY__) + "/../../artifacts/packages/" + configuration)
generateProjBody
-let lockObj = obj()
let singleTestBuildAndRunCore cfg copyFiles p languageVersion =
let sources = []
let loadSources = []
@@ -225,22 +226,7 @@ let singleTestBuildAndRunCore cfg copyFiles p languageVersion =
// targetFramework optimize = "net472" OR net5.0 etc ...
// optimize = true or false
let executeSingleTestBuildAndRun outputType compilerType targetFramework optimize buildOnly =
- let mutable result = false
- let directory =
- let mutable result = ""
- lock lockObj <| (fun () ->
- let rec loop () =
- let pathToArtifacts = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "../../../.."))
- if Path.GetFileName(pathToArtifacts) <> "artifacts" then failwith "FSharp.Cambridge did not find artifacts directory --- has the location changed????"
- let pathToTemp = Path.Combine(pathToArtifacts, "Temp")
- let projectDirectory = Path.Combine(pathToTemp, "FSharp.Cambridge", Guid.NewGuid().ToString() + ".tmp")
- if Directory.Exists(projectDirectory) then
- loop ()
- else
- Directory.CreateDirectory(projectDirectory) |>ignore
- projectDirectory
- result <- loop())
- result
+ let directory = cfg.Directory
let pc = {
OutputType = outputType
@@ -269,47 +255,30 @@ let singleTestBuildAndRunCore cfg copyFiles p languageVersion =
let propsFileName = Path.Combine(directory, "Directory.Build.props")
let overridesFileName = Path.Combine(directory, "Directory.Overrides.targets")
let projectFileName = Path.Combine(directory, Guid.NewGuid().ToString() + ".tmp" + ".fsproj")
- try
- // Clean up directory
- Directory.CreateDirectory(directory) |> ignore
- copyFilesToDest cfg.Directory directory
- try File.Delete(Path.Combine(directory, "FSharp.Core.dll")) with _ -> ()
- emitFile targetsFileName targetsBody
- emitFile overridesFileName overridesBody
- let buildOutputFile = Path.Combine(directory, "buildoutput.txt")
- if outputType = OutputType.Exe then
- let executeFsc testCompilerVersion targetFramework =
- let propsBody = generateProps testCompilerVersion cfg.BUILD_CONFIG
- emitFile propsFileName propsBody
- let projectBody = generateProjectArtifacts pc outputType targetFramework cfg.BUILD_CONFIG languageVersion
- emitFile projectFileName projectBody
- use testOkFile = new FileGuard(Path.Combine(directory, "test.ok"))
- let cfg = { cfg with Directory = directory }
- let result = execBothToOutNoCheck cfg directory buildOutputFile cfg.DotNetExe (sprintf "run -f %s" targetFramework)
- if not (buildOnly) then
- result |> checkResult
- testOkFile.CheckExists()
- executeFsc compilerType targetFramework
- if buildOnly then verifyResults (findFirstSourceFile pc) buildOutputFile
- else
- let executeFsi testCompilerVersion targetFramework =
- let propsBody = generateProps testCompilerVersion cfg.BUILD_CONFIG
- emitFile propsFileName propsBody
- let projectBody = generateProjectArtifacts pc outputType targetFramework cfg.BUILD_CONFIG languageVersion
- emitFile projectFileName projectBody
- use testOkFile = new FileGuard(Path.Combine(directory, "test.ok"))
- let cfg = { cfg with Directory = directory }
- execBothToOut cfg directory buildOutputFile cfg.DotNetExe "build /t:RunFSharpScript"
- testOkFile.CheckExists()
- executeFsi compilerType targetFramework
- result <- true
- finally
- if result <> false then
- try Directory.Delete(directory, true) with _ -> ()
- else
- printfn "Configuration: %s" cfg.Directory
- printfn "Directory: %s" directory
- printfn "Filename: %s" projectFileName
+ emitFile targetsFileName targetsBody
+ emitFile overridesFileName overridesBody
+ let buildOutputFile = Path.Combine(directory, "buildoutput.txt")
+ if outputType = OutputType.Exe then
+ let executeFsc testCompilerVersion targetFramework =
+ let propsBody = generateProps testCompilerVersion cfg.BUILD_CONFIG
+ emitFile propsFileName propsBody
+ let projectBody = generateProjectArtifacts pc outputType targetFramework cfg.BUILD_CONFIG languageVersion
+ emitFile projectFileName projectBody
+ let cfg = { cfg with Directory = directory }
+ let result = execBothToOutNoCheck cfg directory buildOutputFile cfg.DotNetExe (sprintf "run -f %s" targetFramework)
+ if not (buildOnly) then
+ result |> checkResultPassed
+ executeFsc compilerType targetFramework
+ if buildOnly then verifyResults (findFirstSourceFile pc) buildOutputFile
+ else
+ let executeFsi testCompilerVersion targetFramework =
+ let propsBody = generateProps testCompilerVersion cfg.BUILD_CONFIG
+ emitFile propsFileName propsBody
+ let projectBody = generateProjectArtifacts pc outputType targetFramework cfg.BUILD_CONFIG languageVersion
+ emitFile projectFileName projectBody
+ let cfg = { cfg with Directory = directory }
+ execBothToOutCheckPassed cfg directory buildOutputFile cfg.DotNetExe $"build /t:RunFSharpScriptAndPrintOutput"
+ executeFsi compilerType targetFramework
match p with
#if NETCOREAPP
@@ -321,19 +290,15 @@ let singleTestBuildAndRunCore cfg copyFiles p languageVersion =
| FSI_NETFX_STDIN ->
use _cleanup = (cleanUpFSharpCore cfg)
- use testOkFile = new FileGuard (getfullpath cfg "test.ok")
let sources = extraSources |> List.filter (fileExists cfg)
- fsiStdin cfg (sources |> List.rev |> List.head) "" [] //use last file, because `cmd < a.txt b.txt` redirect b.txt only
-
- testOkFile.CheckExists()
+ fsiStdinCheckPassed cfg (sources |> List.rev |> List.head) "" [] //use last file, because `cmd < a.txt b.txt` redirect b.txt only
| FSC_NETFX_TEST_ROUNDTRIP_AS_DLL ->
// Compile as a DLL to exercise pickling of interface data, then recompile the original source file referencing this DLL
// The second compilation will not utilize the information from the first in any meaningful way, but the
// compiler will unpickle the interface and optimization data, so we test unpickling as well.
use _cleanup = (cleanUpFSharpCore cfg)
- use testOkFile = new FileGuard (getfullpath cfg "test.ok")
let sources = extraSources |> List.filter (fileExists cfg)
@@ -343,9 +308,8 @@ let singleTestBuildAndRunCore cfg copyFiles p languageVersion =
peverify cfg "test--optimize-lib.dll"
peverify cfg "test--optimize-client-of-lib.exe"
- exec cfg ("." ++ "test--optimize-client-of-lib.exe") ""
+ execAndCheckPassed cfg ("." ++ "test--optimize-client-of-lib.exe") ""
- testOkFile.CheckExists()
#endif
let singleTestBuildAndRunAux cfg p =
diff --git a/tests/fsharp/tests.fs b/tests/fsharp/tests.fs
index 7fdab667a00..ed99adda96a 100644
--- a/tests/fsharp/tests.fs
+++ b/tests/fsharp/tests.fs
@@ -35,37 +35,32 @@ module CoreTests =
let ``subtype-langversion-checknulls`` () =
let cfg = testConfig "core/subtype"
- use testOkFile = fileguard cfg "test.ok"
+
fsc cfg "%s -o:test-checknulls.exe -g --checknulls" cfg.fsc_flags ["test.fsx"]
- exec cfg ("." ++ "test-checknulls.exe") ""
+ execAndCheckPassed cfg ("." ++ "test-checknulls.exe") ""
- testOkFile.CheckExists()
[]
let ``subtype-langversion-no-checknulls`` () =
let cfg = testConfig "core/subtype"
- use testOkFile = fileguard cfg "test.ok"
+
fsc cfg "%s -o:test-no-checknulls.exe -g --checknulls-" cfg.fsc_flags ["test.fsx"]
- exec cfg ("." ++ "test-no-checknulls.exe") ""
+ execAndCheckPassed cfg ("." ++ "test-no-checknulls.exe") ""
- testOkFile.CheckExists()
[]
let ``subtype-langversion-46`` () =
let cfg = testConfig "core/subtype"
- use testOkFile = fileguard cfg "test.ok"
-
fsc cfg "%s -o:test-langversion-46.exe -g --langversion:4.6" cfg.fsc_flags ["test.fsx"]
- exec cfg ("." ++ "test-langversion-46.exe") ""
+ execAndCheckPassed cfg ("." ++ "test-langversion-46.exe") ""
- testOkFile.CheckExists()
#endif
@@ -94,75 +89,71 @@ module CoreTests =
let cfg = { cfg with fsc_flags = sprintf "%s --preferreduilang:en-US --test:StackSpan" cfg.fsc_flags}
begin
- use testOkFile = fileguard cfg "test.ok"
+
singleNegTest cfg "test"
fsc cfg "%s -o:test.exe -g" cfg.fsc_flags ["test.fsx"]
// Execution is disabled until we can be sure .NET 4.7.2 is on the machine
- //exec cfg ("." ++ "test.exe") ""
+ //execAndCheckPassed cfg ("." ++ "test.exe") ""
- //testOkFile.CheckExists()
+ //checkPassed()
end
begin
- use testOkFile = fileguard cfg "test2.ok"
singleNegTest cfg "test2"
fsc cfg "%s -o:test2.exe -g" cfg.fsc_flags ["test2.fsx"]
// Execution is disabled until we can be sure .NET 4.7.2 is on the machine
- //exec cfg ("." ++ "test.exe") ""
+ //execAndCheckPassed cfg ("." ++ "test.exe") ""
- //testOkFile.CheckExists()
+ //checkPassed()
end
begin
- use testOkFile = fileguard cfg "test3.ok"
singleNegTest cfg "test3"
fsc cfg "%s -o:test3.exe -g" cfg.fsc_flags ["test3.fsx"]
// Execution is disabled until we can be sure .NET 4.7.2 is on the machine
- //exec cfg ("." ++ "test.exe") ""
+ //execAndCheckPassed cfg ("." ++ "test.exe") ""
- //testOkFile.CheckExists()
+ //checkPassed()
end
[]
let asyncStackTraces () =
let cfg = testConfig "core/asyncStackTraces"
- use testOkFile = fileguard cfg "test.ok"
+
fsc cfg "%s -o:test.exe -g --tailcalls- --optimize-" cfg.fsc_flags ["test.fsx"]
- exec cfg ("." ++ "test.exe") ""
+ execAndCheckPassed cfg ("." ++ "test.exe") ""
- testOkFile.CheckExists()
[]
let ``state-machines-non-optimized`` () =
let cfg = testConfig "core/state-machines"
- use testOkFile = fileguard cfg "test.ok"
+
fsc cfg "%s -o:test.exe -g --tailcalls- --optimize-" cfg.fsc_flags ["test.fsx"]
peverify cfg "test.exe"
- exec cfg ("." ++ "test.exe") ""
+ execAndCheckPassed cfg ("." ++ "test.exe") ""
- testOkFile.CheckExists()
[]
let ``state-machines-optimized`` () =
let cfg = testConfig "core/state-machines"
- use testOkFile = fileguard cfg "test.ok"
+
fsc cfg "%s -o:test.exe -g --tailcalls+ --optimize+" cfg.fsc_flags ["test.fsx"]
@@ -170,7 +161,6 @@ module CoreTests =
exec cfg ("." ++ "test.exe") ""
- testOkFile.CheckExists()
[]
let ``state-machines neg-resumable-01`` () =
@@ -186,90 +176,79 @@ module CoreTests =
[]
let ``lots-of-conditionals``() =
let cfg = testConfig "core/large/conditionals"
- use testOkFile = fileguard cfg "test.ok"
+
fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeConditionals-200.fs"]
- exec cfg ("." ++ "test.exe") ""
- testOkFile.CheckExists()
+ execAndCheckPassed cfg ("." ++ "test.exe") ""
[]
let ``lots-of-conditionals-maxtested``() =
let cfg = testConfig "core/large/conditionals"
- use testOkFile = fileguard cfg "test.ok"
+
fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeConditionals-maxtested.fs"]
- exec cfg ("." ++ "test.exe") ""
- testOkFile.CheckExists()
+ execAndCheckPassed cfg ("." ++ "test.exe") ""
[]
let ``lots-of-lets``() =
let cfg = testConfig "core/large/lets"
- use testOkFile = fileguard cfg "test.ok"
+
fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeLets-500.fs"]
- exec cfg ("." ++ "test.exe") ""
- testOkFile.CheckExists()
+ execAndCheckPassed cfg ("." ++ "test.exe") ""
[]
let ``lots-of-lets-maxtested``() =
let cfg = testConfig "core/large/lets"
- use testOkFile = fileguard cfg "test.ok"
+
fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeLets-maxtested.fs"]
- exec cfg ("." ++ "test.exe") ""
- testOkFile.CheckExists()
+ execAndCheckPassed cfg ("." ++ "test.exe") ""
[]
let ``lots-of-lists``() =
let cfg = testConfig "core/large/lists"
- use testOkFile = fileguard cfg "test.ok"
+
fsc cfg "%s -o:test-500.exe " cfg.fsc_flags ["LargeList-500.fs"]
- exec cfg ("." ++ "test-500.exe") ""
- testOkFile.CheckExists()
+ execAndCheckPassed cfg ("." ++ "test-500.exe") ""
[]
let ``lots-of-matches``() =
let cfg = testConfig "core/large/matches"
- use testOkFile = fileguard cfg "test.ok"
+
fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeMatches-200.fs"]
- exec cfg ("." ++ "test.exe") ""
- testOkFile.CheckExists()
+ execAndCheckPassed cfg ("." ++ "test.exe") ""
[]
let ``lots-of-matches-maxtested``() =
let cfg = testConfig "core/large/matches"
- use testOkFile = fileguard cfg "test.ok"
+
fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeMatches-maxtested.fs"]
- exec cfg ("." ++ "test.exe") ""
- testOkFile.CheckExists()
+ execAndCheckPassed cfg ("." ++ "test.exe") ""
[]
let ``lots-of-sequential-and-let``() =
let cfg = testConfig "core/large/mixed"
- use testOkFile = fileguard cfg "test.ok"
+
fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeSequentialLet-500.fs"]
- exec cfg ("." ++ "test.exe") ""
- testOkFile.CheckExists()
+ execAndCheckPassed cfg ("." ++ "test.exe") ""
[]
let ``lots-of-sequential-and-let-maxtested``() =
let cfg = testConfig "core/large/mixed"
- use testOkFile = fileguard cfg "test.ok"
+
fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeSequentialLet-maxtested.fs"]
- exec cfg ("." ++ "test.exe") ""
- testOkFile.CheckExists()
+ execAndCheckPassed cfg ("." ++ "test.exe") ""
[]
let ``lots-of-sequential``() =
let cfg = testConfig "core/large/sequential"
- use testOkFile = fileguard cfg "test.ok"
+
fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeSequential-500.fs"]
- exec cfg ("." ++ "test.exe") ""
- testOkFile.CheckExists()
+ execAndCheckPassed cfg ("." ++ "test.exe") ""
[]
let ``lots-of-sequential-maxtested``() =
let cfg = testConfig "core/large/sequential"
- use testOkFile = fileguard cfg "test.ok"
+
fsc cfg "%s -o:test.exe " cfg.fsc_flags ["LargeSequential-maxtested.fs"]
- exec cfg ("." ++ "test.exe") ""
- testOkFile.CheckExists()
+ execAndCheckPassed cfg ("." ++ "test.exe") ""
#endif
@@ -295,19 +274,17 @@ module CoreTests =
peverify cfg "test.exe"
begin
- use testOkFile = fileguard cfg "test.ok"
+
- exec cfg ("." ++ "test.exe") ""
+ execAndCheckPassed cfg ("." ++ "test.exe") ""
- testOkFile.CheckExists()
end
begin
- use testOkFile = fileguard cfg "test.ok"
+
- fsi cfg "-r:lib.dll" ["test.fsx"]
+ fsiCheckPassed cfg "-r:lib.dll" ["test.fsx"]
- testOkFile.CheckExists()
end
[]
@@ -322,13 +299,12 @@ module CoreTests =
peverify cfg "testcs.exe"
- use testOkFile = fileguard cfg "test.ok"
+
- fsi cfg "" ["test.fs"]
+ fsiCheckPassed cfg "" ["test.fs"]
- testOkFile.CheckExists()
- exec cfg ("." ++ "testcs.exe") ""
+ execAndCheckPassed cfg ("." ++ "testcs.exe") ""
//
@@ -355,7 +331,7 @@ module CoreTests =
// fsiStdin cfg "%s %s" cfg.fsi_flags flags "test1.fsx"
//
// // if NOT EXIST test1.ok goto SetError
- // testOkFile.CheckExists()
+ // checkPassed()
//
//
// []
@@ -377,7 +353,7 @@ module CoreTests =
// fsiStdin cfg "%s %s" cfg.fsi_flags flags "test2.fsx"
//
// // if NOT EXIST test2.ok goto SetError
- // testOkFile.CheckExists()
+ // checkPassed()
//
@@ -446,9 +422,9 @@ module CoreTests =
csc cfg """/nologo /r:"%s" /r:System.Core.dll /r:lib--optimize.dll /out:test--optimize.exe""" cfg.FSCOREDLLPATH ["test.cs"]
- exec cfg ("." ++ "test.exe") ""
+ execAndCheckPassed cfg ("." ++ "test.exe") ""
- exec cfg ("." ++ "test--optimize.exe") ""
+ execAndCheckPassed cfg ("." ++ "test--optimize.exe") ""
[]
let fsfromfsviacs () =
@@ -467,21 +443,21 @@ module CoreTests =
peverify cfg "test.exe"
- exec cfg ("." ++ "test.exe") ""
+ execAndCheckPassed cfg ("." ++ "test.exe") ""
// Same with library references the other way around
fsc cfg "%s -r:lib.dll -r:lib3.dll -r:lib2.dll -o:test.exe -g" cfg.fsc_flags ["test.fsx"]
peverify cfg "test.exe"
- exec cfg ("." ++ "test.exe") ""
+ execAndCheckPassed cfg ("." ++ "test.exe") ""
// Same without the reference to lib.dll - testing an incomplete reference set, but only compiling a subset of the code
fsc cfg "%s --define:NO_LIB_REFERENCE -r:lib3.dll -r:lib2.dll -o:test.exe -g" cfg.fsc_flags ["test.fsx"]
peverify cfg "test.exe"
- exec cfg ("." ++ "test.exe") ""
+ execAndCheckPassed cfg ("." ++ "test.exe") ""
// some features missing in 4.7
for version in ["4.7"] do
@@ -509,35 +485,22 @@ module CoreTests =
let cfg = testConfig "core/fsi-reference"
- begin
- use testOkFile = fileguard cfg "test.ok"
+ begin
fsc cfg @"--target:library -o:ImplementationAssembly\ReferenceAssemblyExample.dll" ["ImplementationAssembly.fs"]
fsc cfg @"--target:library -o:ReferenceAssembly\ReferenceAssemblyExample.dll" ["ReferenceAssembly.fs"]
- fsiStdin cfg "test.fsx" "" []
- testOkFile.CheckExists()
+ fsiStdinCheckPassed cfg "test.fsx" "" []
end
[]
let ``fsi-reload`` () =
let cfg = testConfig "core/fsi-reload"
+
+ fsiStdinCheckPassed cfg "test1.ml" " --langversion:5.0 --mlcompatibility --maxerrors:1" []
+
+ fsiCheckPassed cfg "%s --maxerrors:1" cfg.fsi_flags ["load1.fsx"]
- begin
- use testOkFile = fileguard cfg "test.ok"
- fsiStdin cfg "test1.ml" " --langversion:5.0 --mlcompatibility --maxerrors:1" []
- testOkFile.CheckExists()
- end
-
- begin
- use testOkFile = fileguard cfg "test.ok"
- fsi cfg "%s --maxerrors:1" cfg.fsi_flags ["load1.fsx"]
- testOkFile.CheckExists()
- end
-
- begin
- use testOkFile = fileguard cfg "test.ok"
- fsi cfg "%s --maxerrors:1" cfg.fsi_flags ["load2.fsx"]
- testOkFile.CheckExists()
- end
+
+ fsiCheckPassed cfg "%s --maxerrors:1" cfg.fsi_flags ["load2.fsx"]
fsc cfg "" ["load1.fsx"]
fsc cfg "" ["load2.fsx"]
@@ -551,11 +514,7 @@ module CoreTests =
fsiStdin cfg "prepare.fsx" "--maxerrors:1" []
- use testOkFile = fileguard cfg "test.ok"
-
- fsiStdin cfg "test.fsx" "--maxerrors:1" []
-
- testOkFile.CheckExists()
+ fsiStdinCheckPassed cfg "test.fsx" "--maxerrors:1" []
[]
let ``genericmeasures-FSC_NETFX_TEST_ROUNDTRIP_AS_DLL`` () = singleTestBuildAndRun "core/genericmeasures" FSC_NETFX_TEST_ROUNDTRIP_AS_DLL
@@ -595,27 +554,24 @@ module CoreTests =
singleNegTest cfg "negativetest"
begin
- use testOkFile = fileguard cfg "test.ok"
+
- fsi cfg "%s" cfg.fsi_flags ["test.fsx"]
+ fsiCheckPassed cfg "%s" cfg.fsi_flags ["test.fsx"]
- testOkFile.CheckExists()
end
begin
- use testOkFile = fileguard cfg "test.ok"
+
- exec cfg ("." ++ "test.exe") ""
+ execAndCheckPassed cfg ("." ++ "test.exe") ""
- testOkFile.CheckExists()
end
begin
- use testOkFile = fileguard cfg "test.ok"
+
- exec cfg ("." ++ "test--optimize.exe") ""
+ execAndCheckPassed cfg ("." ++ "test--optimize.exe") ""
- testOkFile.CheckExists()
end
// Debug with
@@ -633,10 +589,10 @@ module CoreTests =
let ``fsi b 2>c`` =
// "%FSI%" %fsc_flags_errors_ok% --nologo z.raw.output.test.default.txt 2>&1
- let ``exec b 2>c`` (inFile, outFile, errFile) p =
+ let ``execAndCheckPassed b 2>c`` (inFile, outFile, errFile) p =
Command.exec cfg.Directory cfg.EnvironmentVariables { Output = OutputAndError(Overwrite(outFile), Overwrite(errFile)); Input = Some(RedirectInput(inFile)); } p
>> checkResult
- Printf.ksprintf (fun flags (inFile, outFile, errFile) -> Commands.fsi (``exec b 2>c`` (inFile, outFile, errFile)) cfg.FSI flags [])
+ Printf.ksprintf (fun flags (inFile, outFile, errFile) -> Commands.fsi (``execAndCheckPassed b 2>c`` (inFile, outFile, errFile)) cfg.FSI flags [])
let fsc_flags_errors_ok = ""
@@ -819,9 +775,8 @@ module CoreTests =
peverify cfg "test.exe"
begin
- use testOkFile = fileguard cfg "test.ok"
- exec cfg ("." ++ "test.exe") ""
- testOkFile.CheckExists()
+
+ execAndCheckPassed cfg ("." ++ "test.exe") ""
end
fsc cfg "%s -o:test-with-debug-data.exe --quotations-debug+ -r cslib.dll -g" cfg.fsc_flags ["test.fsx"]
@@ -833,23 +788,20 @@ module CoreTests =
peverify cfg "test--optimize.exe"
begin
- use testOkFile = fileguard cfg "test.ok"
+
- fsi cfg "%s -r cslib.dll" cfg.fsi_flags ["test.fsx"]
+ fsiCheckPassed cfg "%s -r cslib.dll" cfg.fsi_flags ["test.fsx"]
- testOkFile.CheckExists()
end
begin
- use testOkFile = fileguard cfg "test.ok"
- exec cfg ("." ++ "test-with-debug-data.exe") ""
- testOkFile.CheckExists()
+
+ execAndCheckPassed cfg ("." ++ "test-with-debug-data.exe") ""
end
begin
- use testOkFile = fileguard cfg "test.ok"
- exec cfg ("." ++ "test--optimize.exe") ""
- testOkFile.CheckExists()
+
+ execAndCheckPassed cfg ("." ++ "test--optimize.exe") ""
end
// Previously a comment here said:
@@ -948,7 +900,7 @@ module CoreTests =
peverify cfg "test.exe"
- exec cfg ("." ++ "test.exe") ""
+ execAndCheckPassed cfg ("." ++ "test.exe") ""
log "== Compiling F# Library and Code, when empty file libfile2.fs IS included"
fsc cfg "%s -a --optimize -o:lib2.dll " cfg.fsc_flags ["libfile1.fs"; "libfile2.fs"]
@@ -959,7 +911,7 @@ module CoreTests =
peverify cfg "test2.exe"
- exec cfg ("." ++ "test2.exe") ""
+ execAndCheckPassed cfg ("." ++ "test2.exe") ""
// Repro for https://github.com/dotnet/fsharp/issues/2679
[]
@@ -1008,26 +960,24 @@ module CoreTests =
let ``libtest-langversion-checknulls`` () =
let cfg = testConfig "core/libtest"
- use testOkFile = fileguard cfg "test.ok"
+
fsc cfg "%s -o:test-checknulls.exe -g --checknulls" cfg.fsc_flags ["test.fsx"]
- exec cfg ("." ++ "test-checknulls.exe") ""
+ execAndCheckPassed cfg ("." ++ "test-checknulls.exe") ""
- testOkFile.CheckExists()
[]
let ``libtest-langversion-46`` () =
let cfg = testConfig "core/libtest"
- use testOkFile = fileguard cfg "test.ok"
+
fsc cfg "%s -o:test-langversion-46.exe -g --langversion:4.6" cfg.fsc_flags ["test.fsx"]
- exec cfg ("." ++ "test-langversion-46.exe") ""
+ execAndCheckPassed cfg ("." ++ "test-langversion-46.exe") ""
- testOkFile.CheckExists()
[]
let ``no-warn-2003-tests`` () =
@@ -1240,23 +1190,14 @@ module CoreTests =
peverify cfg "test--optimize.exe"
- use testOkFile = fileguard cfg "test.ok"
+ fsiCheckPassed cfg "%s" cfg.fsi_flags ["test.fsx"]
- fsi cfg "%s" cfg.fsi_flags ["test.fsx"]
- testOkFile.CheckExists()
+ execAndCheckPassed cfg ("." ++ "test.exe") ""
- use testOkFile2 = fileguard cfg "test.ok"
- exec cfg ("." ++ "test.exe") ""
+ execAndCheckPassed cfg ("." ++ "test--optimize.exe") ""
- testOkFile2.CheckExists()
-
- use testOkFile3 = fileguard cfg "test.ok"
-
- exec cfg ("." ++ "test--optimize.exe") ""
-
- testOkFile3.CheckExists()
[]
@@ -1271,17 +1212,11 @@ module CoreTests =
peverify cfg "test--optimize.exe"
- use testOkFile = fileguard cfg "test.ok"
- fsi cfg "%s" cfg.fsi_flags ["test.fsx"]
- testOkFile.CheckExists()
+ fsiCheckPassed cfg "%s" cfg.fsi_flags ["test.fsx"]
- use testOkFile2 = fileguard cfg "test.ok"
- exec cfg ("." ++ "test.exe") ""
- testOkFile2.CheckExists()
+ execAndCheckPassed cfg ("." ++ "test.exe") ""
- use testOkFile3 = fileguard cfg "test.ok"
- exec cfg ("." ++ "test--optimize.exe") ""
- testOkFile3.CheckExists()
+ execAndCheckPassed cfg ("." ++ "test--optimize.exe") ""
[]
let queriesOverIEnumerable () =
@@ -1295,23 +1230,15 @@ module CoreTests =
peverify cfg "test--optimize.exe"
- use testOkFile = fileguard cfg "test.ok"
-
- fsi cfg "%s" cfg.fsi_flags ["test.fsx"]
-
- testOkFile.CheckExists()
+
- use testOkFile2 = fileguard cfg "test.ok"
+ fsiCheckPassed cfg "%s" cfg.fsi_flags ["test.fsx"]
- exec cfg ("." ++ "test.exe") ""
- testOkFile2.CheckExists()
+ execAndCheckPassed cfg ("." ++ "test.exe") ""
- use testOkFile3 = fileguard cfg "test.ok"
-
- exec cfg ("." ++ "test--optimize.exe") ""
+ execAndCheckPassed cfg ("." ++ "test--optimize.exe") ""
- testOkFile3.CheckExists()
[]
let queriesOverIQueryable () =
@@ -1325,23 +1252,18 @@ module CoreTests =
peverify cfg "test--optimize.exe"
- use testOkFile = fileguard cfg "test.ok"
- fsi cfg "%s" cfg.fsi_flags ["test.fsx"]
+
+ fsiCheckPassed cfg "%s" cfg.fsi_flags ["test.fsx"]
- testOkFile.CheckExists()
- use testOkFile2 = fileguard cfg "test.ok"
- exec cfg ("." ++ "test.exe") ""
+ execAndCheckPassed cfg ("." ++ "test.exe") ""
- testOkFile2.CheckExists()
- use testOkFile3 = fileguard cfg "test.ok"
- exec cfg ("." ++ "test--optimize.exe") ""
+ execAndCheckPassed cfg ("." ++ "test--optimize.exe") ""
- testOkFile3.CheckExists()
[]
@@ -1356,23 +1278,17 @@ module CoreTests =
peverify cfg "test--optimize.exe"
- use testOkFile = fileguard cfg "test.ok"
- fsi cfg "%s --quotations-debug+" cfg.fsi_flags ["test.fsx"]
-
- testOkFile.CheckExists()
+
+ fsiCheckPassed cfg "%s --quotations-debug+" cfg.fsi_flags ["test.fsx"]
- use testOkFile2 = fileguard cfg "test.ok"
- exec cfg ("." ++ "test.exe") ""
+ execAndCheckPassed cfg ("." ++ "test.exe") ""
- testOkFile2.CheckExists()
- use testOkFile3 = fileguard cfg "test.ok"
- exec cfg ("." ++ "test--optimize.exe") ""
+ execAndCheckPassed cfg ("." ++ "test--optimize.exe") ""
- testOkFile3.CheckExists()
[]
@@ -1399,30 +1315,24 @@ module CoreTests =
peverify cfg "module2-opt.exe"
- use testOkFile = fileguard cfg "test.ok"
-
- fsi cfg "%s -r module1.dll" cfg.fsi_flags ["module2.fsx"]
-
- testOkFile.CheckExists()
+
+ fsiCheckPassed cfg "%s -r module1.dll" cfg.fsi_flags ["module2.fsx"]
- use testOkFile = fileguard cfg "test.ok"
- exec cfg ("." ++ "module2.exe") ""
- testOkFile.CheckExists()
+
- use testOkFile = fileguard cfg "test.ok"
+ execAndCheckPassed cfg ("." ++ "module2.exe") ""
- exec cfg ("." ++ "module2-opt.exe") ""
+
- testOkFile.CheckExists()
+ execAndCheckPassed cfg ("." ++ "module2-opt.exe") ""
- use testOkFile = fileguard cfg "test.ok"
+
- exec cfg ("." ++ "module2-staticlink.exe") ""
+ execAndCheckPassed cfg ("." ++ "module2-staticlink.exe") ""
- testOkFile.CheckExists()
#endif
@@ -1442,26 +1352,23 @@ module CoreTests =
//TestCase1
// Build a program that references v2 of ascendent and v1 of dependent.
// Note that, even though ascendent v2 references dependent v2, the reference is marked as v1.
- use TestOk = fileguard cfg "test.ok"
+
fsc cfg @"%s -o:test1.exe -r:version1\DependentAssembly.dll -r:version2\AscendentAssembly.dll --optimize- -g" cfg.fsc_flags ["test.fs"]
- exec cfg ("." ++ "test1.exe") "DependentAssembly-1.0.0.0 AscendentAssembly-2.0.0.0"
- TestOk.CheckExists()
+ execAndCheckPassed cfg ("." ++ "test1.exe") "DependentAssembly-1.0.0.0 AscendentAssembly-2.0.0.0"
//TestCase2
// Build a program that references v1 of ascendent and v2 of dependent.
// Note that, even though ascendent v1 references dependent v1, the reference is marked as v2 which was passed in.
- use TestOk = fileguard cfg "test.ok"
+
fsc cfg @"%s -o:test2.exe -r:version2\DependentAssembly.dll -r:version1\AscendentAssembly.dll --optimize- -g" cfg.fsc_flags ["test.fs"]
- exec cfg ("." ++ "test2.exe") "DependentAssembly-2.0.0.0 AscendentAssembly-1.0.0.0"
- TestOk.CheckExists()
+ execAndCheckPassed cfg ("." ++ "test2.exe") "DependentAssembly-2.0.0.0 AscendentAssembly-1.0.0.0"
//TestCase3
// Build a program that references v1 of ascendent and v1 and v2 of dependent.
// Verifies that compiler uses first version of a duplicate assembly passed on command line.
- use TestOk = fileguard cfg "test.ok"
+
fsc cfg @"%s -o:test3.exe -r:version1\DependentAssembly.dll -r:version2\DependentAssembly.dll -r:version1\AscendentAssembly.dll --optimize- -g" cfg.fsc_flags ["test.fs"]
- exec cfg ("." ++ "test3.exe") "DependentAssembly-1.0.0.0 AscendentAssembly-1.0.0.0"
- TestOk.CheckExists()
+ execAndCheckPassed cfg ("." ++ "test3.exe") "DependentAssembly-1.0.0.0 AscendentAssembly-1.0.0.0"
[]
@@ -1628,11 +1535,10 @@ module CoreTests =
peverify cfg "test.exe"
- use testOkFile = fileguard cfg "test.ok"
+
- exec cfg ("." ++ "test.exe") ""
+ execAndCheckPassed cfg ("." ++ "test.exe") ""
- testOkFile.CheckExists()
[]
let verify () =
@@ -1867,11 +1773,10 @@ module RegressionTests =
peverify cfg "test.exe"
- use testOkFile = fileguard cfg "test.ok"
+
- exec cfg ("." ++ "test.exe") ""
+ execAndCheckPassed cfg ("." ++ "test.exe") ""
- testOkFile.CheckExists()
// This test is disabled in coreclr builds dependent on fixing : https://github.com/dotnet/fsharp/issues/2600
[]
diff --git a/tests/fsharp/tools/eval/test.fsx b/tests/fsharp/tools/eval/test.fsx
index 69431999bbc..9fb17c1d870 100644
--- a/tests/fsharp/tools/eval/test.fsx
+++ b/tests/fsharp/tools/eval/test.fsx
@@ -2797,5 +2797,5 @@ let _ =
exit 1
else
stdout.WriteLine "Test Passed";
- System.IO.File.WriteAllText("test.ok","ok");
+ printf "TEST PASSED OK";
exit 0
diff --git a/tests/fsharp/typeProviders/diamondAssembly/test3.fsx b/tests/fsharp/typeProviders/diamondAssembly/test3.fsx
index 51e5f1803e7..d3350294831 100644
--- a/tests/fsharp/typeProviders/diamondAssembly/test3.fsx
+++ b/tests/fsharp/typeProviders/diamondAssembly/test3.fsx
@@ -162,7 +162,7 @@ let _ =
if not failures.IsEmpty then (printfn "Test Failed, failures = %A" failures; exit 1)
do (stdout.WriteLine "Test Passed";
- System.IO.File.WriteAllText("test.ok","ok");
+ printf "TEST PASSED OK";
exit 0)
diff --git a/tests/fsharp/typeProviders/globalNamespace/test.fsx b/tests/fsharp/typeProviders/globalNamespace/test.fsx
index 133be281594..f0201d7d252 100644
--- a/tests/fsharp/typeProviders/globalNamespace/test.fsx
+++ b/tests/fsharp/typeProviders/globalNamespace/test.fsx
@@ -24,7 +24,7 @@ let _ =
if not failures.IsEmpty then (printfn "Test Failed, failures = %A" failures; exit 1)
do (stdout.WriteLine "Test Passed";
- System.IO.File.WriteAllText("test.ok","ok");
+ printf "TEST PASSED OK";
exit 0)
diff --git a/tests/fsharp/typeProviders/helloWorld/test.fsx b/tests/fsharp/typeProviders/helloWorld/test.fsx
index e528e8da949..59d811bc5a0 100644
--- a/tests/fsharp/typeProviders/helloWorld/test.fsx
+++ b/tests/fsharp/typeProviders/helloWorld/test.fsx
@@ -1192,7 +1192,7 @@ let _ =
if not failures.IsEmpty then (printfn "Test Failed, failures = %A" failures; exit 1)
do (stdout.WriteLine "Test Passed";
- System.IO.File.WriteAllText("test.ok","ok");
+ printf "TEST PASSED OK";
exit 0)
diff --git a/tests/fsharp/typeProviders/helloWorldCSharp/test.fsx b/tests/fsharp/typeProviders/helloWorldCSharp/test.fsx
index 936e670a305..a4a1fbe3228 100644
--- a/tests/fsharp/typeProviders/helloWorldCSharp/test.fsx
+++ b/tests/fsharp/typeProviders/helloWorldCSharp/test.fsx
@@ -26,7 +26,7 @@ let _ =
if not failures.IsEmpty then (printfn "Test Failed, failures = %A" failures; exit 1)
do (stdout.WriteLine "Test Passed";
- System.IO.File.WriteAllText("test.ok","ok");
+ printf "TEST PASSED OK";
exit 0)
diff --git a/tests/fsharp/typeProviders/splitAssemblyTools/test.fsx b/tests/fsharp/typeProviders/splitAssemblyTools/test.fsx
index e25871ab5f8..ba7cc6b9e34 100644
--- a/tests/fsharp/typeProviders/splitAssemblyTools/test.fsx
+++ b/tests/fsharp/typeProviders/splitAssemblyTools/test.fsx
@@ -26,7 +26,7 @@ let _ =
if not failures.IsEmpty then (printfn "Test Failed, failures = %A" failures; exit 1)
do (stdout.WriteLine "Test Passed";
- System.IO.File.WriteAllText("test.ok","ok");
+ printf "TEST PASSED OK";
exit 0)
diff --git a/tests/fsharp/typeProviders/splitAssemblyTypeproviders/test.fsx b/tests/fsharp/typeProviders/splitAssemblyTypeproviders/test.fsx
index e25871ab5f8..ba7cc6b9e34 100644
--- a/tests/fsharp/typeProviders/splitAssemblyTypeproviders/test.fsx
+++ b/tests/fsharp/typeProviders/splitAssemblyTypeproviders/test.fsx
@@ -26,7 +26,7 @@ let _ =
if not failures.IsEmpty then (printfn "Test Failed, failures = %A" failures; exit 1)
do (stdout.WriteLine "Test Passed";
- System.IO.File.WriteAllText("test.ok","ok");
+ printf "TEST PASSED OK";
exit 0)
diff --git a/tests/fsharp/typeProviders/wedgeAssembly/test3.fsx b/tests/fsharp/typeProviders/wedgeAssembly/test3.fsx
index 7e6125c4be9..1a3c546d17a 100644
--- a/tests/fsharp/typeProviders/wedgeAssembly/test3.fsx
+++ b/tests/fsharp/typeProviders/wedgeAssembly/test3.fsx
@@ -108,7 +108,7 @@ let _ =
if not failures.IsEmpty then (printfn "Test Failed, failures = %A" failures; exit 1)
do (stdout.WriteLine "Test Passed";
- System.IO.File.WriteAllText("test.ok","ok");
+ printf "TEST PASSED OK";
exit 0)
diff --git a/tests/fsharp/typecheck/full-rank-arrays/test.fsx b/tests/fsharp/typecheck/full-rank-arrays/test.fsx
index 0a062adae4a..d8800170979 100644
--- a/tests/fsharp/typecheck/full-rank-arrays/test.fsx
+++ b/tests/fsharp/typecheck/full-rank-arrays/test.fsx
@@ -107,5 +107,5 @@ let _ =
let x = Class1()
x.RunTests()
System.Console.WriteLine "Test Passed";
- System.IO.File.WriteAllText ("test.ok", "ok");
+ printf "TEST PASSED OK"
exit 0
diff --git a/tests/fsharp/typecheck/misc/test.ml b/tests/fsharp/typecheck/misc/test.ml
index 4a2e5c89332..14bc16ae51f 100644
--- a/tests/fsharp/typecheck/misc/test.ml
+++ b/tests/fsharp/typecheck/misc/test.ml
@@ -33,5 +33,5 @@ let _ =
* So avoid using ;;
*)
System.Console.WriteLine "Test Passed";
- System.IO.File.WriteAllText ("test.ok", "ok");
+ printf "TEST PASSED OK";
exit 0
diff --git a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/IdentifiersAndKeywords/backtickmoduleandtypenames.fsx b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/IdentifiersAndKeywords/backtickmoduleandtypenames.fsx
index 20aede76c20..47debdeb71f 100644
--- a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/IdentifiersAndKeywords/backtickmoduleandtypenames.fsx
+++ b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/IdentifiersAndKeywords/backtickmoduleandtypenames.fsx
@@ -75,5 +75,5 @@ let aa =
if !failures then (stdout.WriteLine "Test Failed"; exit 1)
do (stdout.WriteLine "Test Passed";
- System.IO.File.WriteAllText("test.ok","ok");
+ printf "TEST PASSED OK";
exit 0)
diff --git a/tests/scripts/scriptlib.fsx b/tests/scripts/scriptlib.fsx
index b074b78ba25..853aecb496e 100644
--- a/tests/scripts/scriptlib.fsx
+++ b/tests/scripts/scriptlib.fsx
@@ -82,7 +82,7 @@ module Scripting =
type FilePath = string
type CmdResult =
- | Success
+ | Success of output: string
| ErrorLevel of string * int
type CmdArguments =
@@ -156,7 +156,8 @@ module Scripting =
p.WaitForExit()
match p.ExitCode with
- | 0 -> Success
+ | 0 ->
+ Success(string out)
| errCode ->
let msg = sprintf "Error running command '%s' with args '%s' in directory '%s'.\n---- stdout below --- \n%s\n---- stderr below --- \n%s " exePath arguments workDir (out.ToString()) (err.ToString())
ErrorLevel (msg, errCode)
From c26b39851380010b935194177d0047ae7a50e685 Mon Sep 17 00:00:00 2001
From: Jakub Majocha <1760221+majocha@users.noreply.github.com>
Date: Sat, 28 Sep 2024 10:50:17 +0200
Subject: [PATCH 2/7] adjust
---
.../DependencyManagerInteractiveTests.fs | 6 +-
.../FSharpScriptTests.fs | 15 ++--
tests/FSharp.Test.Utilities/Utilities.fs | 72 ++-----------------
3 files changed, 12 insertions(+), 81 deletions(-)
diff --git a/tests/FSharp.Compiler.Private.Scripting.UnitTests/DependencyManagerInteractiveTests.fs b/tests/FSharp.Compiler.Private.Scripting.UnitTests/DependencyManagerInteractiveTests.fs
index 8a1bb95b2d2..cc027d098af 100644
--- a/tests/FSharp.Compiler.Private.Scripting.UnitTests/DependencyManagerInteractiveTests.fs
+++ b/tests/FSharp.Compiler.Private.Scripting.UnitTests/DependencyManagerInteractiveTests.fs
@@ -760,10 +760,9 @@ x |> Seq.iter(fun r ->
if found = expected.Length then sawExpectedOutput.Set() |> ignore
let text = "#help"
- use output = new RedirectConsoleOutput()
use script = new FSharpScript(quiet = false, langVersion = LangVersion.V47)
let mutable found = 0
- output.OutputProduced.Add (fun line -> verifyOutput line)
+ script.OutputProduced.Add (fun line -> verifyOutput line)
let opt = script.Eval(text) |> getValue
Assert.True(sawExpectedOutput.WaitOne(TimeSpan.FromSeconds(5.0)), sprintf "Expected to see error sentinel value written\nexpected:%A\nactual:%A" expected lines)
@@ -811,10 +810,9 @@ x |> Seq.iter(fun r ->
if found = expected.Length then sawExpectedOutput.Set() |> ignore
let text = "#help"
- use output = new RedirectConsoleOutput()
use script = new FSharpScript(quiet = false, langVersion = LangVersion.Preview)
let mutable found = 0
- output.OutputProduced.Add (fun line -> verifyOutput line)
+ script.OutputProduced.Add (fun line -> verifyOutput line)
let opt = script.Eval(text) |> getValue
Assert.True(sawExpectedOutput.WaitOne(TimeSpan.FromSeconds(5.0)), sprintf "Expected to see error sentinel value written\nexpected:%A\nactual:%A" expected lines)
diff --git a/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs b/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs
index 08fa3ec324d..f89cc49e6e2 100644
--- a/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs
+++ b/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs
@@ -83,9 +83,7 @@ x
[]
member _.``Capture console input``() =
- use input = new RedirectConsoleInput()
- use script = new FSharpScript()
- input.ProvideInput "stdin:1234\r\n"
+ use script = new FSharpScript(input = "stdin:1234\r\n")
let opt = script.Eval("System.Console.ReadLine()") |> getValue
let value = opt.Value
Assert.Equal(typeof, value.ReflectionType)
@@ -93,12 +91,11 @@ x
[]
member _.``Capture console output/error``() =
- use output = new RedirectConsoleOutput()
use script = new FSharpScript()
use sawOutputSentinel = new ManualResetEvent(false)
use sawErrorSentinel = new ManualResetEvent(false)
- output.OutputProduced.Add (fun line -> if line = "stdout:1234" then sawOutputSentinel.Set() |> ignore)
- output.ErrorProduced.Add (fun line -> if line = "stderr:5678" then sawErrorSentinel.Set() |> ignore)
+ script.OutputProduced.Add (fun line -> if line = "stdout:1234" then sawOutputSentinel.Set() |> ignore)
+ script.ErrorProduced.Add (fun line -> if line = "stderr:5678" then sawErrorSentinel.Set() |> ignore)
script.Eval("printfn \"stdout:1234\"; eprintfn \"stderr:5678\"") |> ignoreValue
Assert.True(sawOutputSentinel.WaitOne(TimeSpan.FromSeconds(5.0)), "Expected to see output sentinel value written")
Assert.True(sawErrorSentinel.WaitOne(TimeSpan.FromSeconds(5.0)), "Expected to see error sentinel value written")
@@ -305,11 +302,10 @@ printfn ""%A"" result
[]
member _.``Eval script with invalid PackageName should fail immediately``() =
- use output = new RedirectConsoleOutput()
use script = new FSharpScript(additionalArgs=[| |])
let mutable found = 0
let outp = System.Collections.Generic.List()
- output.OutputProduced.Add(
+ script.OutputProduced.Add(
fun line ->
if line.Contains("error NU1101:") && line.Contains("FSharp.Really.Not.A.Package") then
found <- found + 1
@@ -321,10 +317,9 @@ printfn ""%A"" result
[]
member _.``Eval script with invalid PackageName should fail immediately and resolve one time only``() =
- use output = new RedirectConsoleOutput()
use script = new FSharpScript(additionalArgs=[| |])
let mutable foundResolve = 0
- output.OutputProduced.Add (fun line -> if line.Contains("error NU1101:") then foundResolve <- foundResolve + 1)
+ script.OutputProduced.Add (fun line -> if line.Contains("error NU1101:") then foundResolve <- foundResolve + 1)
let result, errors =
script.Eval("""
#r "nuget:FSharp.Really.Not.A.Package"
diff --git a/tests/FSharp.Test.Utilities/Utilities.fs b/tests/FSharp.Test.Utilities/Utilities.fs
index fb59739c2df..6ed885d4e44 100644
--- a/tests/FSharp.Test.Utilities/Utilities.fs
+++ b/tests/FSharp.Test.Utilities/Utilities.fs
@@ -40,83 +40,21 @@ type FactForDESKTOPAttribute() =
// This file mimics how Roslyn handles their compilation references for compilation testing
module Utilities =
-
- type CapturedTextReader() =
- inherit TextReader()
- let queue = Queue()
- member _.ProvideInput(text: string) =
- for c in text.ToCharArray() do
- queue.Enqueue(c)
- override _.Peek() =
- if queue.Count > 0 then queue.Peek() |> int else -1
- override _.Read() =
- if queue.Count > 0 then queue.Dequeue() |> int else -1
-
- type RedirectConsoleInput() =
- let oldStdIn = Console.In
- let newStdIn = new CapturedTextReader()
- do Console.SetIn(newStdIn)
- member _.ProvideInput(text: string) =
- newStdIn.ProvideInput(text)
- interface IDisposable with
- member _.Dispose() =
- Console.SetIn(oldStdIn)
- newStdIn.Dispose()
-
- type EventedTextWriter() =
- inherit TextWriter()
- let sb = StringBuilder()
- let lineWritten = Event()
- member _.LineWritten = lineWritten.Publish
- override _.Encoding = Encoding.UTF8
- override _.Write(c: char) =
- if c = '\n' then
- let line =
- let v = sb.ToString()
- if v.EndsWith("\r") then v.Substring(0, v.Length - 1)
- else v
- sb.Clear() |> ignore
- lineWritten.Trigger(line)
- else sb.Append(c) |> ignore
-
- type RedirectConsoleOutput() =
- let outputProduced = Event()
- let errorProduced = Event()
+ type RedirectConsole() =
let oldStdOut = Console.Out
let oldStdErr = Console.Error
- let newStdOut = new EventedTextWriter()
- let newStdErr = new EventedTextWriter()
-
- do newStdOut.LineWritten.Add outputProduced.Trigger
- do newStdErr.LineWritten.Add errorProduced.Trigger
+ let newStdOut = new StringWriter()
+ let newStdErr = new StringWriter()
do Console.SetOut(newStdOut)
do Console.SetError(newStdErr)
+ member _.Output () = string newStdOut
- member _.OutputProduced = outputProduced.Publish
-
- member _.ErrorProduced = errorProduced.Publish
+ member _.ErrorOutput () =string newStdErr
interface IDisposable with
member _.Dispose() =
Console.SetOut(oldStdOut)
Console.SetError(oldStdErr)
- newStdOut.Dispose()
- newStdErr.Dispose()
-
- type RedirectConsole() =
- let redirector = new RedirectConsoleOutput()
- let outputLines = StringBuilder()
- let errorLines = StringBuilder()
-
- do redirector.OutputProduced.Add (fun line -> lock outputLines <| fun () -> outputLines.AppendLine line |>ignore)
- do redirector.ErrorProduced.Add(fun line -> lock errorLines <| fun () -> errorLines.AppendLine line |>ignore)
-
- member _.Output () = lock outputLines outputLines.ToString
-
- member _.ErrorOutput () = lock errorLines errorLines.ToString
-
- interface IDisposable with
- member _.Dispose() = (redirector :> IDisposable).Dispose()
type Async with
static member RunImmediate (computation: Async<'T>, ?cancellationToken ) =
From cd93a37128c79c57de907ef87cec7df6f02f986e Mon Sep 17 00:00:00 2001
From: Jakub Majocha <1760221+majocha@users.noreply.github.com>
Date: Mon, 30 Sep 2024 15:38:54 +0200
Subject: [PATCH 3/7] separate fsi tooltask for tests
---
FSharpTests.Directory.Build.targets | 7 ++++---
src/FSharp.Build/FSharp.Build.fsproj | 1 +
src/FSharp.Build/Fsi.fs | 9 ---------
src/FSharp.Build/FsiTestTask.fs | 20 ++++++++++++++++++++
4 files changed, 25 insertions(+), 12 deletions(-)
create mode 100644 src/FSharp.Build/FsiTestTask.fs
diff --git a/FSharpTests.Directory.Build.targets b/FSharpTests.Directory.Build.targets
index bc1e734a1f5..6f08b425d24 100644
--- a/FSharpTests.Directory.Build.targets
+++ b/FSharpTests.Directory.Build.targets
@@ -1,13 +1,14 @@
-
+
-
-
+
<_CoreCompileResourceInputs Remove="@(_CoreCompileResourceInputs)" />
diff --git a/src/FSharp.Build/FSharp.Build.fsproj b/src/FSharp.Build/FSharp.Build.fsproj
index 3c392ef1158..378e36b2f77 100644
--- a/src/FSharp.Build/FSharp.Build.fsproj
+++ b/src/FSharp.Build/FSharp.Build.fsproj
@@ -38,6 +38,7 @@
+
diff --git a/src/FSharp.Build/Fsi.fs b/src/FSharp.Build/Fsi.fs
index 5359756bb38..4e7bd9c4e0a 100644
--- a/src/FSharp.Build/Fsi.fs
+++ b/src/FSharp.Build/Fsi.fs
@@ -161,12 +161,6 @@ type public Fsi() as this =
builder
- let outputWriter = new StringWriter()
-
- override _.LogEventsFromTextOutput(line, msgImportance) =
- outputWriter.WriteLine(line)
- base.LogEventsFromTextOutput(line, msgImportance)
-
// --codepage : Specify the codepage to use when opening source files
member _.CodePage
with get () = codePage
@@ -289,9 +283,6 @@ type public Fsi() as this =
with get () = List.toArray commandLineArgs
and set value = commandLineArgs <- List.ofArray value
- [