diff --git a/test/README b/test/README index 84d7b4170..ea775cfcd 100644 --- a/test/README +++ b/test/README @@ -17,6 +17,11 @@ file, which, when viewed in a web browser makes it quite easy to visually see any failed renderings alongside the corresponding reference image, (and a diff image as well). +As some browsers do not permit Javascript to read from the local +filesystem, the view-test-results.py script can used to view the +results. It starts a http server serving the current directory before +displaying the test results in a browser. + The test suite needs to be run before any code is committed and before any release. See below for hints and rules governing the use of the suite. @@ -36,6 +41,15 @@ CAIRO_TEST_TARGET environment variable, so for instance: This binary should be backwards-compatible with all library versions, allowing you to compare current versus past behaviour for any test. +The test suite needs to find the "test" directory in the source +tree. The srcdir environment variable can be used to specify +the location of this directory. If this environment variable is not +set, the binary looks for the directory "srcdir" in the current +directory. The meson build system symlinks "srcdir" in the +$builddir/test directory to the "test" directory in the source +tree. If this is not found the binary defaults to the current +directory. + Tailoring tests running ----------------------- There are some mechanisms to limit the tests run during "make test". diff --git a/test/cairo-test.c b/test/cairo-test.c index df230e523..cbd4fb1ab 100644 --- a/test/cairo-test.c +++ b/test/cairo-test.c @@ -196,9 +196,14 @@ _cairo_test_init (cairo_test_context_t *ctx, ctx->own_targets = TRUE; ctx->srcdir = getenv ("srcdir"); - if (ctx->srcdir == NULL) - ctx->srcdir = "."; - + if (ctx->srcdir == NULL) { + ctx->srcdir = "."; +#if HAVE_SYS_STAT_H + struct stat st; + if (stat ("srcdir", &st) == 0 && (st.st_mode & S_IFDIR)) + ctx->srcdir = "srcdir"; +#endif + } ctx->refdir = getenv ("CAIRO_REF_DIR"); } diff --git a/test/meson.build b/test/meson.build index be05d30ec..bc1547494 100644 --- a/test/meson.build +++ b/test/meson.build @@ -634,6 +634,13 @@ foreach file : html_files configure_file(input: file, output : file, copy: true) endforeach +if build_machine.system() != 'windows' + run_command('ln', '-sf', + meson.current_source_dir(), + join_paths(meson.current_build_dir(), 'srcdir'), + check: true) +endif + env = environment() env.set('srcdir', meson.current_source_dir())