split weaver test files by test class

This commit is contained in:
Paul Pacheco 2020-04-15 12:14:25 -05:00
parent 2b1aefab39
commit 93f7028e0d
91 changed files with 10 additions and 8 deletions

View File

@ -20,10 +20,7 @@ public static string OutputDirectory
if (guidsFound.Length == 1 && !string.IsNullOrEmpty(guidsFound[0])) if (guidsFound.Length == 1 && !string.IsNullOrEmpty(guidsFound[0]))
{ {
string path = AssetDatabase.GUIDToAssetPath(guidsFound[0]); string path = AssetDatabase.GUIDToAssetPath(guidsFound[0]);
string dir = Path.GetDirectoryName(path); return Path.GetDirectoryName(path);
// Path in mirror project
//"Assets/Mirror/Tests/Editor/WeaverTests~/";
_outputDirectory = Path.Combine(dir, "WeaverTests~/");
} }
else else
{ {

View File

@ -1,4 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using UnityEngine; using UnityEngine;
@ -9,7 +11,9 @@ public abstract class WeaverTestsBuildFromTestName : WeaverTests
[SetUp] [SetUp]
public void TestSetup() public void TestSetup()
{ {
BuildAndWeaveTestAssembly(TestContext.CurrentContext.Test.Name); string className = TestContext.CurrentContext.Test.ClassName.Split('.').Last();
BuildAndWeaveTestAssembly(className, TestContext.CurrentContext.Test.Name);
} }
} }
[TestFixture] [TestFixture]
@ -32,10 +36,11 @@ void HandleWeaverWarning(string msg)
weaverWarnings.Add(msg); weaverWarnings.Add(msg);
} }
protected void BuildAndWeaveTestAssembly(string baseName) protected void BuildAndWeaveTestAssembly(string className, string testName)
{ {
WeaverAssembler.OutputFile = baseName + ".dll"; string testSourceDirectory = className + "~";
WeaverAssembler.AddSourceFiles(new string[] { baseName + ".cs" }); WeaverAssembler.OutputFile = Path.Combine(testSourceDirectory, testName + ".dll");
WeaverAssembler.AddSourceFiles(new string[] { Path.Combine(testSourceDirectory, testName + ".cs") });
WeaverAssembler.Build(); WeaverAssembler.Build();
Assert.That(WeaverAssembler.CompilerErrors, Is.False); Assert.That(WeaverAssembler.CompilerErrors, Is.False);