|
26 | 26 | using Akka.Persistence.Sql.Common.Journal;
|
27 | 27 | using ApprovalTests.Core;
|
28 | 28 | using ApprovalTests.Reporters;
|
| 29 | +using ApprovalTests.Reporters.Mac; |
| 30 | +using ApprovalUtilities.Utilities; |
29 | 31 | using DiffPlex;
|
30 | 32 | using DiffPlex.DiffBuilder;
|
31 | 33 | using DiffPlex.DiffBuilder.Model;
|
32 |
| -using Xunit.Abstractions; |
33 | 34 | using Xunit.Sdk;
|
| 35 | +using P4MergeReporter = ApprovalTests.Reporters.P4MergeReporter; |
| 36 | +using P4MacMergeReporter = ApprovalTests.Reporters.Mac.P4MergeReporter; |
34 | 37 |
|
35 | 38 | namespace Akka.API.Tests
|
36 | 39 | {
|
37 | 40 | #if(DEBUG)
|
38 |
| - [UseReporter(typeof(DiffPlexReporter), typeof(DiffReporter), typeof(AllFailingTestsClipboardReporter))] |
| 41 | + [UseReporter(typeof(DiffPlexReporter), typeof(CustomDiffReporter), typeof(AllFailingTestsClipboardReporter))] |
39 | 42 | #else
|
40 |
| - [UseReporter(typeof(DiffPlexReporter))] |
| 43 | + [UseReporter(typeof(DiffPlexReporter), typeof(CustomDiffReporter))] |
41 | 44 | #endif
|
42 | 45 | public class CoreAPISpec
|
43 | 46 | {
|
@@ -173,6 +176,64 @@ public ApiNotApprovedException(string message) : base($"Failed API approval. Dif
|
173 | 176 | public override string StackTrace { get; } = string.Empty;
|
174 | 177 | }
|
175 | 178 |
|
| 179 | + #region Suppress FrameworkAssertReporter hack |
| 180 | + // The built-in FrameworkAssertReporter that is being called inside the DiffReporter class |
| 181 | + // is buggy in a CI/CD environment because it is trying to be clever, could not distinguish |
| 182 | + // between XUnit and XUnit2, and will throw Null Reference Exception every time it ran. |
| 183 | + // |
| 184 | + // This is probably fixed in latest version of ApiApprover but we couldn't switch to that |
| 185 | + // version because the latest ApiGenerator returns a different API report format. |
| 186 | + // |
| 187 | + // FIX: This hack removes FrameworkAssertReporter from the possible reporter list and retains |
| 188 | + // all of the other reporters in DiffReporter |
| 189 | + |
| 190 | + internal class CustomDiffReporter : FirstWorkingReporter |
| 191 | + { |
| 192 | + public CustomDiffReporter() : base( |
| 193 | + CustomWindowsDiffReporter.Instance, |
| 194 | + CustomMacDiffReporter.Instance) |
| 195 | + { } |
| 196 | + } |
| 197 | + |
| 198 | + internal class CustomMacDiffReporter : FirstWorkingReporter |
| 199 | + { |
| 200 | + public static readonly CustomMacDiffReporter Instance = new CustomMacDiffReporter(); |
| 201 | + public CustomMacDiffReporter() |
| 202 | + : base( |
| 203 | + |
| 204 | + BeyondCompareMacReporter.INSTANCE, |
| 205 | + DiffMergeReporter.INSTANCE, |
| 206 | + KaleidoscopeDiffReporter.INSTANCE, |
| 207 | + P4MacMergeReporter.INSTANCE, |
| 208 | + KDiff3Reporter.INSTANCE, |
| 209 | + TkDiffReporter.INSTANCE, |
| 210 | + QuietReporter.INSTANCE) |
| 211 | + { } |
| 212 | + |
| 213 | + public override bool IsWorkingInThisEnvironment(string forFile) => OsUtils.IsUnixOs() && base.IsWorkingInThisEnvironment(forFile); |
| 214 | + } |
| 215 | + |
| 216 | + internal class CustomWindowsDiffReporter : FirstWorkingReporter |
| 217 | + { |
| 218 | + public static readonly CustomWindowsDiffReporter Instance = new CustomWindowsDiffReporter(); |
| 219 | + public CustomWindowsDiffReporter() |
| 220 | + : base( |
| 221 | + CodeCompareReporter.INSTANCE, |
| 222 | + BeyondCompareReporter.INSTANCE, |
| 223 | + TortoiseDiffReporter.INSTANCE, |
| 224 | + AraxisMergeReporter.INSTANCE, |
| 225 | + P4MergeReporter.INSTANCE, |
| 226 | + WinMergeReporter.INSTANCE, |
| 227 | + KDiffReporter.INSTANCE, |
| 228 | + VisualStudioReporter.INSTANCE, |
| 229 | + QuietReporter.INSTANCE) |
| 230 | + { } |
| 231 | + |
| 232 | + public override bool IsWorkingInThisEnvironment(string forFile) => OsUtils.IsWindowsOs() && base.IsWorkingInThisEnvironment(forFile); |
| 233 | + } |
| 234 | + |
| 235 | + #endregion |
| 236 | + |
176 | 237 | internal class DiffPlexReporter : IApprovalFailureReporter
|
177 | 238 | {
|
178 | 239 | public void Report(string approved, string received)
|
|
0 commit comments