blob: 5d2ebec731dddc10df488ca93d88729be360f6ec [file] [edit]
diff --git a/test/cairo-test.c b/test/cairo-test.c
index 49dfadb15..e2e1c3da6 100644
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -195,15 +195,26 @@ _cairo_test_init (cairo_test_context_t *ctx,
ctx->limited_targets = tmp_limited_targets;
ctx->own_targets = TRUE;
- ctx->srcdir = getenv ("srcdir");
- if (ctx->srcdir == NULL) {
- ctx->srcdir = ".";
+ ctx->srcdir = getenv ("srcdir");
+ if (ctx->srcdir == NULL) {
+ const char *test_srcdir = getenv ("TEST_SRCDIR");
+ const char *workspace = getenv ("TEST_WORKSPACE");
+
+ if (test_srcdir != NULL && workspace != NULL) {
+ char *runfiles_srcdir;
+ xasprintf (&runfiles_srcdir, "%s/%s/test", test_srcdir, workspace);
+ ctx->srcdir = runfiles_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";
+ struct stat st;
+ if (stat ("srcdir", &st) == 0 && (st.st_mode & S_IFDIR))
+ ctx->srcdir = "srcdir";
#endif
- }
+ }
ctx->refdir = xstrdup (getenv ("CAIRO_REF_DIR"));
if (ctx->refdir == NULL)