Replace the broken test suite with working GdUnit4 tests

The previous tests never compiled: they used GUT's assert functions,
Godot 3 APIs and reassigned autoload functions, so no test ran.

- 90 tests: unit tests for the playlist, songs, player scoring, time
  formatting, search and the server client, plus integration tests
  that run MainWindow and SyncWindow against a fake server
- Keybind tests check that Alt+<number> and Ctrl+Alt+<number> keep
  following the player rows while players are added and removed
- run_tests.sh finds Godot and runs the suite headless (~10 seconds)
- CI runs the tests before the build job in gitea-build.yaml; the
  separate test.yml used a GitHub action that does not exist
- GdUnit4 is committed instead of ignored, since the project enables
  it, and .gitea/ is no longer ignored
- Exported builds leave out tests/ and addons/gdUnit4/
This commit is contained in:
Sansan committed 2026-10-06 08:32:56 +02:00
1 parent 56e9fe66d3
commit c985a6ce5b
559 files changed
+32474 -2100

No files matched your search

+68
View File
@@ -0,0 +1,68 @@
extends GdUnitTestSuite
var _music_player: MusicPlayer
var _hide_beginning: bool
var _hide_length: bool
var _hide_for_seconds: float
func before_test() -> void:
_music_player = auto_free(MusicPlayer.new())
_hide_beginning = Settings.hide_beginning
_hide_length = Settings.hide_length
_hide_for_seconds = Settings.hide_for_seconds
Settings.hide_beginning = false
Settings.hide_length = false
Settings.hide_for_seconds = 5.0
func after_test() -> void:
Settings.hide_beginning = _hide_beginning
Settings.hide_length = _hide_length
Settings.hide_for_seconds = _hide_for_seconds
func test_format_time() -> void:
assert_str(_music_player.format_time(0.0)).is_equal("00:00")
assert_str(_music_player.format_time(65.0)).is_equal("01:05")
assert_str(_music_player.format_time(3661.0)).is_equal("61:01")
func test_format_time_rounds_up_into_next_minute() -> void:
assert_str(_music_player.format_time(59.6)).is_equal("01:00")
func test_format_text_shows_position_and_length() -> void:
assert_str(_music_player.format_text(10.0, 100.0)).is_equal("00:10 / 01:40")
func test_format_text_hides_length() -> void:
Settings.hide_length = true
assert_str(_music_player.format_text(10.0, 100.0)).is_equal("00:10 / ??:??")
func test_format_text_hides_position_at_start() -> void:
Settings.hide_beginning = true
assert_str(_music_player.format_text(3.0, 100.0)).is_equal("??:?? / 01:40")
func test_format_text_shows_position_after_hidden_start() -> void:
Settings.hide_beginning = true
assert_str(_music_player.format_text(5.0, 100.0)).is_equal("00:05 / 01:40")
func test_format_text_hides_everything_at_start() -> void:
Settings.hide_beginning = true
Settings.hide_length = true
assert_str(_music_player.format_text(3.0, 100.0)).is_equal("??:?? / ??:??")
func test_format_text_keeps_length_hidden_after_hidden_start() -> void:
Settings.hide_beginning = true
Settings.hide_length = true
assert_str(_music_player.format_text(5.0, 100.0)).is_equal("00:05 / ??:??")