GDScript: Only include script file path in test error output

Errors originating in C++ files cause unnecessary diffs whenever the engine is updated
(line number changes, etc.) and would cause CI failures due to different formatting
of the file path on Windows (backslashes, worked around here anyway) and when using
SCU builds (`../scu` insert).
This commit is contained in:
Rémi Verschelde 2023-06-14 10:53:37 +02:00
parent 0aad5eb1cf
commit c40adf027d
No known key found for this signature in database
GPG Key ID: C3336907360768E1
2 changed files with 10 additions and 6 deletions

View File

@ -392,6 +392,9 @@ void GDScriptTest::error_handler(void *p_this, const char *p_function, const cha
StringBuilder builder; StringBuilder builder;
builder.append(">> "); builder.append(">> ");
// Only include the file path and line for script errors, otherwise the test
// outputs include arbitrary data which can change when we edit engine code.
bool include_path = false;
switch (p_type) { switch (p_type) {
case ERR_HANDLER_ERROR: case ERR_HANDLER_ERROR:
builder.append("ERROR"); builder.append("ERROR");
@ -401,6 +404,7 @@ void GDScriptTest::error_handler(void *p_this, const char *p_function, const cha
break; break;
case ERR_HANDLER_SCRIPT: case ERR_HANDLER_SCRIPT:
builder.append("SCRIPT ERROR"); builder.append("SCRIPT ERROR");
include_path = true;
break; break;
case ERR_HANDLER_SHADER: case ERR_HANDLER_SHADER:
builder.append("SHADER ERROR"); builder.append("SHADER ERROR");
@ -413,10 +417,12 @@ void GDScriptTest::error_handler(void *p_this, const char *p_function, const cha
builder.append("\n>> on function: "); builder.append("\n>> on function: ");
builder.append(String::utf8(p_function)); builder.append(String::utf8(p_function));
builder.append("()\n>> "); builder.append("()\n>> ");
builder.append(String::utf8(p_file).trim_prefix(self->base_dir)); if (include_path) {
builder.append(String::utf8(p_file).trim_prefix(self->base_dir).replace("\\", "/"));
builder.append("\n>> "); builder.append("\n>> ");
builder.append(itos(p_line)); builder.append(itos(p_line));
builder.append("\n>> "); builder.append("\n>> ");
}
builder.append(String::utf8(p_error)); builder.append(String::utf8(p_error));
if (strlen(p_explanation) > 0) { if (strlen(p_explanation) > 0) {
builder.append("\n>> "); builder.append("\n>> ");

View File

@ -1,7 +1,5 @@
GDTEST_RUNTIME_ERROR GDTEST_RUNTIME_ERROR
>> ERROR >> ERROR
>> on function: assign() >> on function: assign()
>> core/variant/array.cpp
>> 222
>> Method/function failed. >> Method/function failed.
not ok not ok