-
Notifications
You must be signed in to change notification settings - Fork 804
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Trying to fix the stack overflow case in ilxgen * Added stack guard to GenExpr * Still trying to resolve this * This resolves the stack overflow, but need to review * Adding better tests * Fixing compile and run successfully assert * One test passes * Fixing a few things * Delete fieldNames.txt * Update IlxGen.fs * Update IlxGen.fs * Update IlxGen.fs * More work on CompilerAssert * Got verifying IL working on method * Always delay gen methods when already gen'ing in one. Some small refactoring, created IlxMethodInfo type instead of using large tuples. * Better error message for stack overflow * small msg change * Simplifying some tests * Removing attempt at bringing a FSharpQA test to nunit * Fixing up seq points * More seq point tweaks * Trying to fix ilxgen * Fixing ilxgen * Using RunScript * Fix test * removed IlxMethodInfo * trivial refactor * another quick refactor
- Loading branch information
Showing
9 changed files
with
3,933 additions
and
275 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. | ||
|
||
namespace FSharp.Compiler.UnitTests | ||
|
||
open System | ||
open System.IO | ||
open System.Diagnostics | ||
|
||
open NUnit.Framework | ||
open TestFramework | ||
|
||
[<RequireQualifiedAccess>] | ||
module ILChecker = | ||
|
||
let config = initializeSuite () | ||
|
||
let private exec exe args = | ||
let startInfo = ProcessStartInfo(exe, String.concat " " args) | ||
startInfo.RedirectStandardError <- true | ||
startInfo.UseShellExecute <- false | ||
use p = Process.Start(startInfo) | ||
p.WaitForExit() | ||
p.StandardError.ReadToEnd(), p.ExitCode | ||
|
||
/// Filters i.e ['The system type \'System.ReadOnlySpan`1\' was required but no referenced system DLL contained this type'] | ||
let private filterSpecialComment (text: string) = | ||
let pattern = @"(\[\'(.*?)\'\])" | ||
System.Text.RegularExpressions.Regex.Replace(text, pattern, | ||
(fun me -> String.Empty) | ||
) | ||
|
||
let private checkILAux ildasmArgs dllFilePath expectedIL = | ||
let ilFilePath = Path.ChangeExtension(dllFilePath, ".il") | ||
|
||
let mutable errorMsgOpt = None | ||
try | ||
let ildasmPath = config.ILDASM | ||
|
||
exec ildasmPath (ildasmArgs @ [ sprintf "%s /out=%s" dllFilePath ilFilePath ]) |> ignore | ||
|
||
let text = File.ReadAllText(ilFilePath) | ||
let blockComments = @"/\*(.*?)\*/" | ||
let lineComments = @"//(.*?)\r?\n" | ||
let strings = @"""((\\[^\n]|[^""\n])*)""" | ||
let verbatimStrings = @"@(""[^""]*"")+" | ||
let textNoComments = | ||
System.Text.RegularExpressions.Regex.Replace(text, | ||
blockComments + "|" + lineComments + "|" + strings + "|" + verbatimStrings, | ||
(fun me -> | ||
if (me.Value.StartsWith("/*") || me.Value.StartsWith("//")) then | ||
if me.Value.StartsWith("//") then Environment.NewLine else String.Empty | ||
else | ||
me.Value), System.Text.RegularExpressions.RegexOptions.Singleline) | ||
|> filterSpecialComment | ||
|
||
expectedIL | ||
|> List.iter (fun (ilCode: string) -> | ||
let expectedLines = ilCode.Split('\n') | ||
let startIndex = textNoComments.IndexOf(expectedLines.[0]) | ||
if startIndex = -1 || textNoComments.Length < startIndex + ilCode.Length then | ||
errorMsgOpt <- Some("==EXPECTED CONTAINS==\n" + ilCode + "\n") | ||
else | ||
let errors = ResizeArray() | ||
let actualLines = textNoComments.Substring(startIndex, textNoComments.Length - startIndex).Split('\n') | ||
for i = 0 to expectedLines.Length - 1 do | ||
let expected = expectedLines.[i].Trim() | ||
let actual = actualLines.[i].Trim() | ||
if expected <> actual then | ||
errors.Add(sprintf "\n==\nName: %s\n\nExpected:\t %s\nActual:\t\t %s\n==" actualLines.[0] expected actual) | ||
|
||
if errors.Count > 0 then | ||
let msg = String.concat "\n" errors + "\n\n\n==EXPECTED==\n" + ilCode + "\n" | ||
errorMsgOpt <- Some(msg + "\n\n\n==ACTUAL==\n" + String.Join("\n", actualLines, 0, expectedLines.Length)) | ||
) | ||
|
||
if expectedIL.Length = 0 then | ||
errorMsgOpt <- Some ("No Expected IL") | ||
|
||
match errorMsgOpt with | ||
| Some(msg) -> errorMsgOpt <- Some(msg + "\n\n\n==ENTIRE ACTUAL==\n" + textNoComments) | ||
| _ -> () | ||
finally | ||
try File.Delete(ilFilePath) with | _ -> () | ||
|
||
match errorMsgOpt with | ||
| Some(errorMsg) -> | ||
Assert.Fail(errorMsg) | ||
| _ -> () | ||
|
||
let checkILItem item dllFilePath expectedIL = | ||
checkILAux [ sprintf "/item:%s" item ] dllFilePath expectedIL | ||
|
||
let checkILItemWithLineNumbers item dllFilePath expectedIL = | ||
checkILAux [ sprintf "/item:\"%s\"" item; "/linenum" ] dllFilePath expectedIL | ||
|
||
let checkIL dllFilePath expectedIL = | ||
checkILAux [] dllFilePath expectedIL |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.