|
| 1 | +using FluentAssertions; |
| 2 | +using System.Collections.Generic; |
| 3 | +using Xunit; |
| 4 | + |
| 5 | +namespace UnityBuildRunner.Core.Tests; |
| 6 | + |
| 7 | +public class DefaultStrictErrorFilterTest |
| 8 | +{ |
| 9 | + [Theory] |
| 10 | + [InlineData( |
| 11 | + "-----CompilerOutput:-stdout--exitcode: 1--compilationhadfailure: True--outfile: Temp/Assembly-CSharp.dll", |
| 12 | + "DisplayProgressNotification: Build Failed", |
| 13 | + "Error building Player because scripts had compiler errors", |
| 14 | + @"2018-11-05T00:53:44.2566426Z DisplayProgressNotification: Build Failed |
| 15 | + Error building Player because scripts had compiler errors |
| 16 | + (Filename: Line: -1) |
| 17 | + Unloading 64 Unused Serialized files (Serialized files now loaded: 0) |
| 18 | + System memory in use before: 63.0 MB. |
| 19 | + System memory in use after: 63.4 MB. |
| 20 | +
|
| 21 | + Unloading 47 unused Assets to reduce memory usage. Loaded Objects now: 5728. |
| 22 | + Total: 13.359500 ms (FindLiveObjects: 1.689200 ms CreateObjectMapping: 0.289900 ms MarkObjects: 11.349100 ms DeleteObjects: 0.029600 ms)", |
| 23 | + "Compilation failed: 634 error(s), 0 warnings", |
| 24 | + "Assets/Externals/Plugins/Zenject/Source/Binding/Binders/NonLazyBinder.cs(10,16): error CS0246: The type or namespace name `IfNotBoundBinder' could not be found. Are you missing an assembly reference?", |
| 25 | + @"BatchMode: Unity has not been activated with a valid License. Could be a new activation or renewal... |
| 26 | + DisplayProgressbar: Unity license")] |
| 27 | + public void DetectCSharpCompileError(params string[] inputs) |
| 28 | + { |
| 29 | + IErrorFilter errorFilter = new DefaultStrictErrorFilter(); |
| 30 | + var results = new List<string>(); |
| 31 | + foreach (var input in inputs) |
| 32 | + { |
| 33 | + errorFilter.Filter(input, result => results.Add(result.MatchPattern)); |
| 34 | + } |
| 35 | + |
| 36 | + results.Should().NotBeEmpty(); |
| 37 | + } |
| 38 | + |
| 39 | + [Theory] |
| 40 | + [InlineData("Multiple Unity instances cannot open the same project.")] |
| 41 | + [InlineData("Unity has not been activated")] |
| 42 | + public void DetectUnityError(params string[] inputs) |
| 43 | + { |
| 44 | + IErrorFilter errorFilter = new DefaultStrictErrorFilter(); |
| 45 | + var results = new List<string>(); |
| 46 | + foreach (var input in inputs) |
| 47 | + { |
| 48 | + errorFilter.Filter(input, result => results.Add(result.MatchPattern)); |
| 49 | + } |
| 50 | + results.Should().NotBeEmpty(); |
| 51 | + } |
| 52 | + |
| 53 | + [Theory] |
| 54 | + [InlineData( |
| 55 | + "Compiling shader \"Shader Graphs/UrpFoo\" pass \"\" (vp)", |
| 56 | + " Full variant space: 2", |
| 57 | + " After settings filtering: 2", |
| 58 | + " After built-in stripping: 2", |
| 59 | + " After scriptable stripping: 2", |
| 60 | + " Processed in 0.02 seconds", |
| 61 | + " starting compilation...", |
| 62 | + " finished in 0.22 seconds. Local cache hits 0 (0.00s CPU time), remote cache hits 0 (0.00s CPU time), compiled 2 variants (0.42s CPU time), skipped 0 variants", |
| 63 | + " Prepared data for serialisation in 0.00s", |
| 64 | + "Serialized binary data for shader Shader Graphs/UrpTriplanar in 0.00s", |
| 65 | + " glcore (total internal programs: 21, unique: 21)", |
| 66 | + " vulkan (total internal programs: 34, unique: 34)", |
| 67 | + "Shader error in 'Shader Graphs/UrpFoo': Compilation failed (other error) 'out of memory during compilation")] |
| 68 | + public void SkipShaderError(params string[] inputs) |
| 69 | + { |
| 70 | + IErrorFilter errorFilter = new DefaultStrictErrorFilter(); |
| 71 | + var results = new List<string>(); |
| 72 | + foreach (var input in inputs) |
| 73 | + { |
| 74 | + errorFilter.Filter(input, result => results.Add(result.MatchPattern)); |
| 75 | + } |
| 76 | + results.Should().NotBeEmpty(); |
| 77 | + } |
| 78 | + |
| 79 | + [Theory] |
| 80 | + [InlineData( |
| 81 | + "Unloading 64 Unused Serialized files (Serialized files now loaded: 0)", |
| 82 | + "System memory in use before: 63.0 MB.", "DisplayProgressbar: Unity Package Manager")] |
| 83 | + public void SkipNormalMessage(params string[] inputs) |
| 84 | + { |
| 85 | + IErrorFilter errorFilter = new DefaultStrictErrorFilter(); |
| 86 | + var results = new List<string>(); |
| 87 | + foreach (var input in inputs) |
| 88 | + { |
| 89 | + errorFilter.Filter(input, result => results.Add(result.MatchPattern)); |
| 90 | + } |
| 91 | + results.Should().BeEmpty(); |
| 92 | + } |
| 93 | +} |
0 commit comments