From 77e9b05b2b011ce964287ff493c2b421977107ee Mon Sep 17 00:00:00 2001 From: Brian Ewins Date: Sat, 10 Nov 2007 01:34:03 +0000 Subject: [PATCH] [test] support using a previous build as a reference Allow using a previous test output directory as a source of reference images. To make use of this, set the environment variable 'CAIRO_REF_DIR' to point at an old test directory, relative to the current test directory. This is useful for testing backends when reference images haven't been created yet, or which the current reference image structure can't accomodate, like multiple font backends. --- test/README | 8 ++++++++ test/cairo-test.c | 17 ++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/test/README b/test/README index 90f028765..840e1addb 100644 --- a/test/README +++ b/test/README @@ -69,6 +69,14 @@ The work involved is similar the work described above for new bugs. The only distinction is that the test is expected to pass so it should not be added to the XFAIL_TESTS list. +While working on a test +----------------------- +Before a bugfix or feature is ready, it may be useful to compare +output from different builds. For convenience, you can set +CAIRO_REF_DIR to point at a previous test directory, relative +to the current test directory, and any previous output will be +used by preference as reference images. + When a bug is fixed ------------------- diff --git a/test/cairo-test.c b/test/cairo-test.c index d2e415709..f036163ba 100644 --- a/test/cairo-test.c +++ b/test/cairo-test.c @@ -96,6 +96,7 @@ static const char *vector_ignored_tests[] = { * context object there, (though not a whole lot). */ FILE *cairo_test_log_file = NULL; const char *srcdir; +const char *refdir; /* Used to catch crashes in a test, such that we report it as such and * continue testing, although one crasher may already have corrupted memory in @@ -158,7 +159,20 @@ cairo_ref_name_for_test_target_format (const char *test_name, { char *ref_name = NULL; - /* First look for a target/format-specific reference image. */ + /* First look for a previous build for comparison. */ + if (refdir) { + xasprintf (&ref_name, "%s/%s-%s-%s%s", refdir, + test_name, + target_name, + format, + CAIRO_TEST_PNG_SUFFIX); + if (access (ref_name, F_OK) != 0) + free (ref_name); + else + goto done; + } + + /* Next look for a target/format-specific reference image. */ xasprintf (&ref_name, "%s/%s-%s-%s%s", srcdir, test_name, target_name, @@ -477,6 +491,7 @@ cairo_test_expecting (cairo_test_t *test, srcdir = getenv ("srcdir"); if (!srcdir) srcdir = "."; + refdir = getenv ("CAIRO_REF_DIR"); cairo_test_init (test->name); printf ("%s\n", test->description);