Merge branch 'juliancoffee/better_item_tests' into 'master'

More informative item tests

See merge request veloren/veloren!2534
This commit is contained in:
Ben Wallis 2021-06-30 20:12:21 +00:00
commit 398b658524
2 changed files with 6 additions and 101 deletions

View File

@ -96,7 +96,8 @@ pub fn load_dir<T: DirLoadable>(
#[track_caller]
pub fn load_expect_dir<T: DirLoadable>(specifier: &str, recursive: bool) -> AssetDirHandle<T> {
load_dir(specifier, recursive).expect("Failed loading directory")
load_dir(specifier, recursive)
.unwrap_or_else(|e| panic!("Failed loading directory. error={:?}", e))
}
impl<T: Compound> AssetExt for T {

View File

@ -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::<RawItemDef>("common.items", true);
for item in defs.ids().map(Item::new_from_asset_expect) {
std::mem::drop(item)
}
}
}