Tests: Compare IDAPython and C++ scaffolding files as well as C# stubs in TestRunner

This commit is contained in:
Katy Coe
2020-07-06 20:07:43 +02:00
parent a37bc05db1
commit 9fff9678aa

View File

@@ -1,5 +1,5 @@
/*
Copyright 2019-2020 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com
Copyright 2019-2020 Katy Coe - http://www.djkaty.com - https://github.com/djkaty
All rights reserved.
*/
@@ -60,10 +60,20 @@ namespace Il2CppInspector
.WriteCppToFile(testPath + $@"\test-result{nameSuffix}.h");
}
// Compare test result with expected result
// Compare test results with expected results
for (i = 0; i < inspectors.Count; i++) {
var expected = File.ReadAllLines(testPath + @"\..\..\TestExpectedResults\" + Path.GetFileName(testPath) + (i > 0 ? "-" + i : "") + ".cs");
var actual = File.ReadAllLines(testPath + @"\test-result" + (i > 0 ? "-" + i : "") + ".cs");
var suffix = (i > 0 ? "-" + i : "");
compareFiles(testPath, suffix + ".cs", $"test-result{suffix}.cs");
compareFiles(testPath, suffix + ".py", $"test-ida-result{suffix}.py");
compareFiles(testPath, suffix + ".h", $"test-result{suffix}.h");
}
}
// We have to pass testPath rather than storing it as a field so that tests can be parallelized
private void compareFiles(string testPath, string expectedFilenameSuffix, string actualFilename) {
var expected = File.ReadAllLines(testPath + @"\..\..\TestExpectedResults\" + Path.GetFileName(testPath) + expectedFilenameSuffix);
var actual = File.ReadAllLines(testPath + @"\" + actualFilename);
// Get rid of blank lines and trim the remaining lines
expected = (from l in expected where !string.IsNullOrWhiteSpace(l) select l.Trim()).ToArray();
@@ -73,4 +83,3 @@ namespace Il2CppInspector
}
}
}
}