Skip to content

Commit

Permalink
Switched IL.Verification related warnings to NUnit normal log.
Browse files Browse the repository at this point in the history
  • Loading branch information
kekyo committed Oct 31, 2021
1 parent 968941c commit 36c9ee9
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions tests/IL2C.Core.Test.Fixture/TestFramework.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@

using IL2C.Metadata;
using IL2C.Internal;
using NUnit.Framework.Internal;
using NUnit.Framework.Interfaces;
using ILVerify;

#pragma warning disable CS0436

Expand Down Expand Up @@ -402,13 +405,19 @@ await TestUtilities.CopyResourceToStreamAsync(
ToArray();
if (verifyResults.Length >= 1)
{
foreach (var resultx in verifyResults.Take(verifyResults.Length - 1))
// TODO: ILVerify (IL.Verification library comes portable version of PEVerify)
// produces a lot of minor or invalid result.
// So currently IL2C doesn't make error message.
static void RecordInformation(string message)
{
Assert.Warn($"{caseInfo.Method.DeclaringType.FullName}.{caseInfo.Method.Name}: [{resultx.result.Code}/{resultx.result.ExceptionID?.ToString() ?? "None"}]: {string.Format(resultx.result.Message, resultx.result.Args ?? Array.Empty<object>())}: {string.Join(",", resultx.result.ErrorArguments.Select(a => $"{a.Name}={a.Value}"))}: {resultx.instruction}");
var currentResult = TestExecutionContext.CurrentContext.CurrentResult;
currentResult.OutWriter.WriteLine(message);
}

var result = verifyResults[verifyResults.Length - 1];
Assert.Fail($"{caseInfo.Method.DeclaringType.FullName}.{caseInfo.Method.Name}: [{result.result.Code}/{result.result.ExceptionID?.ToString() ?? "None"}]: {string.Format(result.result.Message, result.result.Args ?? Array.Empty<object>())}: {string.Join(",", result.result.ErrorArguments.Select(a => $"{a.Name}={a.Value}"))}: {result.instruction}");
foreach (var resultx in verifyResults)
{
RecordInformation($"IL.Verification: {caseInfo.Method.DeclaringType.FullName}.{caseInfo.Method.Name}: [{resultx.result.Code}/{resultx.result.ExceptionID?.ToString() ?? "None"}]: {string.Format(resultx.result.Message, resultx.result.Args ?? Array.Empty<object>())}: {string.Join(",", resultx.result.ErrorArguments?.Select(a => $"{a.Name}={a.Value}") ?? Array.Empty<string>())}: {resultx.instruction}");
}
}

///////////////////////////////////////////////
Expand Down

0 comments on commit 36c9ee9

Please sign in to comment.