GDScript: Group similar analyzer/runtime error tests into single files
This commit is contained in:
@@ -575,8 +575,20 @@ GDScriptTest::TestResult GDScriptTest::execute_test_code(bool p_is_generating) {
|
||||
result.status = GDTEST_ANALYZER_ERROR;
|
||||
result.output = get_text_for_status(result.status) + "\n";
|
||||
|
||||
// Errors are stored in the order they were added, which may not match the source code.
|
||||
// Here we sort only by lines, preserving the original order for columns.
|
||||
// So, within a single line, the primary error is printed first, not cascading ones.
|
||||
struct SortErrors {
|
||||
_FORCE_INLINE_ bool operator()(const GDScriptParser::ParserError &p_a, const GDScriptParser::ParserError &p_b) const {
|
||||
return p_a.start_line < p_b.start_line;
|
||||
}
|
||||
};
|
||||
|
||||
List<GDScriptParser::ParserError> errors = List<GDScriptParser::ParserError>(parser.get_errors());
|
||||
errors.sort_custom<SortErrors>();
|
||||
|
||||
StringBuilder error_string;
|
||||
for (const GDScriptParser::ParserError &error : parser.get_errors()) {
|
||||
for (const GDScriptParser::ParserError &error : errors) {
|
||||
error_string.append(vformat(">> ERROR at line %d: %s\n", error.start_line, error.message));
|
||||
}
|
||||
result.output += error_string.as_string();
|
||||
|
||||
Reference in New Issue
Block a user