Skip to content

Commit

Permalink
Test only errors themselves in MML compilation tests
Browse files Browse the repository at this point in the history
The line with the error message is universal, but
what follows is platform dependent. We could
replace these strings somehow to work on all
platforms, but they don't really hold any crucial
information, so it's easier to just drop them.
  • Loading branch information
YuriSizov committed Nov 11, 2024
1 parent c3d3587 commit 490c5f3
Show file tree
Hide file tree
Showing 31 changed files with 17 additions and 267 deletions.
11 changes: 11 additions & 0 deletions tests/TestBase.gd
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,14 @@ func _run_subscript(path: String, arguments: PackedStringArray) -> String:

# Normalize the EOL sequences.
return output[0].replace("\r", "")


func _extract_godot_errors(buffer: String) -> String:
var errors := ""
var lines := buffer.split("\n", false)

for line in lines:
if line.begins_with("ERROR: "):
errors += line + "\n"

return errors
9 changes: 6 additions & 3 deletions tests/run/mml-compilation.gd
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ func run(scene_tree: SceneTree) -> void:
var output_path := OUTPUTS_PATH.path_join("%d.txt" % [ tune_hash ])

# This is painfully slow, but allows us to read the errors and match them against the expected result.
var errors := _run_subscript("./run/mml-compilation/compile-mml-song.gd", [ tune_item.mml_string ])
var received := _run_subscript("./run/mml-compilation/compile-mml-song.gd", [ tune_item.mml_string ])
received = _extract_godot_errors(received)
var expected := _load_tune_output(output_path)
var errors_match := (errors == expected)
expected = _extract_godot_errors(expected)

var errors_match := (received == expected)

if expected.is_empty():
_assert_equal("compiled w/o errors: %s - %s" % [ tune_item.title, tune_item.author ], errors_match, true)
Expand All @@ -49,7 +52,7 @@ func run(scene_tree: SceneTree) -> void:
_append_extra_to_output("Expected:")
_append_extra_to_output(expected)
_append_extra_to_output("Got:")
_append_extra_to_output(errors)
_append_extra_to_output(received)

# Cleanup.

