未验证 提交 80a23ee4 编写于 作者: K Kevin Ransom (msft) 提交者: GitHub

debug fsharpqa tests (#14298)

上级 e2f3a3e0
// 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 =
[<Fact>]
let ``fsc debug``() =
FSharp """
printfn "Hello, World"
"""
|> asExe
|> withOptions ["--debug"]
|> compile
|> shouldSucceed
|> verifyHasPdb
[<Fact>]
let ``fsc debug plus``() =
FSharp """
printfn "Hello, World"
"""
|> asExe
|> withOptions ["--debug+"]
|> compile
|> shouldSucceed
|> verifyHasPdb
[<Fact>]
let ``fsc debug minus``() =
FSharp """
printfn "Hello, World"
"""
|> asExe
|> withOptions ["--debug-"]
|> compile
|> shouldSucceed
|> verifyNoPdb
...@@ -187,6 +187,7 @@ ...@@ -187,6 +187,7 @@
<Compile Include="TypeChecks\ParallelCheckingWithSignatureFilesTests.fs" /> <Compile Include="TypeChecks\ParallelCheckingWithSignatureFilesTests.fs" />
<Compile Include="CompilerOptions\fsc\checked\checked.fs" /> <Compile Include="CompilerOptions\fsc\checked\checked.fs" />
<Compile Include="CompilerOptions\fsc\cliversion.fs" /> <Compile Include="CompilerOptions\fsc\cliversion.fs" />
<Compile Include="CompilerOptions\fsc\debug.fs" />
<Compile Include="CompilerOptions\fsc\langversion.fs" /> <Compile Include="CompilerOptions\fsc\langversion.fs" />
<Compile Include="CompilerOptions\fsc\noframework\noframework.fs" /> <Compile Include="CompilerOptions\fsc\noframework\noframework.fs" />
<Compile Include="CompilerOptions\fsc\platform\platform.fs" /> <Compile Include="CompilerOptions\fsc\platform\platform.fs" />
......
...@@ -1072,6 +1072,30 @@ module rec Compiler = ...@@ -1072,6 +1072,30 @@ module rec Compiler =
result 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."
[<AutoOpen>] [<AutoOpen>]
module Assertions = module Assertions =
let private getErrorNumber (error: ErrorType) : int = let private getErrorNumber (error: ErrorType) : int =
......
// #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+)
//<Expects status="success"></Expects>
/// 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
// #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-)
//<Expects status="success"></Expects>
/// 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
NOMONO SOURCE=debug01.fs SCFLAGS="--debug+" # debug01.fs (--debug+)
SOURCE=debug02.fs SCFLAGS="--debug-" # debug02.fs (--debug-)
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
SOURCE=E_NoLetBindingsWOObjCtor.fs # E_NoLetBindingsWOObjCtor.fs SOURCE=E_NoLetBindingsWOObjCtor.fs # E_NoLetBindingsWOObjCtor.fs
SOURCE=E_NoObjectConstructorOnInterfaces.fs # E_NoObjectConstructorOnInterfaces.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=MutuallyRecursive01.fs # MutuallyRecursive01.fs
SOURCE=ImplicitCtorsCallingBaseclassPassingSelf.fs # ImplicitCtorsCallingBaseclassPassingSelf.fs SOURCE=ImplicitCtorsCallingBaseclassPassingSelf.fs # ImplicitCtorsCallingBaseclassPassingSelf.fs
......
...@@ -5,11 +5,9 @@ ...@@ -5,11 +5,9 @@
# ReqNOCov -- skip this test/suite if we are doing a code coverage run # 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) # 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\codepage
CompilerOptions01,NoMT CompilerOptions\fsc\crossoptimize 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\dumpAllCommandLineOptions
CompilerOptions01,NoMT CompilerOptions\fsc\flaterrors CompilerOptions01,NoMT CompilerOptions\fsc\flaterrors
CompilerOptions02,NoMT CompilerOptions\fsc\gccerrors CompilerOptions02,NoMT CompilerOptions\fsc\gccerrors
...@@ -21,23 +19,22 @@ CompilerOptions01,NoMT CompilerOptions\fsc\noframework ...@@ -21,23 +19,22 @@ CompilerOptions01,NoMT CompilerOptions\fsc\noframework
CompilerOptions01,NoMT CompilerOptions\fsc\nologo CompilerOptions01,NoMT CompilerOptions\fsc\nologo
CompilerOptions01,NoMT CompilerOptions\fsc\optimize CompilerOptions01,NoMT CompilerOptions\fsc\optimize
CompilerOptions01,NoMT CompilerOptions\fsc\out CompilerOptions01,NoMT CompilerOptions\fsc\out
CompilerOptions01,NoMT,pdbs CompilerOptions\fsc\pdb
CompilerOptions01,NoMT CompilerOptions\fsc\platform CompilerOptions01,NoMT CompilerOptions\fsc\platform
CompilerOptions01,NoMT,pdbs CompilerOptions\fsc\pdb
CompilerOptions01,NoMT CompilerOptions\fsc\Removed CompilerOptions01,NoMT CompilerOptions\fsc\Removed
CompilerOptions01,NoMT CompilerOptions\fsc\responsefile
CompilerOptions01,NoMT CompilerOptions\fsc\standalone 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\subsystemversion
CompilerOptions01,NoMT CompilerOptions\fsc\tailcalls CompilerOptions01,NoMT CompilerOptions\fsc\tailcalls
CompilerOptions01,NoMT CompilerOptions\fsc\target CompilerOptions01,NoMT CompilerOptions\fsc\target
CompilerOptions01,NoMT,NoHostedCompiler CompilerOptions\fsc\tokenize CompilerOptions01,NoMT,NoHostedCompiler CompilerOptions\fsc\tokenize
CompilerOptions01,NoMT CompilerOptions\fsc\responsefile
CompilerOptions01,NoMT,help CompilerOptions\fsi\help CompilerOptions01,NoMT,help CompilerOptions\fsi\help
CompilerOptions01,NoMT CompilerOptions\fsi\highentropyva CompilerOptions01,NoMT CompilerOptions\fsi\highentropyva
CompilerOptions01,NoMT CompilerOptions\fsi\langversion CompilerOptions01,NoMT CompilerOptions\fsi\langversion
CompilerOptions01,NoMT CompilerOptions\fsi\nologo CompilerOptions01,NoMT CompilerOptions\fsi\nologo
CompilerOptions01,NoMT CompilerOptions\fsi\subsystemversion CompilerOptions01,NoMT CompilerOptions\fsi\subsystemversion
CompilerOptions02,NoMT CompilerOptions\fsi\exename
CompilerOptions01,NoMT,Determinism CompilerOptions\fsc\determinism
Conformance01 Conformance\BasicGrammarElements\Constants Conformance01 Conformance\BasicGrammarElements\Constants
Conformance01 Conformance\BasicGrammarElements\OperatorNames Conformance01 Conformance\BasicGrammarElements\OperatorNames
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册