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
|
2023-12-10 02:48:56 +01:00
|
|
|
|
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()
|
|
|
|
|
{
|
2023-12-10 07:30:19 +01:00
|
|
|
|
AssertionFailureHandler handler = (ref readonly 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
|
|
|
|
}
|
2022-11-12 02:21:07 +01:00
|
|
|
|
}
|