All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Konrad Weihmann" <kweihmann@outlook.com>
To: openembedded-core@lists.openembedded.org
Cc: Konrad Weihmann <kweihmann@outlook.com>
Subject: [PATCH v2 2/3] OETestContext: order test cases by prio & depends
Date: Tue, 26 Jan 2021 19:01:42 +0100	[thread overview]
Message-ID: <AM9PR09MB4642F0A8F6A711C5CC4EE30FA8BC0@AM9PR09MB4642.eurprd09.prod.outlook.com> (raw)
In-Reply-To: <20210126180143.605303-1-kweihmann@outlook.com>

Order the overall test case list in the resulting test suite
by priority (by default all test cases do have a priority of 50).
In a second round move test cases with test dependencies accordingly.
New method 'orderSuites' can be explictly overridden to disable
usage of the new 'priority' decorator.

Signed-off-by: Konrad Weihmann <kweihmann@outlook.com>
---
v2:
  - mind test cases without any decorator
  - rename new method to orderSuites

 meta/lib/oeqa/core/context.py | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/meta/lib/oeqa/core/context.py b/meta/lib/oeqa/core/context.py
index 2abe353d27..2ca9ec0c56 100644
--- a/meta/lib/oeqa/core/context.py
+++ b/meta/lib/oeqa/core/context.py
@@ -66,6 +66,34 @@ class OETestContext(object):
                 if (cid + '.').startswith(skip + '.'):
                     setattr(tclass, 'setUpHooker', skipfuncgen('Skip by the command line argument "%s"' % skip))
 
+    def orderSuites(self, suites):
+        _tests = {}
+        for _test in suites._tests:
+            _prio = 50
+            _depends = []
+            for x in getattr(_test, "decorators", []):
+                if hasattr(x, "depends"):
+                    _depends += getattr(x, "depends")
+                if hasattr(x, "priority"):
+                    _prio = getattr(x, "priority")
+            _tests[_test.id()] = {"prio": _prio, "deps": _depends, "ref": _test}
+
+        def set_suite_prio(suites, suite):
+            for dep in suite["deps"]:
+                if dep not in suites:
+                    try:
+                        dep = [x for x in suites.keys() if x.endswith(dep)][0]
+                    except:
+                        continue
+                suite["prio"] = max(suite["prio"], set_suite_prio(suites, suites[dep]) + 1)
+            return suite["prio"]
+
+        for k, v in _tests.items():
+            _tests[k]["prio"] = set_suite_prio(_tests, v)
+
+        suites._tests = [x[1]["ref"] for x in sorted(_tests.items(), key=lambda tup: tup[1]["prio"])]
+        return suites
+
     def loadTests(self, module_paths, modules=[], tests=[],
             modules_manifest="", modules_required=[], **kwargs):
         if modules_manifest:
@@ -73,7 +101,7 @@ class OETestContext(object):
 
         self.loader = self.loaderClass(self, module_paths, modules, tests,
                 modules_required, **kwargs)
-        self.suites = self.loader.discover()
+        self.suites = self.orderSuites(self.loader.discover())
 
     def prepareSuite(self, suites, processes):
         return suites
-- 
2.25.1


       reply	other threads:[~2021-01-26 18:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210126180143.605303-1-kweihmann@outlook.com>
2021-01-26 18:01 ` Konrad Weihmann [this message]
2021-01-26 18:01 ` [PATCH v2 3/3] oeqa: add tests for OETestPriority Konrad Weihmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM9PR09MB4642F0A8F6A711C5CC4EE30FA8BC0@AM9PR09MB4642.eurprd09.prod.outlook.com \
    --to=kweihmann@outlook.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.