tests: Allow setting a subdir for output
authorMatthias Clasen <mclasen@redhat.com>
Fri, 15 May 2020 13:18:35 +0000 (09:18 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 15 May 2020 18:11:53 +0000 (14:11 -0400)
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
testsuite/performance/test-performance.c
testsuite/reftests/gtk-reftest.c

index e61fa71e66d8514c41e9893a7ba228804033baa3..3883ed766ea183757e851e94f9db4f010250150a 100644 (file)
@@ -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);
     }
index 9e7d8a710bf6e748e62a37031e83e83bfb8c60d4..506763a75130f9e34ea0e5ba5a07e89211b51400 100644 (file)
@@ -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);
 
index cf07fcc27fd3e59829426039cdf1f82ed00498a1..41e28c05b91ce4def4888f676ccbc651cf60128c 100644 (file)
@@ -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))