[lasem] tests: add a way to ignore png creation and html logging
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [lasem] tests: add a way to ignore png creation and html logging
- Date: Fri, 31 Jul 2015 19:04:21 +0000 (UTC)
commit f2113ad7eb038eb6a4657ca92dbd2df7c315afde
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Fri Jul 31 16:28:35 2015 +0200
tests: add a way to ignore png creation and html logging
For certain files, we just want to know if lasem doesn't crash, we are
not interested in the actual output. This patch allow to not save the
result as png and to not include the result in the html log file.
Just prepend "dont-render-" to the file name.
...> dont-render-librsvg-bug752670-fuzzed-715.svg} | 0
...> dont-render-librsvg-bug752670-fuzzed-84d.svg} | 0
...> dont-render-librsvg-bug752670-fuzzed-beb.svg} | 0
tests/lsmtest.c | 62 ++++++++++---------
4 files changed, 33 insertions(+), 29 deletions(-)
---
diff --git a/tests/data/svg/samples/librsvg/librsvg-bug752670-fuzzed-715.svg
b/tests/data/svg/samples/librsvg/dont-render-librsvg-bug752670-fuzzed-715.svg
similarity index 100%
rename from tests/data/svg/samples/librsvg/librsvg-bug752670-fuzzed-715.svg
rename to tests/data/svg/samples/librsvg/dont-render-librsvg-bug752670-fuzzed-715.svg
diff --git a/tests/data/svg/samples/librsvg/librsvg-bug752670-fuzzed-84d.svg
b/tests/data/svg/samples/librsvg/dont-render-librsvg-bug752670-fuzzed-84d.svg
similarity index 100%
rename from tests/data/svg/samples/librsvg/librsvg-bug752670-fuzzed-84d.svg
rename to tests/data/svg/samples/librsvg/dont-render-librsvg-bug752670-fuzzed-84d.svg
diff --git a/tests/data/svg/samples/librsvg/librsvg-bug752670-fuzzed-beb.svg
b/tests/data/svg/samples/librsvg/dont-render-librsvg-bug752670-fuzzed-beb.svg
similarity index 100%
rename from tests/data/svg/samples/librsvg/librsvg-bug752670-fuzzed-beb.svg
rename to tests/data/svg/samples/librsvg/dont-render-librsvg-bug752670-fuzzed-beb.svg
diff --git a/tests/lsmtest.c b/tests/lsmtest.c
index c9a13f0..3271571 100644
--- a/tests/lsmtest.c
+++ b/tests/lsmtest.c
@@ -246,7 +246,7 @@ compare_surfaces (const char *test_name, cairo_surface_t *surface_a, cairo_surfa
}
static void
-lasem_test_render (char const *filename, gboolean compare, gboolean dry_run, Statistic *statistic)
+lasem_test_render (char const *filename, gboolean compare, gboolean dry_run, gboolean save_png, Statistic
*statistic)
{
LsmDomDocument *document;
LsmDomView *view;
@@ -341,7 +341,7 @@ lasem_test_render (char const *filename, gboolean compare, gboolean dry_run, Sta
statistic->rendered_count++;
g_timer_destroy (timer);
- if (!dry_run)
+ if (!dry_run && save_png)
cairo_surface_write_to_png (surface, png_filename);
if (check) {
@@ -368,39 +368,41 @@ lasem_test_render (char const *filename, gboolean compare, gboolean dry_run, Sta
g_object_unref (view);
g_object_unref (document);
- lasem_test_html ("<table border=\"1\" cellpadding=\"8\">\n");
- lasem_test_html ("<tr>");
+ if (save_png) {
+ lasem_test_html ("<table border=\"1\" cellpadding=\"8\">\n");
+ lasem_test_html ("<tr>");
- lasem_test_html ("<td><a href=\"%s\"><img border=\"0\" src=\"%s\"/></a></td>",
- filename, png_filename);
- lasem_test_html ("<td><img src=\"%s\"/></td>", reference_png_filename);
+ lasem_test_html ("<td><a href=\"%s\"><img border=\"0\" src=\"%s\"/></a></td>",
+ filename, png_filename);
+ lasem_test_html ("<td><img src=\"%s\"/></td>", reference_png_filename);
- lasem_test_html ("<td>");
+ lasem_test_html ("<td>");
- if (is_mathml) {
- regex = g_regex_new ("<math>", 0, 0, &error);
- assert (error == NULL);
+ if (is_mathml) {
+ regex = g_regex_new ("<math>", 0, 0, &error);
+ assert (error == NULL);
- filtered_buffer = g_regex_replace (regex, xml,
- -1, 0,
- "<math
xmlns=\"http://www.w3.org/1998/Math/MathML\">",
- 0, NULL);
- g_regex_unref (regex);
+ filtered_buffer = g_regex_replace (regex, xml,
+ -1, 0,
+ "<math
xmlns=\"http://www.w3.org/1998/Math/MathML\">",
+ 0, NULL);
+ g_regex_unref (regex);
- lasem_test_html ("%s", filtered_buffer);
+ lasem_test_html ("%s", filtered_buffer);
- g_free (filtered_buffer);
- }
+ g_free (filtered_buffer);
+ }
- if (is_svg) {
- lasem_test_html ("<object type=\"image/svg+xml\" data=\"");
- lasem_test_html ("%s", filename);
- lasem_test_html ("\" width=\"%dpx\"/>", width + 2);
- }
+ if (is_svg) {
+ lasem_test_html ("<object type=\"image/svg+xml\" data=\"");
+ lasem_test_html ("%s", filename);
+ lasem_test_html ("\" width=\"%dpx\"/>", width + 2);
+ }
- lasem_test_html ("</td>");
- lasem_test_html ("</tr>\n");
- lasem_test_html ("</table>\n");
+ lasem_test_html ("</td>");
+ lasem_test_html ("</tr>\n");
+ lasem_test_html ("</table>\n");
+ }
if (!is_xml && !g_file_test (reference_png_filename, G_FILE_TEST_IS_REGULAR) && !dry_run) {
FILE *file;
@@ -476,13 +478,15 @@ lasem_test_process_dir (const char *name, gboolean compare, gboolean dry_run, St
strstr (entry, "ignore-") != entry &&
strcmp (entry, "images") != 0)
{
+ gboolean save_png = strstr (entry, "dont-render-") != entry;
+
filename = g_build_filename (name, entry, NULL);
if (g_file_test (filename, G_FILE_TEST_IS_DIR))
lasem_test_process_dir (filename, compare, dry_run, statistic);
else if (g_file_test (filename, G_FILE_TEST_IS_REGULAR) &&
g_regex_match (regex_mml, filename, 0, NULL)) {
- lasem_test_render (filename, compare, dry_run, statistic);
+ lasem_test_render (filename, compare, dry_run, save_png, statistic);
n_files++;
}
@@ -570,7 +574,7 @@ main (int argc, char **argv)
else {
if (n_input_files > 0)
for (i = 0; i < n_input_files; i++)
- lasem_test_render (option_input_filenames[i], TRUE, option_dry_run,
&statistic);
+ lasem_test_render (option_input_filenames[i], TRUE, option_dry_run, TRUE,
&statistic);
else
lasem_test_process_dir (".", TRUE, option_dry_run, &statistic);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]