[librsvg: 8/53] Port the render_crash tests to Rust
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 8/53] Port the render_crash tests to Rust
- Date: Fri, 23 Oct 2020 02:19:06 +0000 (UTC)
commit de28c317b9af598c324548ebf3ee044aa1a63e42
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Oct 13 15:51:35 2020 -0500
Port the render_crash tests to Rust
Cargo.lock | 1 +
tests/Cargo.toml | 1 +
tests/src/main.rs | 3 +++
tests/src/render_crash.rs | 35 +++++++++++++++++++++++++++++++++++
4 files changed, 40 insertions(+)
---
diff --git a/Cargo.lock b/Cargo.lock
index 921b094b..2a46254e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -779,6 +779,7 @@ name = "librsvg-tests"
version = "0.1.0"
dependencies = [
"assert_cmd",
+ "cairo-rs",
"chrono",
"float-cmp",
"librsvg",
diff --git a/tests/Cargo.toml b/tests/Cargo.toml
index 3354dcf6..ac6a537d 100644
--- a/tests/Cargo.toml
+++ b/tests/Cargo.toml
@@ -7,6 +7,7 @@ edition = "2018"
[dev-dependencies]
assert_cmd = "1.0.1"
+cairo-rs = { version = "0.8.0", features = ["png"] }
chrono = "0.4.0"
float-cmp = "0.8.0"
librsvg = { path = "../librsvg_crate" }
diff --git a/tests/src/main.rs b/tests/src/main.rs
index a14b3a8d..793dfb47 100644
--- a/tests/src/main.rs
+++ b/tests/src/main.rs
@@ -11,6 +11,9 @@ mod loading_crash;
#[cfg(test)]
mod predicates;
+#[cfg(test)]
+mod render_crash;
+
mod utils;
fn main() {
diff --git a/tests/src/render_crash.rs b/tests/src/render_crash.rs
new file mode 100644
index 00000000..a02fb064
--- /dev/null
+++ b/tests/src/render_crash.rs
@@ -0,0 +1,35 @@
+//! Tests for crashes in the rendering stage.
+//!
+//! Ensures that redering a particular SVG doesn't crash, but we don't care
+//! about the resulting image or even whether there were errors during rendering.
+
+#![cfg(test)]
+use test_generator::test_resources;
+
+use cairo;
+use librsvg::{CairoRenderer, Loader};
+
+use crate::utils::fixture_path;
+
+#[test_resources("tests/fixtures/render-crash/*.svg")]
+fn loading_crash(name: &str) {
+ let path = fixture_path(name);
+
+ let handle = Loader::new()
+ .read_path(path)
+ .unwrap_or_else(|e| panic!("could not load: {}", e));
+
+ let surface = cairo::ImageSurface::create(cairo::Format::ARgb32, 100, 100).unwrap();
+ let cr = cairo::Context::new(&surface);
+
+ // We just test for crashes during rendering, and don't care about success/error.
+ let _ = CairoRenderer::new(&handle).render_document(
+ &cr,
+ &cairo::Rectangle {
+ x: 0.0,
+ y: 0.0,
+ width: 100.0,
+ height: 100.0,
+ },
+ );
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]