From dbbbb606e54ea854ed676987b3963bdac958a687 Mon Sep 17 00:00:00 2001 From: Saurav Sachidanand Date: Wed, 30 May 2018 23:41:51 +0530 Subject: Write test artifacts to tests/output --- .gitlab-ci.yml | 6 +----- tests/Makefile.am | 3 +++ tests/README.md | 15 ++++++++------- tests/rsvg-test.c | 14 +++++++++++++- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 03c2fa48..84414324 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -45,15 +45,11 @@ stages: - ./autogen.sh --enable-gtk-doc --enable-vala - make check - after_script: - - mkdir png_artifacts - - cp /tmp/*.png png_artifacts - artifacts: when: on_failure paths: - tests/*.log - - png_artifacts + - tests/output/ cache: # JOB_NAME - Each job will have it's own cache diff --git a/tests/Makefile.am b/tests/Makefile.am index 6005eb2e..dde39443 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -87,3 +87,6 @@ dist_installed_test_data = \ fixtures/styles/bug614643.svg \ fixtures/styles/bug418823.svg \ fixtures/styles/order.svg + +clean-local: + rm -rf output \ No newline at end of file diff --git a/tests/README.md b/tests/README.md index b703b75c..3b03177b 100644 --- a/tests/README.md +++ b/tests/README.md @@ -94,8 +94,9 @@ If there are differences in the output, the test will fail; see These files can go anywhere under the `fixtures/reftests` directory; the `rsvg-test` program will recursively look inside -`fixtures/reftests` for all SVG files, render them, and compare them to -the `-ref.png` reference images. +`fixtures/reftests` for all SVG files, render them to `tests/output`, and +compare them to the `-ref.png` reference images. The rendered files can +later be removed by running `make clean`. **Ignoring tests:** SVG test files or entire subdirectories in `fixtures/reftests` whose names begin with "`ignore`" will be skipped from @@ -126,10 +127,10 @@ Let's say you run `make check` and see that one of the tests fails. For example, `rsvg-test.log` may have lines that look like ``` -# Storing test result image at /tmp/paths-data-18-f-out.png +# Storing test result image at tests/output/paths-data-18-f-out.png # 6798 pixels differ (with maximum difference of 255) from reference image -# Storing test result image at /tmp/paths-data-18-f-diff.png +# Storing test result image at tests/output/paths-data-18-f-diff.png not ok 29 /rsvg-test/reftests/svg1.1/paths-data-18-f.svg FAIL: rsvg-test 29 /rsvg-test/reftests/svg1.1/paths-data-18-f.svg ``` @@ -141,11 +142,11 @@ test file `fixtures/reftests/svg1.1/paths-data-18-f.svg` got rendered, and produced incorrect output when compared to `fixtures/reftests/svg1.1/paths-data-18-f-ref.png`. -When a test fails, rsvg-test creates two images in `/tmp`: +When a test fails, rsvg-test creates two images in `tests/output`: ``` -/tmp/foo-out.png -/tmp/foo-diff.png +tests/output/foo-out.png +tests/output/foo-diff.png ``` In this case, `foo-out.png` is the actual rendered output, which is presumed to diff --git a/tests/rsvg-test.c b/tests/rsvg-test.c index 03456f48..1839e7ca 100644 --- a/tests/rsvg-test.c +++ b/tests/rsvg-test.c @@ -34,11 +34,14 @@ #include #include +#include #include "librsvg/rsvg.h" #include "test-utils.h" +static char *_output_dir; + typedef struct _buffer_diff_result { unsigned int pixels_changed; unsigned int max_diff; @@ -138,11 +141,20 @@ compare_surfaces (cairo_surface_t *surface_a, result->pixels_changed, result->max_diff); } +static char * +get_output_dir (void) { + if (_output_dir == NULL) { + _output_dir = g_strconcat (g_get_current_dir (), G_DIR_SEPARATOR_S, "output", NULL); + g_mkdir (_output_dir, 0777); + } + return _output_dir; +} + static char * get_output_file (const char *test_file, const char *extension) { - const char *output_dir = g_get_tmp_dir (); + const char *output_dir = get_output_dir (); char *result, *base; base = g_path_get_basename (test_file); -- cgit v1.2.1