From 3a88a055012ebfc53d967fdd129f4ebc75fb9881 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Diemer?= <stephane.diemer@ubicast.eu>
Date: Wed, 15 Mar 2017 18:11:45 +0100
Subject: [PATCH] Order tests results by criticality (refs #20690).

---
 tester.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/tester.py b/tester.py
index 79bed5ac..91efb3de 100755
--- a/tester.py
+++ b/tester.py
@@ -123,17 +123,22 @@ class Tester():
 
     def discover_tests(self, basic_only=False):
         ignored_tests = utils.get_conf('TESTER_IGNORED_TESTS', '').split(',')
-        tests = list()
         # Get standard tests
         path = os.path.join(self.root_dir, 'tests')
         if not os.path.isdir(path):
             log('The tests dir is missing ("%s").' % path)
-            return tests
+            return
         names = os.listdir(path)
         names.sort()
         if not names:
             log('The tests dir is empty ("%s").' % path)
-            return tests
+            return
+        criticalities_map = {
+            'Low': 1,
+            'Normal': 2,
+            'High': 3,
+        }
+        tests = list()
         for name in names:
             if name in ignored_tests:
                 continue
@@ -142,6 +147,7 @@ class Tester():
                 criticality, description = self.parse_file_header(test_path)
                 tests.append((name, criticality, description, [test_path]))
         if basic_only:
+            tests.sort(key=lambda i: (-criticalities_map.get(i[1], 0), i[0]))
             return tests
         # Get MS instances
         ms_users = list()
@@ -199,6 +205,7 @@ class Tester():
                     test_path = os.path.join(ms_path, name)
                     criticality, description = self.parse_file_header(test_path)
                     tests.append(('%s (%s)' % (name, user), criticality, description, [test_path, user]))
+        tests.sort(key=lambda i: (-criticalities_map.get(i[1], 0), i[0]))
         return tests
 
     def run_tests(self, tests, email=False, email_if_fail=False):
-- 
GitLab