From e3ae24676d1f06f728e6e5a9b507d99026a660fc Mon Sep 17 00:00:00 2001 From: KevinRansom Date: Thu, 10 Nov 2022 23:36:18 -0800 Subject: [PATCH 1/3] debug fsharpqa tests --- .../CompilerOptions/fsc/debug.fs | 42 +++++++++++++++++++ .../FSharp.Compiler.ComponentTests.fsproj | 1 + tests/FSharp.Test.Utilities/Compiler.fs | 24 +++++++++++ .../CompilerOptions/fsc/debug/debug01.fs | 37 ---------------- .../CompilerOptions/fsc/debug/debug02.fs | 37 ---------------- .../Source/CompilerOptions/fsc/debug/env.lst | 2 - 6 files changed, 67 insertions(+), 76 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/debug.fs delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsc/debug/debug01.fs delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsc/debug/debug02.fs delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsc/debug/env.lst diff --git a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/debug.fs b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/debug.fs new file mode 100644 index 00000000000..335566ef175 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/debug.fs @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace FSharp.Compiler.ComponentTests.CompilerOptions + +open Xunit +open FSharp.Test +open FSharp.Test.Compiler + +module debug = + + [] + let ``fsc debug``() = + FSharp """ +printfn "Hello, World" + """ + |> asExe + |> withOptions ["--debug"] + |> compile + |> shouldSucceed + |> verifyHasPdb + + [] + let ``fsc debug plus``() = + FSharp """ +printfn "Hello, World" + """ + |> asExe + |> withOptions ["--debug+"] + |> compile + |> shouldSucceed + |> verifyHasPdb + + [] + let ``fsc debug minus``() = + FSharp """ +printfn "Hello, World" + """ + |> asExe + |> withOptions ["--debug-"] + |> compile + |> shouldSucceed + |> verifyNoPdb diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 240cf851b92..d84f43e1acf 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -187,6 +187,7 @@ + diff --git a/tests/FSharp.Test.Utilities/Compiler.fs b/tests/FSharp.Test.Utilities/Compiler.fs index b871032a23b..97808b58591 100644 --- a/tests/FSharp.Test.Utilities/Compiler.fs +++ b/tests/FSharp.Test.Utilities/Compiler.fs @@ -1072,6 +1072,30 @@ module rec Compiler = result + let verifyHasPdb (result: CompilationResult): unit = + let verifyPdbExists r = + match r.OutputPath with + | Some assemblyPath -> + let pdbPath = Path.ChangeExtension(assemblyPath, ".pdb") + if not (FileSystem.FileExistsShim pdbPath) then + failwith $"PDB file does not exists: {pdbPath}" + | _ -> failwith "Output path is not set, please make sure compilation was successfull." + match result with + | CompilationResult.Success r -> verifyPdbExists r + | _ -> failwith "Result should be \"Success\" in order to verify PDB." + + let verifyNoPdb (result: CompilationResult): unit = + let verifyPdbNotExists r = + match r.OutputPath with + | Some assemblyPath -> + let pdbPath = Path.ChangeExtension(assemblyPath, ".pdb") + if FileSystem.FileExistsShim pdbPath then + failwith $"PDB file exists: {pdbPath}" + | _ -> failwith "Output path is not set, please make sure compilation was successfull." + match result with + | CompilationResult.Success r -> verifyPdbNotExists r + | _ -> failwith "Result should be \"Success\" in order to verify PDB." + [] module Assertions = let private getErrorNumber (error: ErrorType) : int = diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/debug/debug01.fs b/tests/fsharpqa/Source/CompilerOptions/fsc/debug/debug01.fs deleted file mode 100644 index c97e53d56df..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsc/debug/debug01.fs +++ /dev/null @@ -1,37 +0,0 @@ -// #Regression #NoMT #CompilerOptions #NoMono -// Regression test for FSHARP1.0:5080 -// Verify that the assembly contains the full path to the .pdb file (we are compiling with --debug+) -// - -/// Search a sequence of char (the string 's') in a binary file (the 'assemblyFullPath') -let f (assemblyFullPath:string, s:string) = - - printfn "Searching '%s' in '%s'" s assemblyFullPath - - /// Make an array out of the string (will be used later to compare fragments of the file) - let expectedStringAsArray = seq { for i in s -> int i } |> Seq.toArray - - /// Open binary file - use assemblyStream = new System.IO.StreamReader( assemblyFullPath ) - - /// Makes sliding windows out of the sequence of bytes that make up the binary file - let z = seq { while not assemblyStream.EndOfStream do yield assemblyStream.Read() } |> Seq.windowed expectedStringAsArray.Length - - /// Try to find a matching sequence - let p = z |> Seq.tryFindIndex (fun t -> (Seq.toArray t) = expectedStringAsArray) - - /// Dump the result - p.IsSome - -/// Fully qualified path to ourselves -let assemblyFullPath = System.Reflection.Assembly.GetExecutingAssembly().Location - -/// Fully qualified path to pdb - we expect this info to be in the binary! -let pdbFullPath = System.IO.Path.ChangeExtension(assemblyFullPath, "pdb") - -if f(assemblyFullPath, pdbFullPath) then - printfn "OK: .pdb file found in assembly" - exit 0 - else - printfn "ERROR: No .pdb file found in assembly" - exit 1 diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/debug/debug02.fs b/tests/fsharpqa/Source/CompilerOptions/fsc/debug/debug02.fs deleted file mode 100644 index e2335d29b98..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsc/debug/debug02.fs +++ /dev/null @@ -1,37 +0,0 @@ -// #Regression #NoMT #CompilerOptions -// Regression test for FSHARP1.0:5080 -// Verify that the assembly DOES NOT contain the full path to the .pdb file (we are compiling with --debug-) -// - -/// Search a sequence of char (the string 's') in a binary file (the 'assemblyFullPath') -let f (assemblyFullPath:string, s:string) = - - printfn "Searching '%s' in '%s'" s assemblyFullPath - - /// Make an array out of the string (will be used later to compare fragments of the file) - let expectedStringAsArray = seq { for i in s -> int i } |> Seq.toArray - - /// Open binary file - use assemblyStream = new System.IO.StreamReader( assemblyFullPath ) - - /// Makes sliding windows out of the sequence of bytes that make up the binary file - let z = seq { while not assemblyStream.EndOfStream do yield assemblyStream.Read() } |> Seq.windowed expectedStringAsArray.Length - - /// Try to find a matching sequence - let p = z |> Seq.tryFindIndex (fun t -> (Seq.toArray t) = expectedStringAsArray) - - /// Dump the result - p.IsSome - -/// Fully qualified path to ourselves -let assemblyFullPath = System.Reflection.Assembly.GetExecutingAssembly().Location - -/// Fully qualified path to pdb - we expect this info to be in the binary! -let pdbFullPath = System.IO.Path.ChangeExtension(assemblyFullPath, "pdb") - -if f(assemblyFullPath, pdbFullPath) then - printfn "ERROR: .pdb file found in assembly" - exit 1 - else - printfn "OK: No .pdb file found in assembly" - exit 0 diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/debug/env.lst b/tests/fsharpqa/Source/CompilerOptions/fsc/debug/env.lst deleted file mode 100644 index 567c1865a20..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsc/debug/env.lst +++ /dev/null @@ -1,2 +0,0 @@ -NOMONO SOURCE=debug01.fs SCFLAGS="--debug+" # debug01.fs (--debug+) - SOURCE=debug02.fs SCFLAGS="--debug-" # debug02.fs (--debug-) From 88c4b6f06e8bb7e1fa4685749b66af3eaa40b08e Mon Sep 17 00:00:00 2001 From: KevinRansom Date: Fri, 11 Nov 2022 13:59:24 -0800 Subject: [PATCH 2/3] temp --- tests/fsharpqa/Source/test.lst | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/tests/fsharpqa/Source/test.lst b/tests/fsharpqa/Source/test.lst index 31eac0a00f9..e72cbd11612 100644 --- a/tests/fsharpqa/Source/test.lst +++ b/tests/fsharpqa/Source/test.lst @@ -5,15 +5,13 @@ # ReqNOCov -- skip this test/suite if we are doing a code coverage run # ReqENU -- skip this test/suite if we are running on non-ENU (useful to exclude hard-to-localize tests) -CompilerOptions01,NoMT CompilerOptions\fsc\checked -CompilerOptions01,NoMT CompilerOptions\fsc\cliversion CompilerOptions01,NoMT CompilerOptions\fsc\codepage CompilerOptions01,NoMT CompilerOptions\fsc\crossoptimize -CompilerOptions01,NoMT CompilerOptions\fsc\debug +CompilerOptions01,NoMT,Determinism CompilerOptions\fsc\determinism CompilerOptions01,NoMT CompilerOptions\fsc\dumpAllCommandLineOptions CompilerOptions01,NoMT CompilerOptions\fsc\flaterrors CompilerOptions02,NoMT CompilerOptions\fsc\gccerrors -CompilerOptions01,NoMT,help CompilerOptions\fsc\help +CompilerOptions01,NoMT,help CompilerOptions\fsc\help CompilerOptions01,NoMT CompilerOptions\fsc\highentropyva CompilerOptions01,NoMT CompilerOptions\fsc\langversion CompilerOptions01,NoMT CompilerOptions\fsc\lib @@ -21,23 +19,22 @@ CompilerOptions01,NoMT CompilerOptions\fsc\noframework CompilerOptions01,NoMT CompilerOptions\fsc\nologo CompilerOptions01,NoMT CompilerOptions\fsc\optimize CompilerOptions01,NoMT CompilerOptions\fsc\out -CompilerOptions01,NoMT,pdbs CompilerOptions\fsc\pdb CompilerOptions01,NoMT CompilerOptions\fsc\platform +CompilerOptions01,NoMT,pdbs CompilerOptions\fsc\pdb CompilerOptions01,NoMT CompilerOptions\fsc\Removed +CompilerOptions01,NoMT CompilerOptions\fsc\responsefile CompilerOptions01,NoMT CompilerOptions\fsc\standalone -CompilerOptions01,NoMT,NoHostedCompiler CompilerOptions\fsc\staticlink +CompilerOptions01,NoMT,NoHostedCompiler CompilerOptions\fsc\staticlink CompilerOptions01,NoMT CompilerOptions\fsc\subsystemversion CompilerOptions01,NoMT CompilerOptions\fsc\tailcalls CompilerOptions01,NoMT CompilerOptions\fsc\target -CompilerOptions01,NoMT,NoHostedCompiler CompilerOptions\fsc\tokenize -CompilerOptions01,NoMT CompilerOptions\fsc\responsefile -CompilerOptions01,NoMT,help CompilerOptions\fsi\help +CompilerOptions01,NoMT,NoHostedCompiler CompilerOptions\fsc\tokenize + +CompilerOptions01,NoMT,help CompilerOptions\fsi\help CompilerOptions01,NoMT CompilerOptions\fsi\highentropyva CompilerOptions01,NoMT CompilerOptions\fsi\langversion CompilerOptions01,NoMT CompilerOptions\fsi\nologo CompilerOptions01,NoMT CompilerOptions\fsi\subsystemversion -CompilerOptions02,NoMT CompilerOptions\fsi\exename -CompilerOptions01,NoMT,Determinism CompilerOptions\fsc\determinism Conformance01 Conformance\BasicGrammarElements\Constants Conformance01 Conformance\BasicGrammarElements\OperatorNames From 817e077d2e74070246c5561cb68237085ebee897 Mon Sep 17 00:00:00 2001 From: KevinRansom Date: Fri, 11 Nov 2022 15:08:07 -0800 Subject: [PATCH 3/3] temp --- .../Conformance/DeclarationElements/ObjectConstructors/env.lst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fsharpqa/Source/Conformance/DeclarationElements/ObjectConstructors/env.lst b/tests/fsharpqa/Source/Conformance/DeclarationElements/ObjectConstructors/env.lst index adee0212949..40f39e9785c 100644 --- a/tests/fsharpqa/Source/Conformance/DeclarationElements/ObjectConstructors/env.lst +++ b/tests/fsharpqa/Source/Conformance/DeclarationElements/ObjectConstructors/env.lst @@ -11,7 +11,7 @@ SOURCE=E_NoLetBindingsWOObjCtor.fs # E_NoLetBindingsWOObjCtor.fs SOURCE=E_NoObjectConstructorOnInterfaces.fs # E_NoObjectConstructorOnInterfaces.fs - SOURCE=AlternateGenericTypeSyntax01.fs # AlternateGenericTypeSyntax01.fs + SOURCE=AlternateGenericTypeSyntax01.fs SCFLAGS="--langversion:5.0" # AlternateGenericTypeSyntax01.fs SOURCE=MutuallyRecursive01.fs # MutuallyRecursive01.fs SOURCE=ImplicitCtorsCallingBaseclassPassingSelf.fs # ImplicitCtorsCallingBaseclassPassingSelf.fs