[gnome-desktop-testing] Randomize test execution order



commit f54ed37c930d0adf97493a9df3a67622a0dff580
Author: Colin Walters <walters verbum org>
Date:   Thu Dec 26 07:24:45 2013 -0500

    Randomize test execution order
    
    We don't want to allow any dependencies between tests.  In the future,
    I'd like to only run a subset of tests (for example, prioritize tests
    more intelligently).

 src/gnome-desktop-testing-runner.c |   21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/src/gnome-desktop-testing-runner.c b/src/gnome-desktop-testing-runner.c
index b6597eb..8f656b0 100755
--- a/src/gnome-desktop-testing-runner.c
+++ b/src/gnome-desktop-testing-runner.c
@@ -575,6 +575,22 @@ cmp_tests (gconstpointer adata,
     }
 }
 
+static void
+fisher_yates_shuffle (GPtrArray *tests)
+{
+  guint m = tests->len;
+
+  while (m > 0)
+    {
+      guint i = g_random_int_range (0, m);
+      gpointer val;
+      m--;
+      val = tests->pdata[m];
+      tests->pdata[m] = tests->pdata[i];
+      tests->pdata[i] = val;
+    }
+}
+
 static gint64
 timeval_to_ms (const struct timeval *tv)
 {
@@ -681,12 +697,11 @@ main (int argc, char **argv)
         }
     }
 
-  g_ptr_array_sort (app->tests, cmp_tests);
-
   total_tests = app->tests->len;
 
   if (opt_list)
     {
+      g_ptr_array_sort (app->tests, cmp_tests);
       for (i = 0; i < app->tests->len; i++)
         {
           Test *test = app->tests->pdata[i];
@@ -697,6 +712,8 @@ main (int argc, char **argv)
     {
       gboolean show_status;
 
+      fisher_yates_shuffle (app->tests);
+
       reschedule_tests (app->cancellable);
 
       if (opt_status == NULL || strcmp (opt_status, "auto") == 0)


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