Expand Down
8 changes: 0 additions & 8 deletions tests/run/mml-compilation/outputs/1070131212.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
ERROR: Translator: Parameter 'DR' value (44) is outside of valid range (0 : 15). Value will be looped.
at: TranslatorUtil::_sanitize_param_loop (src\utils\translator_util.cpp:66)
ERROR: Translator: Parameter 'SR' value (44) is outside of valid range (0 : 15). Value will be looped.
at: TranslatorUtil::_sanitize_param_loop (src\utils\translator_util.cpp:66)
ERROR: Translator: Parameter 'RR' value (66) is outside of valid range (0 : 15). Value will be looped.
at: TranslatorUtil::_sanitize_param_loop (src\utils\translator_util.cpp:66)
ERROR: Translator: Parameter 'SL' value (66) is outside of valid range (0 : 15). Value will be looped.
at: TranslatorUtil::_sanitize_param_loop (src\utils\translator_util.cpp:66)
ERROR: Translator: Parameter 'RR' value (33) is outside of valid range (0 : 15). Value will be looped.
at: TranslatorUtil::_sanitize_param_loop (src\utils\translator_util.cpp:66)
ERROR: Translator: Parameter 'FB' value (8) is outside of valid range (0 : 7). Value will be looped.
at: TranslatorUtil::_sanitize_param_loop (src\utils\translator_util.cpp:66)
ERROR: Translator: Parameter 'FB' value (8) is outside of valid range (0 : 7). Value will be looped.
at: TranslatorUtil::_sanitize_param_loop (src\utils\translator_util.cpp:66)
ERROR: Translator: Parameter 'FB' value (8) is outside of valid range (0 : 7). Value will be looped.
at: TranslatorUtil::_sanitize_param_loop (src\utils\translator_util.cpp:66)
3 changes: 0 additions & 3 deletions tests/run/mml-compilation/outputs/1152739234.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
ERROR: Translator: Parameter 'RR' value (27) is outside of valid range (0 : 15). Value will be looped.
at: TranslatorUtil::_sanitize_param_loop (src\utils\translator_util.cpp:66)
ERROR: Translator: Parameter 'RR' value (27) is outside of valid range (0 : 15). Value will be looped.
at: TranslatorUtil::_sanitize_param_loop (src\utils\translator_util.cpp:66)
ERROR: Translator: Parameter 'RR' value (27) is outside of valid range (0 : 15). Value will be looped.
at: TranslatorUtil::_sanitize_param_loop (src\utils\translator_util.cpp:66)
2 changes: 0 additions & 2 deletions tests/run/mml-compilation/outputs/1177443911.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
ERROR: Translator: Parameter 'FB' value (8) is outside of valid range (0 : 7). Value will be looped.
at: TranslatorUtil::_sanitize_param_loop (src\utils\translator_util.cpp:66)
ERROR: Translator: Parameter 'FB' value (8) is outside of valid range (0 : 7). Value will be looped.
at: TranslatorUtil::_sanitize_param_loop (src\utils\translator_util.cpp:66)
1 change: 0 additions & 1 deletion tests/run/mml-compilation/outputs/1257090433.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
ERROR: Translator: Parameter 'D2' value (-1) is outside of valid range (0 : 3). Value will be looped.
at: TranslatorUtil::_sanitize_param_loop (src\utils\translator_util.cpp:66)
1 change: 0 additions & 1 deletion tests/run/mml-compilation/outputs/1742055971.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
ERROR: Translator: Parameter 'FB' value (15) is outside of valid range (0 : 7). Value will be looped.
at: TranslatorUtil::_sanitize_param_loop (src\utils\translator_util.cpp:66)
1 change: 0 additions & 1 deletion tests/run/mml-compilation/outputs/2024256035.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
ERROR: Translator: Parameter 'KL' value (8) is outside of valid range (0 : 3). Value will be looped.
at: TranslatorUtil::_sanitize_param_loop (src\utils\translator_util.cpp:66)
5 changes: 0 additions & 5 deletions tests/run/mml-compilation/outputs/2238985794.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
ERROR: Translator: Parameter 'FB' value (8) is outside of valid range (0 : 7). Value will be looped.
at: TranslatorUtil::_sanitize_param_loop (src\utils\translator_util.cpp:66)
ERROR: Translator: Parameter 'FB' value (8) is outside of valid range (0 : 7). Value will be looped.
at: TranslatorUtil::_sanitize_param_loop (src\utils\translator_util.cpp:66)
ERROR: Translator: Parameter 'FB' value (8) is outside of valid range (0 : 7). Value will be looped.
at: TranslatorUtil::_sanitize_param_loop (src\utils\translator_util.cpp:66)
ERROR: Translator: Parameter 'FB' value (8) is outside of valid range (0 : 7). Value will be looped.
at: TranslatorUtil::_sanitize_param_loop (src\utils\translator_util.cpp:66)
ERROR: Translator: Parameter 'FB' value (8) is outside of valid range (0 : 7). Value will be looped.
at: TranslatorUtil::_sanitize_param_loop (src\utils\translator_util.cpp:66)
1 change: 0 additions & 1 deletion tests/run/mml-compilation/outputs/2411669568.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
ERROR: Translator: Parameter 'FB' value (8) is outside of valid range (0 : 7). Value will be looped.
at: TranslatorUtil::_sanitize_param_loop (src\utils\translator_util.cpp:66)
2 changes: 0 additions & 2 deletions tests/run/mml-compilation/outputs/2642208711.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
ERROR: Translator: Parameter 'FB' value (8) is outside of valid range (0 : 7). Value will be looped.
at: TranslatorUtil::_sanitize_param_loop (src\utils\translator_util.cpp:66)
ERROR: Translator: Parameter 'FB' value (8) is outside of valid range (0 : 7). Value will be looped.
at: TranslatorUtil::_sanitize_param_loop (src\utils\translator_util.cpp:66)
Loading

0 comments on commit 490c5f3

Please sign in to comment.