From 33a37a8857600327075bda6a6f389336953ac8fb Mon Sep 17 00:00:00 2001 From: juliancoffee Date: Sun, 4 Jul 2021 16:55:14 +0300 Subject: [PATCH] Run asset_tweak tests separately + Make parse_all_ron_files_to_value panic-friendly. Remove unwraps to unwrap_or_else with panic message. --- .gitlab/CI/build.gitlab-ci.yml | 3 ++- common/assets/src/lib.rs | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.gitlab/CI/build.gitlab-ci.yml b/.gitlab/CI/build.gitlab-ci.yml index e0eddc8959..d5c0fb21a6 100644 --- a/.gitlab/CI/build.gitlab-ci.yml +++ b/.gitlab/CI/build.gitlab-ci.yml @@ -8,8 +8,9 @@ unittests: - ln -s /dockercache/target target - rm -r target/debug/incremental/veloren_* || echo "all good" # TMP FIX FOR 2021-03-22-nightly - cargo test --package veloren-i18n --lib test_all_localizations -- --nocapture --ignored + - cargo test --package veloren-common-assets asset_tweak::tests --features asset_tweak --lib - rm -r target/debug/incremental* || echo "all good" # TMP FIX FOR 2021-03-22-nightly - - cargo test --features asset_tweak + - cargo test retry: max: 2 diff --git a/common/assets/src/lib.rs b/common/assets/src/lib.rs index 3534fdcf11..d9dd19c3e3 100644 --- a/common/assets/src/lib.rs +++ b/common/assets/src/lib.rs @@ -250,7 +250,6 @@ pub fn path_of(specifier: &str, ext: &str) -> PathBuf { #[cfg(test)] mod tests { - use std::{ffi::OsStr, fs::File}; use walkdir::WalkDir; @@ -260,7 +259,10 @@ mod tests { let ext = OsStr::new("ron"); WalkDir::new(crate::ASSETS_PATH.as_path()) .into_iter() - .map(|ent| ent.unwrap().into_path()) + .map(|ent| { + ent.expect("Failed to walk over asset directory") + .into_path() + }) .filter(|path| path.is_file()) .filter(|path| { path.extension() @@ -268,7 +270,7 @@ mod tests { .unwrap_or(false) }) .for_each(|path| { - let file = File::open(&path).unwrap(); + let file = File::open(&path).expect("Failed to open the file"); if let Err(err) = ron::de::from_reader::<_, ron::Value>(file) { println!("{:?}", path); println!("{:#?}", err);