[librsvg: 29/53] Better error messages when RSVG_TEST_TOLERANCE can not be parsed
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 29/53] Better error messages when RSVG_TEST_TOLERANCE can not be parsed
- Date: Fri, 23 Oct 2020 02:19:07 +0000 (UTC)
commit cf6a4c1017046f8c9f62cd2de4a9768e4545ecad
Author: Sven Neumann <sven svenfoo org>
Date: Sat Oct 17 09:35:48 2020 +0200
Better error messages when RSVG_TEST_TOLERANCE can not be parsed
librsvg_crate/tests/standalone/utils.rs | 7 +++++--
tests/build.rs | 8 +++++---
tests/src/reference.rs | 7 +++++--
3 files changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/librsvg_crate/tests/standalone/utils.rs b/librsvg_crate/tests/standalone/utils.rs
index b71aaa27..f3b89c8a 100644
--- a/librsvg_crate/tests/standalone/utils.rs
+++ b/librsvg_crate/tests/standalone/utils.rs
@@ -53,8 +53,11 @@ fn tolerable_difference() -> u8 {
static ONCE: Once = Once::new();
ONCE.call_once(|| unsafe {
if let Ok(str) = env::var("RSVG_TEST_TOLERANCE") {
- let value: usize = str.parse().unwrap();
- TOLERANCE = u8::try_from(value).unwrap();
+ let value: usize = str
+ .parse()
+ .expect("Can not parse RSVG_TEST_TOLERANCE as a number");
+ TOLERANCE =
+ u8::try_from(value).expect("RSVG_TEST_TOLERANCE should be between 0 and 255");
}
});
diff --git a/tests/build.rs b/tests/build.rs
index c19c5c30..ab8c0197 100644
--- a/tests/build.rs
+++ b/tests/build.rs
@@ -1,11 +1,13 @@
-use pkg_config;
-
fn main() {
check_for_pangoft2();
}
fn check_for_pangoft2() {
- if pkg_config::Config::new().atleast_version("1.38").probe("pangoft2").is_ok() {
+ if pkg_config::Config::new()
+ .atleast_version("1.38")
+ .probe("pangoft2")
+ .is_ok()
+ {
println!("cargo:rustc-cfg=have_pangoft2");
}
}
diff --git a/tests/src/reference.rs b/tests/src/reference.rs
index 3d2759e1..9011133d 100644
--- a/tests/src/reference.rs
+++ b/tests/src/reference.rs
@@ -211,8 +211,11 @@ mod duplicated_from_librsvg_crate {
static ONCE: Once = Once::new();
ONCE.call_once(|| unsafe {
if let Ok(str) = env::var("RSVG_TEST_TOLERANCE") {
- let value: usize = str.parse().unwrap();
- TOLERANCE = u8::try_from(value).unwrap();
+ let value: usize = str
+ .parse()
+ .expect("Can not parse RSVG_TEST_TOLERANCE as a number");
+ TOLERANCE =
+ u8::try_from(value).expect("RSVG_TEST_TOLERANCE should be between 0 and 255");
}
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]