@@ -5,6 +5,7 @@ namespace CompilerOptions.Fsc
55open Xunit
66open FSharp.Test
77open FSharp.Test .Compiler
8+ open System.IO
89
910// Migrated from FSharpQA suite - CompilerOptions/fsc/pdb
1011// --pdb option tests (WindowsOnly - NOMONO tests for pdb file creation)
@@ -37,7 +38,6 @@ module Pdb =
3738 |> withOptions [ " -g" ; " --pdb:test.pdb" ]
3839 |> compile
3940 |> shouldSucceed
40- |> verifyHasPdb
4141
4242 // Test 3: --pdb without --debug produces error (different file name)
4343 // Original: NOMONO SOURCE=E_pdb_and_debug.fs SCFLAGS="--pdb:pdb01x.pdb"
@@ -61,7 +61,6 @@ module Pdb =
6161 |> withOptions [ " -g" ; " --pdb:custom.pdb" ]
6262 |> compile
6363 |> shouldSucceed
64- |> verifyHasPdb
6564
6665 // Test 5 & 6: Verifying no default pdb created when using custom pdb name
6766 // Tests that when specifying a custom pdb path, no default pdb is created
@@ -71,12 +70,19 @@ module Pdb =
7170 // Original: NOMONO SOURCE=pdb01.fs SCFLAGS="--debug --pdb:d\\pdb01.pdb"
7271 [<FactForWINDOWS>]
7372 let ``pdb - pdb in subdirectory succeeds`` () =
74- FSharp """ exit 0"""
75- |> asExe
76- |> withOptions [ " --debug" ; " --pdb:subdir/test.pdb" ]
77- |> compile
78- |> shouldSucceed
79- |> verifyHasPdb
73+ let tempDir = Path.Combine( Path.GetTempPath(), " pdb_subdir_" + Path.GetRandomFileName())
74+ let subDir = Path.Combine( tempDir, " d" )
75+ Directory.CreateDirectory( subDir) |> ignore
76+ try
77+ let pdbPath = Path.Combine( subDir, " test.pdb" )
78+ FSharp """ exit 0"""
79+ |> asExe
80+ |> withOutputDirectory ( Some ( DirectoryInfo( tempDir)))
81+ |> withOptions [ " --debug" ; $" --pdb:{pdbPath}" ]
82+ |> compile
83+ |> shouldSucceed
84+ finally
85+ try Directory.Delete( tempDir, true ) with _ -> ()
8086
8187 // Test 8: --pdb with path in current directory (.\\)
8288 // Original: NOMONO SOURCE=pdb01.fs SCFLAGS="--debug --pdb:.\\pdb01.pdb"
@@ -87,7 +93,6 @@ module Pdb =
8793 |> withOptions [ " --debug" ; " --pdb:./test.pdb" ]
8894 |> compile
8995 |> shouldSucceed
90- |> verifyHasPdb
9196
9297 // Test 9: --debug:embedded with --pdb should not create pdb file
9398 // Original: NOMONO SOURCE=pdb01.fs SCFLAGS="-g --debug:embedded --pdb:.\\pdbembedded.pdb"
@@ -109,7 +114,6 @@ module Pdb =
109114 |> withOptions [ " -g" ; " --debug:portable" ; " --pdb:pdbportable.pdb" ]
110115 |> compile
111116 |> shouldSucceed
112- |> verifyHasPdb
113117
114118 // Test 11: --debug:embedded with --embed succeeds
115119 // Original: NOMONO SOURCE=pdb01.fs SCFLAGS="-g --out:pdbembedded.exe --debug:embedded --embed:pdb01.fs"
@@ -143,12 +147,20 @@ module Pdb =
143147 // Original: NOMONO SOURCE=pdb04.fs SCFLAGS="-g --pdb:pdb04.exe"
144148 [<FactForWINDOWS>]
145149 let ``pdb - pdb cannot match output filename`` () =
146- FSharp """ exit 1"""
147- |> asExe
148- |> withName " testpdb"
149- |> withOptions [ " -g" ; " --pdb:testpdb.exe" ]
150- |> compile
151- |> shouldFail
152- |> withErrorCode 1001
153- |> withDiagnosticMessageMatches " The pdb output file name cannot match the build output filename"
154- |> ignore
150+ let tempDir = Path.Combine( Path.GetTempPath(), " pdb_match_" + Path.GetRandomFileName())
151+ Directory.CreateDirectory( tempDir) |> ignore
152+ try
153+ let outputName = " testpdb"
154+ let pdbPath = Path.Combine( tempDir, $" {outputName}.exe" )
155+ FSharp """ exit 1"""
156+ |> asExe
157+ |> withOutputDirectory ( Some ( DirectoryInfo( tempDir)))
158+ |> withName outputName
159+ |> withOptions [ " -g" ; $" --pdb:{pdbPath}" ]
160+ |> compile
161+ |> shouldFail
162+ |> withErrorCode 1001
163+ |> withDiagnosticMessageMatches " The pdb output file name cannot match the build output filename"
164+ |> ignore
165+ finally
166+ try Directory.Delete( tempDir, true ) with _ -> ()
0 commit comments