fix: keep external audio discovery diagnostic only

This commit is contained in:
goose
2026-10-01 09:12:16 -04:00
parent 4e356ee7b8
commit c750399128
5 changed files with 84 additions and 126 deletions
+20 -25
View File
@@ -12,6 +12,8 @@ func test_missing_audio_directories_are_silent_for_known_requests() -> void:
assert_eq(library.current_ambience_context, "exploration")
assert_eq(library.get_last_ambience_path(), "")
assert_eq(library.get_last_sfx_path(), "")
assert_false(library.has_playable_ambience())
assert_false(library.has_playable_sfx())
func test_unknown_requests_are_silent() -> void:
var library := AudioLibrary.new("res://tests/fixtures/missing-dcwascii")
@@ -24,11 +26,22 @@ func test_unknown_requests_are_silent() -> void:
assert_eq(library.current_ambience_context, "exploration")
assert_eq(library.get_last_ambience_path(), "")
assert_eq(library.get_last_sfx_path(), "")
assert_false(library.has_playable_ambience())
assert_false(library.has_playable_sfx())
func test_invalid_wav_is_not_selected_or_played_and_does_not_block_requests() -> void:
var root := ProjectSettings.globalize_path("user://s4-invalid-audio-library")
var invalid_path := root.path_join("audio/exploration/not-a-wave.wav")
func test_nominal_and_invalid_wavs_are_discovered_but_never_playable() -> void:
var root := ProjectSettings.globalize_path("user://s4-external-audio-library")
var nominal_path := root.path_join("audio/exploration/silence.wav")
var invalid_path := root.path_join("sfx/attack_given/not-a-wave.wav")
DirAccess.make_dir_recursive_absolute(nominal_path.get_base_dir())
DirAccess.make_dir_recursive_absolute(invalid_path.get_base_dir())
var nominal_file := FileAccess.open(nominal_path, FileAccess.WRITE)
nominal_file.store_buffer(PackedByteArray([
82, 73, 70, 70, 36, 0, 0, 0, 87, 65, 86, 69, 102, 109, 116, 32,
16, 0, 0, 0, 1, 0, 1, 0, 68, 172, 0, 0, 136, 88, 1, 0,
2, 0, 16, 0, 100, 97, 116, 97, 0, 0, 0, 0,
]))
nominal_file.close()
var invalid_file := FileAccess.open(invalid_path, FileAccess.WRITE)
invalid_file.store_string("this is not a WAV file")
invalid_file.close()
@@ -38,25 +51,7 @@ func test_invalid_wav_is_not_selected_or_played_and_does_not_block_requests() ->
library.set_ambience_context("exploration")
library.play_sfx("attack_given")
assert_eq(library.get_last_ambience_path(), "")
assert_eq(library.get_last_sfx_path(), "")
assert_false(library._ambience_player.playing)
assert_false(library._sfx_player.playing)
func test_admitted_wav_file_is_discovered() -> void:
var root := ProjectSettings.globalize_path("user://s4-audio-library")
var sample_path := root.path_join("audio/exploration/silence.wav")
DirAccess.make_dir_recursive_absolute(sample_path.get_base_dir())
var sample := FileAccess.open(sample_path, FileAccess.WRITE)
sample.store_buffer(PackedByteArray([
82, 73, 70, 70, 36, 0, 0, 0, 87, 65, 86, 69, 102, 109, 116, 32,
16, 0, 0, 0, 1, 0, 1, 0, 68, 172, 0, 0, 136, 88, 1, 0,
2, 0, 16, 0, 100, 97, 116, 97, 0, 0, 0, 0,
]))
sample.close()
var library := AudioLibrary.new(root)
add_child_autofree(library)
library.set_ambience_context("exploration")
assert_eq(library.get_last_ambience_path(), sample_path)
assert_eq(library.get_last_ambience_path(), nominal_path)
assert_eq(library.get_last_sfx_path(), invalid_path)
assert_false(library.has_playable_ambience())
assert_false(library.has_playable_sfx())