Rhythm Selection & Cleanup
ci / checks (push) Successful in 1h16m10s

This commit is contained in:
khodowany
2026-09-26 02:50:22 -05:00
parent 4d6348d354
commit 9fd5abd075
91 changed files with 4692 additions and 2484 deletions
+33 -5
View File
@@ -165,11 +165,16 @@ auto checksum(std::string const &bytes) -> std::string {
return result;
}
auto write_score(std::filesystem::path const &path, std::string part = "Lead") -> void {
auto write_score(std::filesystem::path const &path, std::filesystem::path const &assets, std::string part = "Lead") -> void {
auto score = boost::json::parse(R"({"music":{"metadata":{"title":"Fixture","composer":"Composer",
"key_signature":"C","time_signature":"4/4"},"staves":[{"name":"Lead","measures":[{"voices":[]}]}]},
"presentation":{"width":976,"height":484,"pages":[]}})");
score.at("music").at("staves").as_array().front().as_object()["name"] = part;
auto title = std::string{"VPTI\x28\x01\x40\x00", 8U};
title.resize(vamp_protocol::title_image_size, std::char_t{0x11});
auto title_image = checksum(title);
write_file(assets / "pico" / "titles" / (title_image + ".mask"), title);
score.at("presentation").as_object()["title_image"] = title_image;
auto &pages = score.at("presentation").at("pages").as_array();
for (auto index = std::uint32_t{1}; index <= 2U; ++index) {
auto relative = path.stem().string() + ".pages/" + std::to_string(index) + ".png";
@@ -182,12 +187,12 @@ auto write_score(std::filesystem::path const &path, std::string part = "Lead") -
auto make_assets(vamp_zero::config const &config) -> void {
auto root = std::filesystem::path{config.runtime.assets_path};
write_score(root / "songs" / "first.json");
write_score(root / "songs" / "second.json");
write_score(root / "songs" / "first.json", root);
write_score(root / "songs" / "second.json", root);
for (auto part_name : vamp_zero::practice_part_names()) {
auto name = std::string{part_name};
name.front() = static_cast<std::char_t>(name.front() - 'A' + 'a');
write_score(root / "practice" / "0001" / (name + ".json"), std::string{part_name});
write_score(root / "practice" / "0001" / (name + ".json"), root, std::string{part_name});
}
BOOST_REQUIRE(vamp_test::build_catalog(root, config.database.path));
}
@@ -387,6 +392,29 @@ BOOST_AUTO_TEST_CASE(readiness_validates_later_pages_and_parts) {
}
}
BOOST_AUTO_TEST_CASE(readiness_rejects_missing_or_corrupted_pico_titles) {
for (auto corrupt : {false, true}) {
auto root = temporary_directory{};
auto config = fixture_config(root.path);
make_assets(config);
auto titles = std::filesystem::path{config.runtime.assets_path} / "pico" / "titles";
auto path = std::filesystem::directory_iterator {
titles
} -> path();
if (corrupt) {
auto bytes = read_file(path);
bytes.back() ^= 1;
write_file(path, bytes);
} else {
std::filesystem::remove(path);
}
auto ready = run_once(root.path, config);
BOOST_REQUIRE(!ready);
BOOST_TEST(std::string{ready.error().message()}.find("Pico title") != std::string::npos);
require_no_probe(config);
}
}
BOOST_AUTO_TEST_CASE(readiness_validates_generated_audio_using_configured_asset_root) {
auto root = temporary_directory{};
auto config = fixture_config(root.path);
@@ -395,7 +423,7 @@ BOOST_AUTO_TEST_CASE(readiness_validates_generated_audio_using_configured_asset_
auto fixture = std::filesystem::path{VAMP_TEST_PLAYBACK_ASSETS_DIR};
std::filesystem::copy(fixture / "audio", assets / "audio", std::filesystem::copy_options::recursive);
auto path = assets / "practice/0001/acoustic.json";
write_score(path, "Acoustic");
write_score(path, assets, "Acoustic");
auto score = boost::json::parse(read_file(path));
score.as_object()["playback"] = boost::json::parse(read_file(fixture / "score.json")).at("playback");
write_file(path, boost::json::serialize(score));