Migrate cl help tests from fsharpqa to componentservices (#14810)

* Migrate fsharpqa help tests to fsharp.compiler.componenttests

* Update Utilities.fs

* Update Compiler.fs
This commit is contained in:
Kevin Ransom (msft) 2023-02-27 12:14:27 -08:00 коммит произвёл GitHub
Родитель a296258574
Коммит d5696fc6e5
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
15 изменённых файлов: 295 добавлений и 245 удалений

Просмотреть файл

@ -1,58 +1,38 @@
Microsoft (R) F# Compiler version 12.0.0.0 for F# 6.0
Microsoft (R) F# Compiler version 12.5.0.0 for F# 7.0
Copyright (c) Microsoft Corporation. All Rights Reserved.
- OUTPUT FILES -
--out:<file> Name of the output file (Short form:
-o)
--out:<file> Name of the output file (Short form: -o)
--target:exe Build a console executable
--target:winexe Build a Windows executable
--target:library Build a library (Short form: -a)
--target:module Build a module that can be added to
another assembly
--delaysign[+|-] Delay-sign the assembly using only
the public portion of the strong
name key
--publicsign[+|-] Public-sign the assembly using only
the public portion of the strong
name key, and mark the assembly as
signed
--doc:<file> Write the xmldoc of the assembly to
the given file
--target:module Build a module that can be added to another assembly
--delaysign[+|-] Delay-sign the assembly using only the public portion of the strong name key
--publicsign[+|-] Public-sign the assembly using only the public portion of the strong name
key, and mark the assembly as signed
--doc:<file> Write the xmldoc of the assembly to the given file
--keyfile:<file> Specify a strong name key file
--platform:<string> Limit which platforms this code can
run on: x86, x64, Arm, Arm64,
Itanium, anycpu32bitpreferred, or
anycpu. The default is anycpu.
--compressmetadata[+|-] Compress interface and optimization
data files
--nooptimizationdata Only include optimization
information essential for
implementing inlined constructs.
Inhibits cross-module inlining but
improves binary compatibility.
--nointerfacedata Don't add a resource to the
generated assembly containing
F#-specific metadata
--sig:<file> Print the inferred interface of the
assembly to a file
--allsigs Print the inferred interfaces of all
compilation files to associated
--platform:<string> Limit which platforms this code can run on: x86, x64, Arm, Arm64, Itanium,
anycpu32bitpreferred, or anycpu. The default is anycpu.
--compressmetadata[+|-] Compress interface and optimization data files
--nooptimizationdata Only include optimization information essential for implementing inlined
constructs. Inhibits cross-module inlining but improves binary
compatibility.
--nointerfacedata Don't add a resource to the generated assembly containing F#-specific
metadata
--sig:<file> Print the inferred interface of the assembly to a file
--allsigs Print the inferred interfaces of all compilation files to associated
signature files
--nocopyfsharpcore Don't copy FSharp.Core.dll along the
produced binaries
--refonly[+|-] Produce a reference assembly,
instead of a full assembly, as the
primary output
--refout:<file> Produce a reference assembly with
the specified file path.
--nocopyfsharpcore Don't copy FSharp.Core.dll along the produced binaries
--refonly[+|-] Produce a reference assembly, instead of a full assembly, as the primary
output
--refout:<file> Produce a reference assembly with the specified file path.
- INPUT FILES -
--reference:<file> Reference an assembly (Short form:
-r)
--compilertool:<file> Reference an assembly or directory
containing a design time tool (Short
--reference:<file> Reference an assembly (Short form: -r)
--compilertool:<file> Reference an assembly or directory containing a design time tool (Short
form: -t)
@ -60,45 +40,28 @@ Copyright (c) Microsoft Corporation. All Rights Reserved.
--win32icon:<file> Specify a Win32 icon file (.ico)
--win32res:<file> Specify a Win32 resource file (.res)
--win32manifest:<file> Specify a Win32 manifest file
--nowin32manifest Do not include the default Win32
manifest
--nowin32manifest Do not include the default Win32 manifest
--resource:<resinfo> Embed the specified managed resource
--linkresource:<resinfo> Link the specified resource to this
assembly where the resinfo format is
<file>[,<string
name>[,public|private]]
--linkresource:<resinfo> Link the specified resource to this assembly where the resinfo format is
<file>[,<string name>[,public|private]]
- CODE GENERATION -
--debug[+|-] Emit debug information (Short form:
-g)
--debug:{full|pdbonly|portable|embedded} Specify debugging type: full,
portable, embedded, pdbonly. ('full'
is the default if no debuggging type
specified and enables attaching a
debugger to a running program,
'portable' is a cross-platform
format, 'embedded' is a
cross-platform format embedded into
the output file).
--embed[+|-] Embed all source files in the
portable PDB file
--embed:<file;...> Embed specific source files in the
portable PDB file
--sourcelink:<file> Source link information file to
embed in the portable PDB file
--optimize[+|-] Enable optimizations (Short form:
-O)
--debug[+|-] Emit debug information (Short form: -g)
--debug:{full|pdbonly|portable|embedded} Specify debugging type: full, portable, embedded, pdbonly. ('full' is the
default if no debuggging type specified and enables attaching a debugger to
a running program, 'portable' is a cross-platform format, 'embedded' is a
cross-platform format embedded into the output file).
--embed[+|-] Embed all source files in the portable PDB file
--embed:<file;...> Embed specific source files in the portable PDB file
--sourcelink:<file> Source link information file to embed in the portable PDB file
--optimize[+|-] Enable optimizations (Short form: -O)
--tailcalls[+|-] Enable or disable tailcalls
--deterministic[+|-] Produce a deterministic assembly
(including module version GUID and
--deterministic[+|-] Produce a deterministic assembly (including module version GUID and
timestamp)
--pathmap:<path=sourcePath;...> Maps physical paths to source path
names output by the compiler
--crossoptimize[+|-] Enable or disable cross-module
optimizations
--reflectionfree Disable implicit generation of
constructs using reflection
--pathmap:<path=sourcePath;...> Maps physical paths to source path names output by the compiler
--crossoptimize[+|-] Enable or disable cross-module optimizations
--reflectionfree Disable implicit generation of constructs using reflection
- ERRORS AND WARNINGS -
@ -106,69 +69,45 @@ Copyright (c) Microsoft Corporation. All Rights Reserved.
--warnaserror[+|-]:<warn;...> Report specific warnings as errors
--warn:<n> Set a warning level (0-5)
--nowarn:<warn;...> Disable specific warning messages
--warnon:<warn;...> Enable specific warnings that may be
off by default
--consolecolors[+|-] Output warning and error messages in
color
--warnon:<warn;...> Enable specific warnings that may be off by default
--consolecolors[+|-] Output warning and error messages in color
- LANGUAGE -
--langversion:? Display the allowed values for
language version.
--langversion:{version|latest|preview} Specify language version such as
'latest' or 'preview'.
--langversion:? Display the allowed values for language version.
--langversion:{version|latest|preview} Specify language version such as 'latest' or 'preview'.
--checked[+|-] Generate overflow checks
--define:<string> Define conditional compilation
symbols (Short form: -d)
--define:<string> Define conditional compilation symbols (Short form: -d)
--mlcompatibility Ignore ML compatibility warnings
- MISCELLANEOUS -
--nologo Suppress compiler copyright message
--version Display compiler version banner and
exit
--help Display this usage message (Short
form: -?)
--version Display compiler version banner and exit
--help Display this usage message (Short form: -?)
--@<file> Read response file for more options
- ADVANCED -
--codepage:<n> Specify the codepage used to read
source files
--codepage:<n> Specify the codepage used to read source files
--utf8output Output messages in UTF-8 encoding
--preferreduilang:<string> Specify the preferred output
language culture name (e.g. es-ES,
ja-JP)
--fullpaths Output messages with fully qualified
paths
--lib:<dir;...> Specify a directory for the include
path which is used to resolve source
files and assemblies (Short form:
-I)
--simpleresolution Resolve assembly references using
directory-based rules rather than
MSBuild resolution
--targetprofile:<string> Specify target framework profile of
this assembly. Valid values are
mscorlib, netcore or netstandard.
Default - mscorlib
--baseaddress:<address> Base address for the library to be
built
--checksumalgorithm:{SHA1|SHA256} Specify algorithm for calculating
source file checksum stored in PDB.
Supported values are: SHA1 or SHA256
(default)
--noframework Do not reference the default CLI
assemblies by default
--standalone Statically link the F# library and
all referenced DLLs that depend on
it into the assembly being generated
--staticlink:<file> Statically link the given assembly
and all referenced DLLs that depend
on this assembly. Use an assembly
name e.g. mylib, not a DLL name.
--preferreduilang:<string> Specify the preferred output language culture name (e.g. es-ES, ja-JP)
--fullpaths Output messages with fully qualified paths
--lib:<dir;...> Specify a directory for the include path which is used to resolve source
files and assemblies (Short form: -I)
--simpleresolution Resolve assembly references using directory-based rules rather than MSBuild
resolution
--targetprofile:<string> Specify target framework profile of this assembly. Valid values are
mscorlib, netcore or netstandard. Default - mscorlib
--baseaddress:<address> Base address for the library to be built
--checksumalgorithm:{SHA1|SHA256} Specify algorithm for calculating source file checksum stored in PDB.
Supported values are: SHA1 or SHA256 (default)
--noframework Do not reference the default CLI assemblies by default
--standalone Statically link the F# library and all referenced DLLs that depend on it
into the assembly being generated
--staticlink:<file> Statically link the given assembly and all referenced DLLs that depend on
this assembly. Use an assembly name e.g. mylib, not a DLL name.
--pdb:<string> Name the output debug file
--highentropyva[+|-] Enable high-entropy ASLR
--subsystemversion:<string> Specify subsystem version of this
assembly
--subsystemversion:<string> Specify subsystem version of this assembly
--quotations-debug[+|-] Emit debug information in quotations

Просмотреть файл

@ -0,0 +1,44 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
namespace FSharp.Compiler.ComponentTests.CompilerOptions.fsc
open Xunit
open FSharp.Test
open FSharp.Test.Compiler
open System
open System.IO
module help_options =
// ReqENU SOURCE=dummy.fsx COMPILE_ONLY=1 PRECMD="\$FSC_PIPE >help40.txt -? 2>&1" POSTCMD="\$FSI_PIPE --nologo --quiet --exec ..\\..\\..\\comparer.fsx help40.txt help40.437.1033.bsl" # -?
[<Fact>]
let ``Help - variant 1``() =
FSharp ""
|> asExe
|> withBufferWidth 120
|> withOptions ["-?"]
|> compile
|> verifyOutputWithBaseline (Path.Combine(__SOURCE_DIRECTORY__, "compiler_help_output.bsl"))
|> shouldSucceed
// ReqENU SOURCE=dummy.fsx COMPILE_ONLY=1 PRECMD="\$FSC_PIPE >help40.txt /? 2>&1" POSTCMD="\$FSI_PIPE --nologo --quiet --exec ..\\..\\..\\comparer.fsx help40.txt help40.437.1033.bsl" # --help
[<Fact>]
let ``Help - variant 2``() =
FSharp ""
|> asExe
|> withBufferWidth 120
|> withOptions ["/?"]
|> compile
|> verifyOutputWithBaseline (Path.Combine(__SOURCE_DIRECTORY__, "compiler_help_output.bsl"))
|> shouldSucceed
// ReqENU SOURCE=dummy.fsx COMPILE_ONLY=1 PRECMD="\$FSC_PIPE >help40.txt --help 2>&1" POSTCMD="\$FSI_PIPE --nologo --quiet --exec ..\\..\\..\\comparer.fsx help40.txt help40.437.1033.bsl" # /?
[<Fact>]
let ``Help - variant 3``() =
FSharp ""
|> asExe
|> withBufferWidth 120
|> withOptions ["--help"]
|> compile
|> verifyOutputWithBaseline (Path.Combine(__SOURCE_DIRECTORY__, "compiler_help_output.bsl"))
|> shouldSucceed

Просмотреть файл

@ -51,25 +51,17 @@ module times =
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"error_01.fs"|])>]
let ``times - to console`` compilation =
let oldConsole = Console.Out
let sw = new StringWriter()
Console.SetOut(sw)
use _ = {new IDisposable with
member this.Dispose() = Console.SetOut(oldConsole) }
compilation
|> asFsx
|> withBufferWidth 120
|> withOptions ["--times"]
|> ignoreWarnings
|> compile
|> shouldSucceed
|> ignore<CompilationResult>
let consoleContents = sw.ToString()
Assert.Contains("Parse inputs",consoleContents)
Assert.Contains("Typecheck",consoleContents)
Assert.Contains("GC0",consoleContents)
Assert.Contains("Duration",consoleContents)
|> verifyOutputContains [|
"Parse inputs"
"Typecheck"
"GC0"
"Duration"|]
[<Theory(Skip="Flaky in CI due to file being locked, disabling for now until file closure is resolved."); Directory(__SOURCE_DIRECTORY__, Includes=[|"error_01.fs"|])>]

