diff --git a/common/assets/src/lib.rs b/common/assets/src/lib.rs index 886670a11a..bed643fc77 100644 --- a/common/assets/src/lib.rs +++ b/common/assets/src/lib.rs @@ -96,7 +96,8 @@ pub fn load_dir( #[track_caller] pub fn load_expect_dir(specifier: &str, recursive: bool) -> AssetDirHandle { - load_dir(specifier, recursive).expect("Failed loading directory") + load_dir(specifier, recursive) + .unwrap_or_else(|e| panic!("Failed loading directory. error={:?}", e)) } impl AssetExt for T { diff --git a/common/src/comp/inventory/item/mod.rs b/common/src/comp/inventory/item/mod.rs index f8660a8918..0bbc8b4a6f 100644 --- a/common/src/comp/inventory/item/mod.rs +++ b/common/src/comp/inventory/item/mod.rs @@ -1020,105 +1020,9 @@ mod tests { #[test] fn test_assets_items() { - // TODO: Figure out how to get file name in error so only a single glob is - // needed - - // Separated out into subsections so that error more descriptive - Item::new_from_asset_glob("common.items.armor.*").expect("Failed to iterate over armors."); - - Item::new_from_asset_glob("common.items.boss_drops.*") - .expect("Failed to iterate over boss drops."); - - Item::new_from_asset_glob("common.items.consumable.*") - .expect("Failed to iterate over consumables."); - - Item::new_from_asset_glob("common.items.crafting_ing.*") - .expect("Failed to iterate over crafting ingredients."); - - Item::new_from_asset_glob("common.items.crafting_tools.*") - .expect("Failed to iterate over crafting tools."); - - Item::new_from_asset_glob("common.items.debug.*") - .expect("Failed to iterate over debug items."); - - Item::new_from_asset_glob("common.items.flowers.*") - .expect("Failed to iterate over flower items."); - - Item::new_from_asset_glob("common.items.food.*") - .expect("Failed to iterate over food items."); - - Item::new_from_asset_glob("common.items.glider.*") - .expect("Failed to iterate over gliders."); - - Item::new_from_asset_glob("common.items.grasses.*") - .expect("Failed to iterate over grasses."); - - Item::new_from_asset_glob("common.items.lantern.*") - .expect("Failed to iterate over lanterns."); - - Item::new_from_asset_glob("common.items.npc_armor.*") - .expect("Failed to iterate over npc armors."); - - Item::new_from_asset_glob("common.items.npc_weapons.*") - .expect("Failed to iterate over npc weapons."); - - Item::new_from_asset_glob("common.items.mineral.*") - .expect("Failed to iterate over minerals."); - - Item::new_from_asset_glob("common.items.tag_examples.*") - .expect("Failed to iterate over tag examples."); - - Item::new_from_asset_glob("common.items.testing.*") - .expect("Failed to iterate over testing items."); - - Item::new_from_asset_glob("common.items.utility.*") - .expect("Failed to iterate over utility items."); - - // Checks each weapon type to allow errors to be located more easily - Item::new_from_asset_glob("common.items.weapons.axe.*") - .expect("Failed to iterate over axes."); - - Item::new_from_asset_glob("common.items.weapons.axe_1h.*") - .expect("Failed to iterate over 1h axes."); - - Item::new_from_asset_glob("common.items.weapons.bow.*") - .expect("Failed to iterate over bows."); - - Item::new_from_asset_glob("common.items.weapons.dagger.*") - .expect("Failed to iterate over daggers."); - - Item::new_from_asset_glob("common.items.weapons.empty.*") - .expect("Failed to iterate over empty."); - - Item::new_from_asset_glob("common.items.weapons.hammer.*") - .expect("Failed to iterate over hammers."); - - Item::new_from_asset_glob("common.items.weapons.hammer_1h.*") - .expect("Failed to iterate over 1h hammers."); - - Item::new_from_asset_glob("common.items.weapons.sceptre.*") - .expect("Failed to iterate over sceptres."); - - Item::new_from_asset_glob("common.items.weapons.shield.*") - .expect("Failed to iterate over shields."); - - Item::new_from_asset_glob("common.items.weapons.staff.*") - .expect("Failed to iterate over staffs."); - - Item::new_from_asset_glob("common.items.weapons.sword.*") - .expect("Failed to iterate over swords."); - - Item::new_from_asset_glob("common.items.weapons.sword_1h.*") - .expect("Failed to iterate over 1h swords."); - - Item::new_from_asset_glob("common.items.weapons.tool.*") - .expect("Failed to iterate over tools."); - - // Checks all weapons should more weapons be added later - Item::new_from_asset_glob("common.items.weapons.*") - .expect("Failed to iterate over weapons."); - - // Final at the end to account for a new folder being added - Item::new_from_asset_glob("common.items.*").expect("Failed to iterate over item folders."); + let defs = assets::load_expect_dir::("common.items", true); + for item in defs.ids().map(Item::new_from_asset_expect) { + std::mem::drop(item) + } } }