[PATCH v3 7/7] test: Refer to output filename by variable, not a hardcoded value

"Bryce W. Harrington" <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
Signed-off-by: Bryce Harrington <[email protected]>
---
 test/svg-surface.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/test/svg-surface.c b/test/svg-surface.c
index 30cf994..8ee3b61 100644
--- a/test/svg-surface.c
+++ b/test/svg-surface.c
@@ -91,8 +91,9 @@ static cairo_test_status_t
 preamble (cairo_test_context_t *ctx)
 {
     cairo_t *cr;
-    const char *filename = CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".svg";
     cairo_surface_t *surface;
+    char *filename;
+    const char *path = cairo_test_mkdir (CAIRO_TEST_OUTPUT_DIR) ? CAIRO_TEST_OUTPUT_DIR : ".";
 
     if (! cairo_test_is_target_enabled (ctx, "svg11") &&
 	! cairo_test_is_target_enabled (ctx, "svg12"))
@@ -100,6 +101,7 @@ preamble (cairo_test_context_t *ctx)
 	return CAIRO_TEST_UNTESTED;
     }
 
+    xasprintf (&filename, "%s/%s.svg", path, BASENAME);
     surface = cairo_svg_surface_create (filename,
 					WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
     if (cairo_surface_status (surface)) {
@@ -107,6 +109,7 @@ preamble (cairo_test_context_t *ctx)
 			"Failed to create svg surface for file %s: %s\n",
 			filename,
 			cairo_status_to_string (cairo_surface_status (surface)));
+	free (filename);
 	return CAIRO_TEST_FAILURE;
     }
 
@@ -119,7 +122,8 @@ preamble (cairo_test_context_t *ctx)
     cairo_destroy (cr);
     cairo_surface_destroy (surface);
 
-    printf ("svg-surface: Please check svg-surface.svg to make sure it looks happy.\n");
+    printf ("svg-surface: Please check %s to make sure it looks happy.\n", filename);
+    free (filename);
     return CAIRO_TEST_SUCCESS;
 }
 
-- 
1.7.9.5
-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.