Skip to content

Commit a5cfd2a

Browse files
abelbraaksmabaronfel
authored andcommitted
Showing only failing line in ExprTests, cleanup temp files
1 parent d174bb5 commit a5cfd2a

1 file changed

Lines changed: 23 additions & 9 deletions

File tree

tests/service/ExprTests.fs

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -985,21 +985,30 @@ let ``Test Optimized and Unoptimized Declarations for Project1`` () =
985985

986986
let testOperators dnName fsName excludedTests expectedUnoptimized expectedOptimized =
987987

988-
let tempFileName = Utils.getTempFileName()
989-
let filePath = Utils.getTempFilePathChangeExt tempFileName ".fs"
990-
let dllPath =Utils.getTempFilePathChangeExt tempFileName ".dll"
991-
let projFilePath = Utils.getTempFilePathChangeExt tempFileName ".fsproj"
988+
/// File is placed in local user's %TEMP%\ExprTests folder
989+
let tempPath = Path.Combine(Path.GetTempPath(), "ExprTests")
990+
do
991+
if Directory.Exists tempPath then ()
992+
else Directory.CreateDirectory tempPath |> ignore
993+
994+
let tempFileName = Path.GetFileName(Path.GetTempFileName())
995+
let basePath = Path.Combine(tempPath, tempFileName)
996+
let fileName = Path.ChangeExtension(basePath, ".fs")
997+
let dllName = Path.ChangeExtension(basePath, ".dll")
998+
let projFileName = Path.ChangeExtension(basePath, ".fsproj")
992999

9931000
try
994-
createTempDir()
9951001
let source = System.String.Format(Project1.operatorTests, dnName, fsName)
9961002
let replace (s:string) r = s.Replace("let " + r, "// let " + r)
9971003
let fileSource = excludedTests |> List.fold replace source
998-
File.WriteAllText(filePath, fileSource)
1004+
File.WriteAllText(fileName, fileSource)
9991005

1000-
let args = mkProjectCommandLineArgsSilent (dllPath, [filePath])
1006+
let args = [|
1007+
yield! mkProjectCommandLineArgsSilent (dllName, [fileName])
1008+
yield @"-r:System.Numerics.dll" // needed for some tests
1009+
|]
10011010

1002-
let options = checker.GetProjectOptionsFromCommandLineArgs (projFilePath, args)
1011+
let options = checker.GetProjectOptionsFromCommandLineArgs (projFileName, args)
10031012

10041013
let wholeProjectResults = exprChecker.ParseAndCheckProject(options) |> Async.RunSynchronously
10051014

@@ -1026,8 +1035,13 @@ let testOperators dnName fsName excludedTests expectedUnoptimized expectedOptimi
10261035
|> shouldPairwiseEqual expectedOptimized
10271036

10281037
finally
1029-
Utils.cleanupTempFiles [filePath; dllPath; projFilePath]
1038+
try
1039+
// cleanup: only the source file is written to the temp dir.
1040+
File.Delete fileName
1041+
if Directory.GetFiles(tempPath) |> Array.isEmpty then
1042+
Directory.Delete tempPath
10301043

1044+
with _ -> ()
10311045
()
10321046

10331047
[<Test>]

0 commit comments

Comments
 (0)