@@ -27,6 +27,17 @@ open Xunit
27
27
open TestFramework
28
28
open System.Collections .Immutable
29
29
30
+ type FileNames =
31
+ static let testFileName = AsyncLocal< string>()
32
+ static let mutable counter = 0
33
+ //static do testFileName.Value <- "test"
34
+ static member internal MakeTestFileNameUniqueForThisTestCase () =
35
+ testFileName.Value <- $" {Interlocked.Increment &counter}{Path.PathSeparator}test"
36
+
37
+ static member TestFs with get() = $" {testFileName.Value}.fs"
38
+ static member TestFsx with get() = $" {testFileName.Value}.fsx"
39
+ static member TestFsi with get() = $" {testFileName.Value}.fsi"
40
+ static member Test with get() = testFileName.Value
30
41
31
42
#if ! NETCOREAPP
32
43
module AssemblyResolver =
@@ -407,9 +418,9 @@ module CompilerAssertHelpers =
407
418
#endif
408
419
|]
409
420
{
410
- ProjectFileName = " Z:\\ test.fsproj"
421
+ ProjectFileName = " Z:\\ " ++ " test.fsproj"
411
422
ProjectId = None
412
- SourceFiles = [| " test.fs " |]
423
+ SourceFiles = [| FileNames.TestFs |]
413
424
OtherOptions = Array.append testDefaults assemblies
414
425
ReferencedProjects = [||]
415
426
IsIncompleteTypeCheckEnvironment = false
@@ -742,7 +753,7 @@ Updated automatically, please check diffs in your pull request, changes must be
742
753
Assert.Equal( expectedOutput, output)
743
754
744
755
static member Pass ( source : string ) =
745
- let parseResults , fileAnswer = checker.ParseAndCheckFileInProject( " test.fs " , 0 , SourceText.ofString source, defaultProjectOptions TargetFramework.Current) |> Async.RunImmediate
756
+ let parseResults , fileAnswer = checker.ParseAndCheckFileInProject( FileNames.TestFs , 0 , SourceText.ofString source, defaultProjectOptions TargetFramework.Current) |> Async.RunImmediate
746
757
747
758
Assert.Empty( parseResults.Diagnostics)
748
759
@@ -752,11 +763,11 @@ Updated automatically, please check diffs in your pull request, changes must be
752
763
753
764
Assert.Empty( typeCheckResults.Diagnostics)
754
765
755
- static member PassWithOptions options ( source : string ) =
766
+ static member PassWithOptions options ( source : string ) =
756
767
let defaultOptions = defaultProjectOptions TargetFramework.Current
757
768
let options = { defaultOptions with OtherOptions = Array.append options defaultOptions.OtherOptions}
758
769
759
- let parseResults , fileAnswer = checker.ParseAndCheckFileInProject( " test.fs " , 0 , SourceText.ofString source, options) |> Async.RunImmediate
770
+ let parseResults , fileAnswer = checker.ParseAndCheckFileInProject( FileNames.TestFs , 0 , SourceText.ofString source, options) |> Async.RunImmediate
760
771
761
772
Assert.Empty( parseResults.Diagnostics)
762
773
@@ -872,7 +883,7 @@ Updated automatically, please check diffs in your pull request, changes must be
872
883
let parseResults , fileAnswer =
873
884
let defaultOptions = defaultProjectOptions TargetFramework.Current
874
885
checker.ParseAndCheckFileInProject(
875
- " test.fs " ,
886
+ FileNames.TestFs ,
876
887
0 ,
877
888
SourceText.ofString source,
878
889
{ defaultOptions with OtherOptions = Array.append options defaultOptions.OtherOptions})
@@ -932,48 +943,48 @@ Updated automatically, please check diffs in your pull request, changes must be
932
943
Assert.Fail ( sprintf " Compile had warnings and/or errors: %A " errors))
933
944
934
945
static member CompileExeWithOptions ( options , ( source : string )) =
935
- compile true options ( SourceCodeFileKind.Create( " test.fs " , source)) ( fun ( errors , _ , _ ) ->
946
+ compile true options ( SourceCodeFileKind.Create( FileNames.TestFs , source)) ( fun ( errors , _ , _ ) ->
936
947
if errors.Length > 0 then
937
948
Assert.Fail ( sprintf " Compile had warnings and/or errors: %A " errors))
938
949
939
950
static member CompileExe ( source : SourceCodeFileKind ) =
940
951
CompilerAssert.CompileExeWithOptions([||], source)
941
952
942
953
static member CompileExe ( source : string ) =
943
- CompilerAssert.CompileExeWithOptions([||], ( SourceCodeFileKind.Create( " test.fs " , source)))
954
+ CompilerAssert.CompileExeWithOptions([||], ( SourceCodeFileKind.Create( FileNames.TestFs , source)))
944
955
945
956
static member CompileExeAndRunWithOptions ( options , ( source : SourceCodeFileKind )) =
946
957
compileExeAndRunWithOptions options source
947
958
948
959
static member CompileExeAndRunWithOptions ( options , ( source : string )) =
949
- compileExeAndRunWithOptions options ( SourceCodeFileKind.Create( " test.fs " , source))
960
+ compileExeAndRunWithOptions options ( SourceCodeFileKind.Create( FileNames.TestFs , source))
950
961
951
962
static member CompileExeAndRun ( source : SourceCodeFileKind ) =
952
963
compileExeAndRunWithOptions [||] source
953
964
954
965
static member CompileExeAndRun ( source : string ) =
955
- compileExeAndRunWithOptions [||] ( SourceCodeFileKind.Create( " test.fs " , source))
966
+ compileExeAndRunWithOptions [||] ( SourceCodeFileKind.Create( FileNames.TestFs , source))
956
967
957
968
static member CompileLibraryAndVerifyILWithOptions ( options , ( source : SourceCodeFileKind ), ( f : ILVerifier -> unit )) =
958
969
compileLibraryAndVerifyILWithOptions options source f
959
970
960
971
static member CompileLibraryAndVerifyILWithOptions ( options , ( source : string ), ( f : ILVerifier -> unit )) =
961
- compileLibraryAndVerifyILWithOptions options ( SourceCodeFileKind.Create( " test.fs " , source)) f
972
+ compileLibraryAndVerifyILWithOptions options ( SourceCodeFileKind.Create( FileNames.TestFs , source)) f
962
973
963
974
static member CompileLibraryAndVerifyDebugInfoWithOptions ( options , ( expectedFile : string ), ( source : SourceCodeFileKind )) =
964
975
compileLibraryAndVerifyDebugInfoWithOptions options expectedFile source
965
976
966
977
static member CompileLibraryAndVerifyDebugInfoWithOptions ( options , ( expectedFile : string ), ( source : string )) =
967
- compileLibraryAndVerifyDebugInfoWithOptions options expectedFile ( SourceCodeFileKind.Create( " test.fs " , source))
978
+ compileLibraryAndVerifyDebugInfoWithOptions options expectedFile ( SourceCodeFileKind.Create( FileNames.TestFs , source))
968
979
969
980
static member CompileLibraryAndVerifyIL (( source : SourceCodeFileKind ), ( f : ILVerifier -> unit )) =
970
981
compileLibraryAndVerifyILWithOptions [||] source f
971
982
972
983
static member CompileLibraryAndVerifyIL (( source : string ), ( f : ILVerifier -> unit )) =
973
- compileLibraryAndVerifyILWithOptions [||] ( SourceCodeFileKind.Create( " test.fs " , source)) f
984
+ compileLibraryAndVerifyILWithOptions [||] ( SourceCodeFileKind.Create( FileNames.TestFs , source)) f
974
985
975
986
static member CompileLibraryAndVerifyILRealSig (( source : string ), ( f : ILVerifier -> unit )) =
976
- compileLibraryAndVerifyILWithOptions [| " --realsig+" |] ( SourceCodeFileKind.Create( " test.fs " , source)) f
987
+ compileLibraryAndVerifyILWithOptions [| " --realsig+" |] ( SourceCodeFileKind.Create( FileNames.TestFs , source)) f
977
988
978
989
static member RunScriptWithOptionsAndReturnResult options ( source : string ) =
979
990
// Initialize output and input streams
@@ -1020,7 +1031,7 @@ Updated automatically, please check diffs in your pull request, changes must be
1020
1031
1021
1032
static member Parse ( source : string , ? langVersion : string , ? fileName : string ) =
1022
1033
let langVersion = defaultArg langVersion " default"
1023
- let sourceFileName = defaultArg fileName " test.fsx "
1034
+ let sourceFileName = defaultArg fileName ( FileNames.TestFsx )
1024
1035
let parsingOptions =
1025
1036
{ FSharpParsingOptions.Default with
1026
1037
SourceFiles = [| sourceFileName |]
0 commit comments