[cairo-commit] 2 commits - test/cairo-test.c test/meson.build test/README

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri May 20 13:07:42 UTC 2022


 test/README       |   14 ++++++++++++++
 test/cairo-test.c |   11 ++++++++---
 test/meson.build  |    7 +++++++
 3 files changed, 29 insertions(+), 3 deletions(-)

New commits:
commit 5dafd7411660f153219abceab64d5cc3be1c59a6
Merge: b41cfe3fe 29acc5584
Author: Uli Schlachter <psychon at znc.in>
Date:   Fri May 20 13:07:41 2022 +0000

    Merge branch 'srcdir' into 'master'
    
    Make it easier for cairo-test-suite to find the source dir
    
    See merge request cairo/cairo!328

commit 29acc5584915be294b2d7ed926d9ac48346474e3
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Wed May 18 10:37:37 2022 +0930

    Make it easier for cairo-test-suite to find the source dir

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())


More information about the cairo-commit mailing list