diff --git a/FSharpTests.Directory.Build.targets b/FSharpTests.Directory.Build.targets
index 075321e3fb5..2e0b335b411 100644
--- a/FSharpTests.Directory.Build.targets
+++ b/FSharpTests.Directory.Build.targets
@@ -7,33 +7,35 @@
Returns=""
DependsOnTargets="$(CoreCompileDependsOn)"
>
-
-
-
+
+
+
+
<_CoreCompileResourceInputs Remove="@(_CoreCompileResourceInputs)" />
diff --git a/src/FSharp.Build/Fsi.fs b/src/FSharp.Build/Fsi.fs
index 4e7bd9c4e0a..dc362420db0 100644
--- a/src/FSharp.Build/Fsi.fs
+++ b/src/FSharp.Build/Fsi.fs
@@ -161,6 +161,34 @@ type public Fsi() as this =
builder
+ let mutable bufferLimit = None
+
+ let textOutput =
+ lazy System.Collections.Generic.Queue<_>(defaultArg bufferLimit 1024)
+
+ override this.LogEventsFromTextOutput(line, msgImportance) =
+ if this.CaptureTextOutput then
+ textOutput.Value.Enqueue line
+
+ match bufferLimit with
+ | Some limit when textOutput.Value.Count > limit -> textOutput.Value.Dequeue() |> ignore
+ | _ -> ()
+
+ base.LogEventsFromTextOutput(line, msgImportance)
+
+ member _.BufferLimit
+ with get () = defaultArg bufferLimit 0
+ and set limit = bufferLimit <- if limit = 0 then None else Some limit
+
+ member val CaptureTextOutput = false with get, set
+
+ [
-
"
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)