mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
Initial commit
This commit is contained in:
commit
3c7cc0c973
8391 changed files with 704313 additions and 0 deletions
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Packages.Rider.Editor.UnitTesting
|
||||
{
|
||||
public class CallbackData : ScriptableSingleton<CallbackData>
|
||||
{
|
||||
public bool isRider;
|
||||
|
||||
[UsedImplicitly] public static event EventHandler Changed = (sender, args) => { };
|
||||
|
||||
internal void RaiseChangedEvent()
|
||||
{
|
||||
Changed(null, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public List<TestEvent> events = new List<TestEvent>();
|
||||
|
||||
[UsedImplicitly]
|
||||
public void Clear()
|
||||
{
|
||||
events.Clear();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 010246a07de7cb34185a2a7b1c1fad59
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,18 @@
|
|||
#if TEST_FRAMEWORK
|
||||
using UnityEditor;
|
||||
using UnityEditor.TestTools.TestRunner.Api;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Packages.Rider.Editor.UnitTesting
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
internal static class CallbackInitializer
|
||||
{
|
||||
static CallbackInitializer()
|
||||
{
|
||||
if (CallbackData.instance.isRider)
|
||||
ScriptableObject.CreateInstance<TestRunnerApi>().RegisterCallbacks(ScriptableObject.CreateInstance<TestsCallback>(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: aa1c6b1a353ab464782fc1e7c051eb02
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,47 @@
|
|||
using JetBrains.Annotations;
|
||||
using UnityEngine;
|
||||
#if TEST_FRAMEWORK
|
||||
using UnityEditor;
|
||||
using UnityEditor.TestTools.TestRunner.Api;
|
||||
#endif
|
||||
|
||||
namespace Packages.Rider.Editor.UnitTesting
|
||||
{
|
||||
public static class RiderTestRunner
|
||||
{
|
||||
#if TEST_FRAMEWORK
|
||||
private static readonly TestsCallback Callback = ScriptableObject.CreateInstance<TestsCallback>();
|
||||
#endif
|
||||
[UsedImplicitly]
|
||||
public static void RunTests(int testMode, string[] assemblyNames, string[] testNames, string[] categoryNames, string[] groupNames, int? buildTarget)
|
||||
{
|
||||
#if !TEST_FRAMEWORK
|
||||
Debug.LogError("Update Test Framework package to v.1.1.1+ to run tests from Rider.");
|
||||
#else
|
||||
CallbackData.instance.isRider = true;
|
||||
|
||||
var api = ScriptableObject.CreateInstance<TestRunnerApi>();
|
||||
var settings = new ExecutionSettings();
|
||||
var filter = new Filter
|
||||
{
|
||||
assemblyNames = assemblyNames,
|
||||
testNames = testNames,
|
||||
categoryNames = categoryNames,
|
||||
groupNames = groupNames,
|
||||
targetPlatform = (BuildTarget?) buildTarget
|
||||
};
|
||||
|
||||
if (testMode > 0) // for future use - test-framework would allow running both Edit and Play test at once
|
||||
filter.testMode = (TestMode) testMode;
|
||||
|
||||
settings.filters = new []{
|
||||
filter
|
||||
};
|
||||
api.Execute(settings);
|
||||
|
||||
api.UnregisterCallbacks(Callback); // avoid multiple registrations
|
||||
api.RegisterCallbacks(Callback); // This can be used to receive information about when the test suite and individual tests starts and stops. Provide this with a scriptable object implementing ICallbacks
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5c3b27069cb3ddf42ba1260eeefcdd1c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using NUnit.Framework.Interfaces;
|
||||
|
||||
namespace Packages.Rider.Editor.UnitTesting
|
||||
{
|
||||
[Serializable]
|
||||
public enum EventType { TestStarted, TestFinished, RunFinished }
|
||||
|
||||
[Serializable]
|
||||
public class TestEvent
|
||||
{
|
||||
public EventType type;
|
||||
public string id;
|
||||
public string assemblyName;
|
||||
public string output;
|
||||
public TestStatus testStatus;
|
||||
public double duration;
|
||||
public string parentId;
|
||||
|
||||
public TestEvent(EventType type, string id, string assemblyName, string output, double duration, TestStatus testStatus, string parentID)
|
||||
{
|
||||
this.type = type;
|
||||
this.id = id;
|
||||
this.assemblyName = assemblyName;
|
||||
this.output = output;
|
||||
this.testStatus = testStatus;
|
||||
this.duration = duration;
|
||||
parentId = parentID;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f9413c47b3a14a64e8810ce76d1a6032
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,83 @@
|
|||
#if TEST_FRAMEWORK
|
||||
using System;
|
||||
using System.Text;
|
||||
using UnityEditor.TestTools.TestRunner.Api;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Packages.Rider.Editor.UnitTesting
|
||||
{
|
||||
public class TestsCallback : ScriptableObject, ICallbacks
|
||||
{
|
||||
public void RunFinished(ITestResultAdaptor result)
|
||||
{
|
||||
CallbackData.instance.isRider = false;
|
||||
|
||||
CallbackData.instance.events.Add(
|
||||
new TestEvent(EventType.RunFinished, "", "","", 0, ParseTestStatus(result.TestStatus), ""));
|
||||
CallbackData.instance.RaiseChangedEvent();
|
||||
}
|
||||
|
||||
public void TestStarted(ITestAdaptor result)
|
||||
{
|
||||
if (result.Method == null) return;
|
||||
|
||||
CallbackData.instance.events.Add(
|
||||
new TestEvent(EventType.TestStarted, GetUniqueName(result), result.Method.TypeInfo.Assembly.GetName().Name, "", 0, ParseTestStatus(TestStatus.Passed), result.ParentFullName));
|
||||
CallbackData.instance.RaiseChangedEvent();
|
||||
}
|
||||
|
||||
public void TestFinished(ITestResultAdaptor result)
|
||||
{
|
||||
if (result.Test.Method == null) return;
|
||||
|
||||
CallbackData.instance.events.Add(
|
||||
new TestEvent(EventType.TestFinished, GetUniqueName(result.Test), result.Test.Method.TypeInfo.Assembly.GetName().Name, ExtractOutput(result), result.Duration, ParseTestStatus(result.TestStatus), result.Test.ParentFullName));
|
||||
CallbackData.instance.RaiseChangedEvent();
|
||||
}
|
||||
|
||||
// todo: reimplement JetBrains.Rider.Unity.Editor.AfterUnity56.UnitTesting.TestEventsSender.GetUniqueName
|
||||
private static string GetUniqueName(ITestAdaptor test)
|
||||
{
|
||||
string str = test.FullName;
|
||||
return str;
|
||||
}
|
||||
|
||||
public void RunStarted(ITestAdaptor testsToRun)
|
||||
{
|
||||
}
|
||||
|
||||
private static NUnit.Framework.Interfaces.TestStatus ParseTestStatus(TestStatus testStatus)
|
||||
{
|
||||
return (NUnit.Framework.Interfaces.TestStatus)Enum.Parse(typeof(NUnit.Framework.Interfaces.TestStatus), testStatus.ToString());
|
||||
}
|
||||
|
||||
private static string ExtractOutput(ITestResultAdaptor testResult)
|
||||
{
|
||||
var stringBuilder = new StringBuilder();
|
||||
if (testResult.Message != null)
|
||||
{
|
||||
stringBuilder.AppendLine("Message: ");
|
||||
stringBuilder.AppendLine(testResult.Message);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(testResult.Output))
|
||||
{
|
||||
stringBuilder.AppendLine("Output: ");
|
||||
stringBuilder.AppendLine(testResult.Output);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(testResult.StackTrace))
|
||||
{
|
||||
stringBuilder.AppendLine("Stacktrace: ");
|
||||
stringBuilder.AppendLine(testResult.StackTrace);
|
||||
}
|
||||
|
||||
var result = stringBuilder.ToString();
|
||||
if (result.Length > 0)
|
||||
return result;
|
||||
|
||||
return testResult.Output ?? string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 58aa570dbe0761f43b25ff6c2265bbe2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue