[gtk/headless-seatless] tests: Allow setting a subdir for output



commit 269fea9968e6aa198b3a09e3b235c6b97f1af224
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri May 15 09:18:35 2020 -0400

    tests: Allow setting a subdir for output
    
    meson seems somewhat weak when it comes to handling
    test output. We need to get the output from different
    test runs into different locations, and the only
    way to communicate from a test setup with the actual
    test code seems the environment, so use that.
    
    Make all tests that produce output in files respect
    a TEST_OUTPUT_SUBDIR environment variable which specifies
    the name of a subdirectory to use. This is combined
    with the existing --output argument, which specifies
    a per-test location.
    
    Affected tests are reftests, css performance tests
    and gsk compare tests.

 testsuite/gsk/compare-render.c           | 10 ++++++++++
 testsuite/performance/test-performance.c | 12 +++++++++++-
 testsuite/reftests/gtk-reftest.c         | 10 ++++++++++
 3 files changed, 31 insertions(+), 1 deletion(-)
---
diff --git a/testsuite/gsk/compare-render.c b/testsuite/gsk/compare-render.c
index e61fa71e66..3883ed766e 100644
--- a/testsuite/gsk/compare-render.c
+++ b/testsuite/gsk/compare-render.c
@@ -19,6 +19,16 @@ get_output_dir (void)
   if (arg_output_dir)
     {
       GFile *file = g_file_new_for_commandline_arg (arg_output_dir);
+      const char *subdir;
+
+      subdir = g_getenv ("TEST_OUTPUT_SUBDIR");
+      if (subdir)
+        {
+          GFile *child = g_file_get_child (file, subdir);
+          g_object_unref (file);
+          file = child;
+        }
+
       output_dir = g_file_get_path (file);
       g_object_unref (file);
     }
diff --git a/testsuite/performance/test-performance.c b/testsuite/performance/test-performance.c
index 9e7d8a710b..506763a751 100644
--- a/testsuite/performance/test-performance.c
+++ b/testsuite/performance/test-performance.c
@@ -89,8 +89,18 @@ main (int argc, char *argv[])
     {
       GError *err = NULL;
       GFile *file;
+      const char *subdir;
 
       file = g_file_new_for_commandline_arg (opt_output);
+
+      subdir = g_getenv ("TEST_OUTPUT_SUBDIR");
+      if (subdir)
+        {
+          GFile *child = g_file_get_child (file, subdir);
+          g_object_unref (file);
+          file = child;
+        }
+
       if (!g_file_make_directory_with_parents (file, NULL, &err))
         {
           if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_EXISTS))
@@ -134,7 +144,7 @@ main (int argc, char *argv[])
 
       if (!g_subprocess_get_successful (subprocess))
         g_error ("Child process failed");
-        
+
       g_object_unref (subprocess);
       g_object_unref (launcher);
 
diff --git a/testsuite/reftests/gtk-reftest.c b/testsuite/reftests/gtk-reftest.c
index cf07fcc27f..41e28c05b9 100644
--- a/testsuite/reftests/gtk-reftest.c
+++ b/testsuite/reftests/gtk-reftest.c
@@ -109,8 +109,18 @@ get_output_dir (GError **error)
     {
       GError *err = NULL;
       GFile *file;
+      const char *subdir;
 
       file = g_file_new_for_commandline_arg (arg_output_dir);
+
+      subdir = g_getenv ("TEST_OUTPUT_SUBDIR");
+      if (subdir)
+        {
+          GFile *child = g_file_get_child (file, subdir);
+          g_object_unref (file);
+          file = child;
+        }
+
       if (!g_file_make_directory_with_parents (file, NULL, &err))
         {
           if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_EXISTS))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]