2020-02-09 08:25:21 +01:00
|
|
|
|
using System.Diagnostics;
|
2021-03-29 00:50:29 +02:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using LibHac.Diag;
|
2020-02-09 08:25:21 +01:00
|
|
|
|
using LibHac.Tests;
|
|
|
|
|
using Xunit.Abstractions;
|
|
|
|
|
using Xunit.Sdk;
|
|
|
|
|
|
|
|
|
|
[assembly: Xunit.TestFramework("LibHac.Tests." + nameof(LibHacTestFramework), "LibHac.Tests")]
|
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
namespace LibHac.Tests;
|
|
|
|
|
|
|
|
|
|
public class LibHacTestFramework : XunitTestFramework
|
2020-02-09 08:25:21 +01:00
|
|
|
|
{
|
2021-11-14 20:08:57 +01:00
|
|
|
|
public LibHacTestFramework(IMessageSink messageSink)
|
|
|
|
|
: base(messageSink)
|
2020-02-09 08:25:21 +01:00
|
|
|
|
{
|
2021-11-14 20:08:57 +01:00
|
|
|
|
SetDebugHandler();
|
|
|
|
|
SetResultNames();
|
|
|
|
|
}
|
2020-02-09 08:25:21 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
// Todo: Catch assertions in PathToolTestGenerator.cpp
|
|
|
|
|
private static readonly string[] SkipAbortFunctions = { "Normalize" };
|
2021-03-29 00:50:29 +02:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
private static void SetDebugHandler()
|
|
|
|
|
{
|
|
|
|
|
AssertionFailureHandler handler = (in AssertionInfo info) =>
|
2020-02-09 08:25:21 +01:00
|
|
|
|
{
|
2021-11-14 20:08:57 +01:00
|
|
|
|
if (SkipAbortFunctions.Contains(info.FunctionName))
|
2021-03-29 00:50:29 +02:00
|
|
|
|
{
|
2021-11-14 20:08:57 +01:00
|
|
|
|
return AssertionFailureOperation.Continue;
|
|
|
|
|
}
|
2021-03-29 00:50:29 +02:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
return AssertionFailureOperation.Abort;
|
|
|
|
|
};
|
2021-03-29 00:50:29 +02:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
Assert.SetAssertionFailureHandler(handler);
|
|
|
|
|
Trace.Listeners.Clear();
|
|
|
|
|
Trace.Listeners.Add(new DebugAssertHandler());
|
|
|
|
|
}
|
2020-02-09 08:25:21 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
private static void SetResultNames()
|
|
|
|
|
{
|
|
|
|
|
Result.SetNameResolver(new ResultNameResolver());
|
2020-02-09 08:25:21 +01:00
|
|
|
|
}
|
|
|
|
|
}
|