use WeaverTests error handling functions

This commit is contained in:
vis2k 2021-08-28 18:12:27 +08:00
parent eb592eb0e1
commit 523a6c944d
2 changed files with 5 additions and 4 deletions

View File

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -92,7 +93,7 @@ public static void Clear()
DeleteOutputOnClear = false; DeleteOutputOnClear = false;
} }
public static void Build() public static void Build(Action<string> OnWarning, Action<string> OnError)
{ {
AssemblyBuilder assemblyBuilder = new AssemblyBuilder(Path.Combine(OutputDirectory, OutputFile), SourceFiles.ToArray()) AssemblyBuilder assemblyBuilder = new AssemblyBuilder(Path.Combine(OutputDirectory, OutputFile), SourceFiles.ToArray())
{ {
@ -154,11 +155,11 @@ public static void Build()
{ {
if (message.DiagnosticType == DiagnosticType.Warning) if (message.DiagnosticType == DiagnosticType.Warning)
{ {
Debug.LogWarning(message.MessageData); OnWarning(message.MessageData);
} }
else if (message.DiagnosticType == DiagnosticType.Error) else if (message.DiagnosticType == DiagnosticType.Error)
{ {
Debug.LogError(message.MessageData); OnError(message.MessageData);
} }
} }
// TODO need to feed them to weaverWarnings/weaverErrors // TODO need to feed them to weaverWarnings/weaverErrors

View File

@ -32,7 +32,7 @@ protected void BuildAndWeaveTestAssembly(string className, string testName)
string testSourceDirectory = className + "~"; string testSourceDirectory = className + "~";
WeaverAssembler.OutputFile = Path.Combine(testSourceDirectory, testName + ".dll"); WeaverAssembler.OutputFile = Path.Combine(testSourceDirectory, testName + ".dll");
WeaverAssembler.AddSourceFiles(new string[] { Path.Combine(testSourceDirectory, testName + ".cs") }); WeaverAssembler.AddSourceFiles(new string[] { Path.Combine(testSourceDirectory, testName + ".cs") });
WeaverAssembler.Build(); WeaverAssembler.Build(HandleWeaverWarning, HandleWeaverError);
Assert.That(WeaverAssembler.CompilerErrors, Is.False); Assert.That(WeaverAssembler.CompilerErrors, Is.False);
foreach (string error in weaverErrors) foreach (string error in weaverErrors)