Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5a04fd4
Porting selected fsharpsuite tests to ComponentTests without fsc.exe/…
T-Gro Jan 10, 2023
b20a672
Merge branch 'main' into fsharp-suite-reduction-diet
T-Gro Jan 10, 2023
ca842bc
Support for multisource tests (fsi,test2)
T-Gro Jan 10, 2023
cd04c01
Making migrated tests pass
T-Gro Jan 11, 2023
9df37fc
Merge branch 'main' into fsharp-suite-reduction-diet
T-Gro Jan 12, 2023
623eb47
Pinvoke tests only on windows
T-Gro Jan 12, 2023
381e1f2
negTests -> rendering of errors to match baseline files (to be finis…
T-Gro Jan 13, 2023
5f02e37
Merge branch 'main' into fsharp-suite-reduction-diet
T-Gro Jan 13, 2023
2baf5fa
Merge branch 'main' into fsharp-suite-reduction-diet
vzarytovskii Jan 19, 2023
f77bbd4
Merge branch 'main' into fsharp-suite-reduction-diet
T-Gro Jan 24, 2023
6712b6b
Merge branch 'main' into fsharp-suite-reduction-diet
T-Gro Jan 24, 2023
d955b2d
negative tests string comparison
T-Gro Jan 24, 2023
fd6fb45
neg test integration
T-Gro Jan 25, 2023
64e8b05
making array negative tests pass
T-Gro Jan 25, 2023
d499290
TEST_UPDATE_BSL support
T-Gro Jan 26, 2023
fe2ad0b
Removing wrong duplicate definitions from old .bsl files
T-Gro Jan 26, 2023
3b638f6
Putting stderr output of .fsx tests into test output window
T-Gro Jan 26, 2023
34e26e9
Overload resolution tests migrated over
T-Gro Jan 26, 2023
25dbb25
Separating migrated tests into files, removing them from old tests.fs
T-Gro Jan 26, 2023
f398ebe
Merge branch 'main' into fsharp-suite-reduction-diet
T-Gro Jan 31, 2023
547b68c
Test framework - script execution in separate thread (to get shorter …
T-Gro Jan 31, 2023
05093a0
Trying to address stackoverflow for MacOs CI run
T-Gro Jan 31, 2023
4b16738
Fixing negtest45 run to match older test suite
T-Gro Jan 31, 2023
086e272
Apply suggestions from code review
T-Gro Feb 6, 2023
466b232
Merge branch 'main' into fsharp-suite-reduction-diet
T-Gro Feb 6, 2023
27928bf
conflicts resolved
T-Gro Feb 6, 2023
d05aeef
Merge branch 'main' into fsharp-suite-reduction-diet
T-Gro Feb 6, 2023
bab08f8
Merge branch 'main' into fsharp-suite-reduction-diet
T-Gro Feb 10, 2023
81d060f
Apply suggestions from code review
T-Gro Feb 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,8 @@ stages:
- checkout: self
clean: true
- script: ./eng/cibuild.sh --configuration $(_BuildConfig) --testcoreclr
env:
COMPlus_DefaultStackSize: 1000000
displayName: Build / Test
- task: PublishTestResults@2
displayName: Publish Test Results
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ namespace FSharp.Compiler.ComponentTests.Conformance.LexicalFiltering.Basic
open Xunit
open FSharp.Test
open FSharp.Test.Compiler
open FSharp.Test.Compiler.Assertions.StructuredResultsAsserts

module OffsideExceptions =

type FileAttribute(file) =
inherit DirectoryAttribute(__SOURCE_DIRECTORY__, Includes=[|file|])

Expand Down
1 change: 1 addition & 0 deletions tests/FSharp.Compiler.ComponentTests/EmittedIL/Enums.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace FSharp.Compiler.ComponentTests.EmittedIL

open Xunit
open FSharp.Test.Compiler
open FSharp.Test.Compiler.Assertions.StructuredResultsAsserts

module Enums =

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace FSharp.Compiler.ComponentTests.EmittedIL

open Xunit
open FSharp.Test.Compiler
open FSharp.Test.Compiler.Assertions.StructuredResultsAsserts

module ``Literals`` =

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace FSharp.Compiler.ComponentTests.ErrorMessages

open Xunit
open FSharp.Test.Compiler
open FSharp.Test.Compiler.Assertions.StructuredResultsAsserts

module ``Unsupported Attributes`` =

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@
<Compile Include="Miscellaneous\ListLiterals.fs" />
<Compile Include="Miscellaneous\SemanticClassificationKeyBuilder.fs" />
<Compile Include="Miscellaneous\XmlDoc.fs" />
<Compile Include="Miscellaneous\FsharpSuiteMigrated.fs" />
<Compile Include="Miscellaneous\MigratedCoreTests.fs" />
<Compile Include="Miscellaneous\MigratedOverloadTests.fs" />
<Compile Include="Miscellaneous\MigratedTypeCheckTests.fs" />
<Compile Include="Miscellaneous\GraphTests.fs" />
<Compile Include="Signatures\TestHelpers.fs" />
<Compile Include="Signatures\ModuleOrNamespaceTests.fs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ module FSharp.Compiler.ComponentTests.Language.SequenceExpressionTests

open Xunit
open FSharp.Test.Compiler
open FSharp.Test.ScriptHelpers



let fsiSession = getSessionForEval()
let fsiSession = getSessionForEval [||] LangVersion.Preview

let runCode = evalInSharedSession fsiSession

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace FSharp.Compiler.ComponentTests.Miscellaneous.FsharpSuiteMigrated

open System
open System.IO
open Xunit
open FSharp.Test
open FSharp.Test.Compiler
open FSharp.Test.ScriptHelpers



module Configuration =
let supportedNames = set ["testlib.fsi";"testlib.fs";"test.mli";"test.ml";"test.fsi";"test.fs";"test2.fsi";"test2.fs";"test.fsx";"test2.fsx"]

module ScriptRunner =
open Internal.Utilities.Library

let private createEngine(args,version) =
let scriptingEnv = getSessionForEval args version
scriptingEnv.Eval """
let errorStringWriter = new System.IO.StringWriter()
let oldConsoleError = System.Console.Error
System.Console.SetError(errorStringWriter)
let exit (code:int) =
System.Console.SetError(oldConsoleError)
if code=0 then
()
else failwith $"Script called function 'exit' with code={code} and collected in stderr: {errorStringWriter.ToString()}" """ |> ignore
scriptingEnv

let defaultDefines =
[
#if NETCOREAPP
"NETCOREAPP"
#endif
]

let runScriptFile version (cu:CompilationUnit) =
let cu = cu |> withDefines defaultDefines
match cu with
| FS fsSource ->
File.Delete("test.ok")
let engine = createEngine (fsSource.Options |> Array.ofList,version)
let res = evalScriptFromDiskInSharedSession engine cu
match res with
| CompilationResult.Failure _ -> res
| CompilationResult.Success s ->
if File.Exists("test.ok") then
res
else
failwith $"Results looked correct, but 'test.ok' file was not created. Result: %A{s}"

| _ -> failwith $"Compilation unit other than fsharp is not supported, cannot process %A{cu}"

/// This test file was created by porting over (slower) FsharpSuite.Tests
/// In order to minimize human error, the test definitions have been copy-pasted and this adapter provides implementations of the test functions
module TestFrameworkAdapter =
open FSharp.Test.Compiler.Assertions.TextBasedDiagnosticAsserts

type ExecutionMode =
| FSC_DEBUG
| FSC_OPTIMIZED
| FSI
| COMPILED_EXE_APP
| NEG_TEST_BUILD of testName:string

let baseFolder = Path.Combine(__SOURCE_DIRECTORY__,"..","..","fsharp") |> Path.GetFullPath

let diffNegativeBaseline (cr:CompilationUnit) absFolder testName _version =
let expectedFiles = Directory.GetFiles(absFolder, testName + ".*")
let baselines =
[ for f in expectedFiles do
match Path.GetExtension(f) with
| ".bsl" -> cr, f
| ".vsbsl" -> cr |> withOptions ["--test:ContinueAfterParseFailure"], f
| _ -> () ]
[ for compilationUnit,baseline in baselines do
compilationUnit
|> typecheck
|> withResultsMatchingFile baseline ]
|> List.head


let adjustVersion version bonusArgs =
match version with
| LangVersion.V47 -> "4.7",bonusArgs
| LangVersion.V50 -> "5.0",bonusArgs
| LangVersion.V60 -> "6.0",bonusArgs
| LangVersion.V70 -> "7.0",bonusArgs
| LangVersion.Preview -> "preview",bonusArgs
| LangVersion.Latest -> "latest", bonusArgs
| LangVersion.SupportsMl -> "5.0", "--mlcompatibility" :: bonusArgs


let singleTestBuildAndRunAuxVersion (folder:string) bonusArgs mode langVersion =
let absFolder = Path.Combine(baseFolder,folder)
let supportedNames, files =
match mode with
| NEG_TEST_BUILD testName ->
let nameSet =
Configuration.supportedNames
.Add(testName+".fsx")
.Add(testName+".fs")
.Add(testName+".fsi")
.Add(testName+"-pre.fs")
let files = Directory.GetFiles(absFolder,"*.fs*") |> Array.filter(fun n -> nameSet.Contains(Path.GetFileName(n)))
nameSet, files
| _ -> Configuration.supportedNames, Directory.GetFiles(absFolder,"test*.fs*")

let mainFile,otherFiles =
match files.Length with
| 0 -> Directory.GetFiles(absFolder,"*.ml") |> Array.exactlyOne, [||]
| 1 -> files |> Array.exactlyOne, [||]
| _ ->
let mainFile,dependencies =
files
|> Array.filter (fun n -> supportedNames.Contains(Path.GetFileName(n)))
// Convention in older FsharpSuite: test2 goes last, longer names like testlib before test, .fsi before .fs on equal filenames
|> Array.sortBy (fun n -> n.Contains("test2"), -n.IndexOf('.'), n.EndsWith(".fsi") |> not)
|> Array.splitAt 1

mainFile[0],dependencies

let version,bonusArgs = adjustVersion langVersion bonusArgs

FsFromPath mainFile
|> withAdditionalSourceFiles [for f in otherFiles -> SourceFromPath f]
|> withLangVersion version
|> fun cu ->
match mode with
| FSC_DEBUG | FSC_OPTIMIZED | FSI | COMPILED_EXE_APP ->
cu
|> ignoreWarnings
|> withOptions (["--nowarn:0988;3370"] @ bonusArgs)
| NEG_TEST_BUILD _ ->
cu |>
withOptions (["--vserrors";"--maxerrors:10000";"--warnaserror";"--warn:3";"--nowarn:20;21;1178;52"] @ bonusArgs)
|> fun cu ->
match mode with
| FSC_DEBUG ->
cu
|> withDebug
|> withNoOptimize
|> ScriptRunner.runScriptFile langVersion
|> shouldSucceed
| FSC_OPTIMIZED ->
cu
|> withOptimize
|> withNoDebug
|> ScriptRunner.runScriptFile langVersion
|> shouldSucceed
| FSI ->
cu
|> ScriptRunner.runScriptFile langVersion
|> shouldSucceed
| COMPILED_EXE_APP ->
cu
|> withDefines ("TESTS_AS_APP" :: ScriptRunner.defaultDefines)
|> compileExeAndRun
|> shouldSucceed
| NEG_TEST_BUILD testName -> diffNegativeBaseline (cu |> withName mainFile) absFolder testName langVersion

|> ignore<CompilationResult>


let singleTestBuildAndRunAux folder bonusArgs mode = singleTestBuildAndRunAuxVersion folder bonusArgs mode LangVersion.Latest
let singleTestBuildAndRunVersion folder mode version = singleTestBuildAndRunAuxVersion folder [] mode version
let singleTestBuildAndRun folder mode = singleTestBuildAndRunVersion folder mode LangVersion.Latest

let singleVersionedNegTestAux folder bonusArgs version testName =
singleTestBuildAndRunAuxVersion folder bonusArgs (NEG_TEST_BUILD testName) version
let singleVersionedNegTest (folder:string) (version:LangVersion) (testName:string) =
singleVersionedNegTestAux folder [] version testName
let singleNegTest folder testName = singleVersionedNegTest folder LangVersion.Latest testName
Loading