Tests: Compare IDAPython and C++ scaffolding files as well as C# stubs in TestRunner
This commit is contained in:
@@ -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.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
@@ -60,17 +60,26 @@ namespace Il2CppInspector
|
|||||||
.WriteCppToFile(testPath + $@"\test-result{nameSuffix}.h");
|
.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++) {
|
for (i = 0; i < inspectors.Count; i++) {
|
||||||
var expected = File.ReadAllLines(testPath + @"\..\..\TestExpectedResults\" + Path.GetFileName(testPath) + (i > 0 ? "-" + i : "") + ".cs");
|
var suffix = (i > 0 ? "-" + i : "");
|
||||||
var actual = File.ReadAllLines(testPath + @"\test-result" + (i > 0 ? "-" + i : "") + ".cs");
|
|
||||||
|
|
||||||
// Get rid of blank lines and trim the remaining lines
|
compareFiles(testPath, suffix + ".cs", $"test-result{suffix}.cs");
|
||||||
expected = (from l in expected where !string.IsNullOrWhiteSpace(l) select l.Trim()).ToArray();
|
compareFiles(testPath, suffix + ".py", $"test-ida-result{suffix}.py");
|
||||||
actual = (from l in actual where !string.IsNullOrWhiteSpace(l) select l.Trim()).ToArray();
|
compareFiles(testPath, suffix + ".h", $"test-result{suffix}.h");
|
||||||
|
|
||||||
CollectionAssert.AreEqual(expected, actual);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
actual = (from l in actual where !string.IsNullOrWhiteSpace(l) select l.Trim()).ToArray();
|
||||||
|
|
||||||
|
CollectionAssert.AreEqual(expected, actual);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user