Просмотреть файл

@ -209,6 +209,7 @@
<Compile Include="CompilerOptions\fsc\codepage\codepage.fs" />
<Compile Include="CompilerOptions\fsc\debug.fs" />
<Compile Include="CompilerOptions\fsc\langversion.fs" />
<Compile Include="CompilerOptions\fsc\misc\misc.fs" />
<Compile Include="CompilerOptions\fsc\noframework\noframework.fs" />
<Compile Include="CompilerOptions\fsc\platform\platform.fs" />
<Compile Include="CompilerOptions\fsc\times\times.fs" />

Просмотреть файл

@ -11,8 +11,9 @@ open System.Threading
open FSharp.Compiler.Interactive.Shell
open FSharp.Compiler.DependencyManager
open FSharp.Compiler.Diagnostics
open FSharp.Test.ScriptHelpers
open FSharp.DependencyManager.Nuget
open FSharp.Test.ScriptHelpers
open FSharp.Test.Utilities
open Internal.Utilities

Просмотреть файл

@ -11,6 +11,7 @@ open System.Threading
open System.Threading.Tasks
open FSharp.Compiler.Interactive.Shell
open FSharp.Test.ScriptHelpers
open FSharp.Test.Utilities
open Xunit

Просмотреть файл

@ -60,7 +60,8 @@ module rec Compiler =
Name: string option
IgnoreWarnings: bool
References: CompilationUnit list
TargetFramework: TargetFramework }
TargetFramework: TargetFramework
}
member this.CreateOutputDirectory() =
match this.OutputDirectory with
@ -395,6 +396,9 @@ module rec Compiler =
| FS fs -> FS { fs with OutputDirectory = Some (DirectoryInfo(path)) }
| _ -> failwith "withOutputDirectory is only supported on F#"
let withBufferWidth (width: int)(cUnit: CompilationUnit) : CompilationUnit =
withOptionsHelper [ $"--bufferwidth:{width}" ] "withBufferWidth is only supported on F#" cUnit
let withDefines (defines: string list) (cUnit: CompilationUnit) : CompilationUnit =
withOptionsHelper (defines |> List.map(fun define -> $"--define:{define}")) "withDefines is only supported on F#" cUnit
@ -582,18 +586,22 @@ module rec Compiler =
let private compileFSharpCompilation compilation ignoreWarnings (cUnit: CompilationUnit) : CompilationResult =
let ((err: FSharpDiagnostic[], outputFilePath: string), deps) = CompilerAssert.CompileRaw(compilation, ignoreWarnings)
use redirect = new RedirectConsole()
let ((err: FSharpDiagnostic[], rc: int, outputFilePath: string), deps) =
CompilerAssert.CompileRaw(compilation, ignoreWarnings)
// Create and stash the console output
let diagnostics = err |> fromFSharpDiagnostic
let result =
{ OutputPath = None
Dependencies = deps
Adjust = 0
PerFileErrors = diagnostics
Diagnostics = diagnostics |> List.map snd
Output = None
Compilation = cUnit }
let result = {
OutputPath = None
Dependencies = deps
Adjust = 0
PerFileErrors = diagnostics
Diagnostics = diagnostics |> List.map snd
Output = Some (RunOutput.ExecutionOutput { ExitCode = rc; StdOut = redirect.Output(); StdErr = redirect.ErrorOutput() })
Compilation = cUnit
}
let (errors, warnings) = partitionErrors result.Diagnostics
@ -1021,6 +1029,62 @@ module rec Compiler =
let verifyBaselines = verifyBaseline >> verifyILBaseline
let normalizeNewlines output =
let regex = new Regex("(\r\n|\r|\n)", RegexOptions.Singleline ||| RegexOptions.ExplicitCapture)
let result = regex.Replace(output, System.Environment.NewLine)
result
let regexStrip output pattern flags =
let regex = new Regex(pattern, flags)
let result = regex.Replace(output, "")
result
let stripEnvironment output =
let pattern = @"(---------------------------------------------------------------(\r\n|\r|\n)).*(\n---------------------------------------------------------------(\r\n|\r|\n))"
let result = regexStrip output pattern (RegexOptions.Singleline ||| RegexOptions.ExplicitCapture)
result
let stripVersion output =
let pattern = @"(Microsoft \(R\) (.*) version (.*) F# (.*))"
let result = regexStrip output pattern (RegexOptions.Multiline ||| RegexOptions.ExplicitCapture)
result
let getOutput (cResult: CompilationResult) : string option =
let result =
match cResult with
| CompilationResult.Failure f -> failwith $"Build failure: {f}"
| CompilationResult.Success output ->
match output.Output with
| Some (EvalOutput _) -> None
| Some (ExecutionOutput eo) ->
match eo.StdOut with
| null -> None
| output -> Some (stripVersion (stripEnvironment (normalizeNewlines output)))
| None -> None
result
let verifyOutput (expected: string) (cResult: CompilationResult) : CompilationResult =
match getOutput cResult with
| None -> cResult
| Some actual ->
let expected = stripVersion (normalizeNewlines expected)
if expected <> actual then
failwith $"""Output does not match expected: ------------{Environment.NewLine}{expected}{Environment.NewLine}Actual: ------------{Environment.NewLine}{actual}{Environment.NewLine}"""
else
cResult
let verifyOutputWithBaseline path =
verifyOutput (File.ReadAllText(path).Replace(@"\r\n", Environment.NewLine))
let verifyOutputContains (expected: string array) (cResult: CompilationResult) : CompilationResult =
match getOutput cResult with
| None -> cResult
| Some actual ->
for item in expected do
if not(actual.Contains(item)) then
failwith $"""Output does not match expected: ------------{Environment.NewLine}{item}{Environment.NewLine}Actual: ------------{Environment.NewLine}{actual}{Environment.NewLine}"""
cResult
type ImportScope = { Kind: ImportDefinitionKind; Name: string }
type PdbVerificationOption =

