From d2a30c01cd2fdc0497c7ad4b6a9b5f47bb7ebd2a Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Mon, 12 Apr 2021 20:40:11 +0200 Subject: [PATCH] Tests: Ignore single-line comments in source code diffs --- Il2CppTests/TestRunner.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Il2CppTests/TestRunner.cs b/Il2CppTests/TestRunner.cs index 2753210..2206cad 100644 --- a/Il2CppTests/TestRunner.cs +++ b/Il2CppTests/TestRunner.cs @@ -236,6 +236,10 @@ namespace Il2CppInspector var expected = File.ReadAllLines(expectedPath); var actual = File.ReadAllLines(testPath + @"\" + actualFilename); + // Ignore single-line comments in source code files + var ext = Path.GetExtension(expectedPath).ToLower(); + var excludeComments = ext == ".cs" || ext == ".cpp" || ext == ".h"; + var extraInExpected = expected.Except(actual); var extraInActual = actual.Except(expected); @@ -248,9 +252,9 @@ namespace Il2CppInspector // We don't use Linq to strip whitespace lines or CollectionAssert to compare, // as we want to be able to determine the exact line number of the first mismatch for (int expLine = 0, actLine = 0; expLine < expected.Length || actLine < actual.Length; expLine++, actLine++) { - while (expLine < expected.Length && string.IsNullOrWhiteSpace(expected[expLine])) + while (expLine < expected.Length && (string.IsNullOrWhiteSpace(expected[expLine]) || (excludeComments && expected[expLine].StartsWith("//")))) expLine++; - while (actLine < actual.Length && string.IsNullOrWhiteSpace(actual[actLine])) + while (actLine < actual.Length && (string.IsNullOrWhiteSpace(actual[actLine]) || (excludeComments && actual[actLine].StartsWith("//")))) actLine++; if (expLine < expected.Length && actLine < actual.Length)