Просмотреть файл

@ -342,14 +342,13 @@ module rec CompilerAssertHelpers =
yield "-o:" + outputFilePath
yield (if isExe then "--target:exe" else "--target:library")
yield! (defaultProjectOptions targetFramework).OtherOptions
// yield! TargetFrameworkUtil.getFileReferences targetFramework
yield! options
|]
// Generate a response file, purely for diagnostic reasons.
File.WriteAllLines(Path.ChangeExtension(outputFilePath, ".rsp"), args)
let errors, _ = checker.Compile args |> Async.RunImmediate
errors, outputFilePath
let errors, rc = checker.Compile args |> Async.RunImmediate
errors, rc, outputFilePath
let compileDisposable (outputDirectory:DirectoryInfo) isExe options targetFramework nameOpt (sources:SourceCodeFileKind list) =
let disposeFile path =
@ -461,11 +460,11 @@ module rec CompilerAssertHelpers =
let tmp = Path.Combine(outputPath.FullName, Path.ChangeExtension(fileName, ".dll"))
disposals.Add({ new IDisposable with member _.Dispose() = File.Delete tmp })
cmpl.EmitAsFile tmp
(([||], tmp), []), false)
(([||], 0, tmp), []), false)
let compilationRefs =
compiledRefs
|> List.map (fun (((errors, outputFilePath), _), staticLink) ->
|> List.map (fun (((errors, _, outputFilePath), _), staticLink) ->
assertErrors 0 ignoreWarnings errors [||]
let rOption = "-r:" + outputFilePath
if staticLink then
@ -483,7 +482,7 @@ module rec CompilerAssertHelpers =
compilationRefs, deps
let compileCompilationAux outputDirectory (disposals: ResizeArray<IDisposable>) ignoreWarnings (cmpl: Compilation) : (FSharpDiagnostic[] * string) * string list =
let compileCompilationAux outputDirectory (disposals: ResizeArray<IDisposable>) ignoreWarnings (cmpl: Compilation) : (FSharpDiagnostic[] * int * string) * string list =
let compilationRefs, deps = evaluateReferences outputDirectory disposals ignoreWarnings cmpl
let isExe, sources, options, targetFramework, name =
@ -595,7 +594,7 @@ open CompilerAssertHelpers
type CompilerAssert private () =
static let compileExeAndRunWithOptions options (source: SourceCodeFileKind) =
compile true options source (fun (errors, outputExe) ->
compile true options source (fun (errors, _, outputExe) ->
if errors.Length > 0 then
Assert.Fail (sprintf "Compile had warnings and/or errors: %A" errors)
@ -604,7 +603,7 @@ type CompilerAssert private () =
)
static let compileLibraryAndVerifyILWithOptions options (source: SourceCodeFileKind) (f: ILVerifier -> unit) =
compile false options source (fun (errors, outputFilePath) ->
compile false options source (fun (errors, _, outputFilePath) ->
let errors =
errors |> Array.filter (fun x -> x.Severity = FSharpDiagnosticSeverity.Error)
if errors.Length > 0 then
@ -616,7 +615,7 @@ type CompilerAssert private () =
static let compileLibraryAndVerifyDebugInfoWithOptions options (expectedFile: string) (source: SourceCodeFileKind) =
let options = [| yield! options; yield"--test:DumpDebugInfo" |]
compile false options source (fun (errors, outputFilePath) ->
compile false options source (fun (errors, _, outputFilePath) ->
let errors =
errors |> Array.filter (fun x -> x.Severity = FSharpDiagnosticSeverity.Error)
if errors.Length > 0 then
@ -652,7 +651,7 @@ Updated automatically, please check diffs in your pull request, changes must be
static member CompileWithErrors(cmpl: Compilation, expectedErrors, ?ignoreWarnings) =
let ignoreWarnings = defaultArg ignoreWarnings false
compileCompilation ignoreWarnings cmpl (fun ((errors, _), _) ->
compileCompilation ignoreWarnings cmpl (fun ((errors, _, _), _) ->
assertErrors 0 ignoreWarnings errors expectedErrors)
static member Compile(cmpl: Compilation, ?ignoreWarnings) =
@ -681,7 +680,7 @@ Updated automatically, please check diffs in your pull request, changes must be
let beforeExecute = defaultArg beforeExecute copyDependenciesToOutputDir
let newProcess = defaultArg newProcess false
let onOutput = defaultArg onOutput (fun _ -> ())
compileCompilation ignoreWarnings cmpl (fun ((errors, outputFilePath), deps) ->
compileCompilation ignoreWarnings cmpl (fun ((errors, _, outputFilePath), deps) ->
assertErrors 0 ignoreWarnings errors [||]
beforeExecute outputFilePath deps
if newProcess then
@ -857,12 +856,12 @@ Updated automatically, please check diffs in your pull request, changes must be
CompilerAssert.TypeCheckWithErrors source [| expectedSeverity, expectedErrorNumber, expectedErrorRange, expectedErrorMsg |]
static member CompileExeWithOptions(options, (source: SourceCodeFileKind)) =
compile true options source (fun (errors, _) ->
compile true options source (fun (errors, _, _) ->
if errors.Length > 0 then
Assert.Fail (sprintf "Compile had warnings and/or errors: %A" errors))
static member CompileExeWithOptions(options, (source: string)) =
compile true options (SourceCodeFileKind.Create("test.fs", source)) (fun (errors, _) ->
compile true options (SourceCodeFileKind.Create("test.fs", source)) (fun (errors, _, _) ->
if errors.Length > 0 then
Assert.Fail (sprintf "Compile had warnings and/or errors: %A" errors))

Просмотреть файл

@ -121,23 +121,23 @@ type DirectoryAttribute(dir: string) =
let fsBslSource = readFileOrDefault fsBslFilePath
let ilBslSource = readFileOrDefault ilBslFilePath
{
Source = SourceCodeFileKind.Create(sourceFilePath)
AdditionalSources = []
Baseline =
{ Source = SourceCodeFileKind.Create(sourceFilePath)
AdditionalSources = []
Baseline =
Some
{
SourceFilename = Some sourceFilePath
FSBaseline = { FilePath = fsOutFilePath; BslSource=fsBslFilePath; Content = fsBslSource }
ILBaseline = { FilePath = ilOutFilePath; BslSource=ilBslFilePath ; Content = ilBslSource }
}
Options = []
OutputType = Library
Name = Some filename
IgnoreWarnings = false
References = []
OutputDirectory = outputDirectory
TargetFramework = TargetFramework.Current} |> FS
Options = []
OutputType = Library
Name = Some filename
IgnoreWarnings = false
References = []
OutputDirectory = outputDirectory
TargetFramework = TargetFramework.Current
} |> FS
member _.BaselineSuffix with get() = baselineSuffix and set v = baselineSuffix <- v
member _.Includes with get() = includes and set v = includes <- v

Просмотреть файл

@ -11,65 +11,7 @@ open FSharp.Compiler
open FSharp.Compiler.Interactive.Shell
open FSharp.Compiler.Diagnostics
open FSharp.Compiler.EditorServices
type CapturedTextReader() =
inherit TextReader()
let queue = Queue<char>()
member _.ProvideInput(text: string) =
for c in text.ToCharArray() do
queue.Enqueue(c)
override _.Peek() =
if queue.Count > 0 then queue.Peek() |> int else -1
override _.Read() =
if queue.Count > 0 then queue.Dequeue() |> int else -1
type RedirectConsoleInput() =
let oldStdIn = Console.In
let newStdIn = new CapturedTextReader()
do Console.SetIn(newStdIn)
member _.ProvideInput(text: string) =
newStdIn.ProvideInput(text)
interface IDisposable with
member _.Dispose() =
Console.SetIn(oldStdIn)
newStdIn.Dispose()
type EventedTextWriter() =
inherit TextWriter()
let sb = StringBuilder()
let lineWritten = Event<string>()
member _.LineWritten = lineWritten.Publish
override _.Encoding = Encoding.UTF8
override _.Write(c: char) =
if c = '\n' then
let line =
let v = sb.ToString()
if v.EndsWith("\r") then v.Substring(0, v.Length - 1)
else v
sb.Clear() |> ignore
lineWritten.Trigger(line)
else sb.Append(c) |> ignore
type RedirectConsoleOutput() =
let outputProduced = Event<string>()
let errorProduced = Event<string>()
let oldStdOut = Console.Out
let oldStdErr = Console.Error
let newStdOut = new EventedTextWriter()
let newStdErr = new EventedTextWriter()
do newStdOut.LineWritten.Add outputProduced.Trigger
do newStdErr.LineWritten.Add errorProduced.Trigger
do Console.SetOut(newStdOut)
do Console.SetError(newStdErr)
member _.OutputProduced = outputProduced.Publish
member _.ErrorProduced = errorProduced.Publish
interface IDisposable with
member _.Dispose() =
Console.SetOut(oldStdOut)
Console.SetError(oldStdErr)
newStdOut.Dispose()
newStdErr.Dispose()
open FSharp.Test.Utilities
[<RequireQualifiedAccess>]
type LangVersion =

Просмотреть файл

@ -8,11 +8,13 @@ open System.Reflection
open System.Collections.Immutable
open System.Diagnostics
open System.Threading
open System.Text
open System.Threading.Tasks
open Microsoft.CodeAnalysis
open Microsoft.CodeAnalysis.CSharp
open TestFramework
open NUnit.Framework
open System.Collections.Generic
type TheoryForNETCOREAPPAttribute() =
inherit Xunit.TheoryAttribute()
@ -35,6 +37,83 @@ type FactForDESKTOPAttribute() =
// This file mimics how Roslyn handles their compilation references for compilation testing
module Utilities =
type CapturedTextReader() =
inherit TextReader()
let queue = Queue<char>()
member _.ProvideInput(text: string) =
for c in text.ToCharArray() do
queue.Enqueue(c)
override _.Peek() =
if queue.Count > 0 then queue.Peek() |> int else -1
override _.Read() =
if queue.Count > 0 then queue.Dequeue() |> int else -1
type RedirectConsoleInput() =
let oldStdIn = Console.In
let newStdIn = new CapturedTextReader()
do Console.SetIn(newStdIn)
member _.ProvideInput(text: string) =
newStdIn.ProvideInput(text)
interface IDisposable with
member _.Dispose() =
Console.SetIn(oldStdIn)
newStdIn.Dispose()
type EventedTextWriter() =
inherit TextWriter()
let sb = StringBuilder()
let lineWritten = Event<string>()
member _.LineWritten = lineWritten.Publish
override _.Encoding = Encoding.UTF8
override _.Write(c: char) =
if c = '\n' then
let line =
let v = sb.ToString()
if v.EndsWith("\r") then v.Substring(0, v.Length - 1)
else v
sb.Clear() |> ignore
lineWritten.Trigger(line)
else sb.Append(c) |> ignore
type RedirectConsoleOutput() =
let outputProduced = Event<string>()
let errorProduced = Event<string>()
let oldStdOut = Console.Out
let oldStdErr = Console.Error
let newStdOut = new EventedTextWriter()
let newStdErr = new EventedTextWriter()
do newStdOut.LineWritten.Add outputProduced.Trigger
do newStdErr.LineWritten.Add errorProduced.Trigger
do Console.SetOut(newStdOut)
do Console.SetError(newStdErr)
member _.OutputProduced = outputProduced.Publish
member _.ErrorProduced = errorProduced.Publish
interface IDisposable with
member _.Dispose() =
Console.SetOut(oldStdOut)
Console.SetError(oldStdErr)
newStdOut.Dispose()
newStdErr.Dispose()
type RedirectConsole() =
let redirector = new RedirectConsoleOutput()
let outputLines = StringBuilder()
let errorLines = StringBuilder()
do redirector.OutputProduced.Add (fun line -> outputLines.AppendLine line |>ignore)
do redirector.ErrorProduced.Add(fun line -> errorLines.AppendLine line |>ignore)
member _.Output () = outputLines.ToString()
member _.ErrorOutput () = errorLines.ToString()
interface IDisposable with
member _.Dispose() = (redirector :> IDisposable).Dispose()
type Async with
static member RunImmediate (computation: Async<'T>, ?cancellationToken ) =
let cancellationToken = defaultArg cancellationToken Async.DefaultCancellationToken

Просмотреть файл

@ -1,2 +0,0 @@
# generated as part of the test
help40.txt

Просмотреть файл

@ -1,3 +0,0 @@
// #NoMT #CompilerOptions #RequiresENU
#light
exit 0

Просмотреть файл

@ -1,6 +0,0 @@
# ReqENU means that the test is non-localized
ReqENU SOURCE=dummy.fsx COMPILE_ONLY=1 PRECMD="\$FSC_PIPE >help40.txt -? 2>&1" POSTCMD="\$FSI_PIPE --nologo --quiet --exec ..\\..\\..\\comparer.fsx help40.txt help40.437.1033.bsl" # -?
ReqENU SOURCE=dummy.fsx COMPILE_ONLY=1 PRECMD="\$FSC_PIPE >help40.txt --help 2>&1" POSTCMD="\$FSI_PIPE --nologo --quiet --exec ..\\..\\..\\comparer.fsx help40.txt help40.437.1033.bsl" # --help
ReqENU SOURCE=dummy.fsx COMPILE_ONLY=1 PRECMD="\$FSC_PIPE >help40.txt /? 2>&1" POSTCMD="\$FSI_PIPE --nologo --quiet --exec ..\\..\\..\\comparer.fsx help40.txt help40.437.1033.bsl" # /?

Просмотреть файл

@ -10,7 +10,6 @@ CompilerOptions01,NoMT,Determinism CompilerOptions\fsc\determinism
CompilerOptions01,NoMT CompilerOptions\fsc\dumpAllCommandLineOptions
CompilerOptions01,NoMT CompilerOptions\fsc\flaterrors
CompilerOptions02,NoMT,gcc CompilerOptions\fsc\gccerrors
CompilerOptions01,NoMT,help CompilerOptions\fsc\help
CompilerOptions01,NoMT CompilerOptions\fsc\highentropyva
CompilerOptions01,NoMT CompilerOptions\fsc\langversion
CompilerOptions01,NoMT CompilerOptions\fsc\lib