diff mbox series

[27/41] oeqa/core/decorator/depends: Check resolved dependency ids when running

Message ID 20261115084845.701136-27-richard.purdie@linuxfoundation.org
State New
Headers show
Series [01/41] oeqa/loader: Drop code for pre python 3.5 | expand

Commit Message

Richard Purdie Nov. 15, 2026, 8:48 a.m. UTC
OETestDepends allows dependencies to be given relative to the test's
module or class and bind() resolves these to full test ids for ordering.

The runtime check compared the dependencies as written with the ids of the
passed tests though, so a test with a relative dependency was always
skipped, e.g. test_example_depends in the core example tests.

Use the resolved ids from the registry to avoid that.

Add a test which runs tests with relative dependencies.

AI-Generated: Uses Claude Opus 5.5
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/lib/oeqa/core/decorator/depends.py     |  2 +-
 meta/lib/oeqa/core/tests/test_decorators.py | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/meta/lib/oeqa/core/decorator/depends.py b/meta/lib/oeqa/core/decorator/depends.py
index 41a324e61fb..abfb72a6152 100644
--- a/meta/lib/oeqa/core/decorator/depends.py
+++ b/meta/lib/oeqa/core/decorator/depends.py
@@ -95,4 +95,4 @@  class OETestDepends(OETestDiscover):
             return [registry['cases'][case_id] for case_id in registry['cases']]
 
     def setUpDecorator(self):
-        _skipTestDependency(self.case, self.depends)
+        _skipTestDependency(self.case, self.case.tc._registry['depends'][self.case.id()])
diff --git a/meta/lib/oeqa/core/tests/test_decorators.py b/meta/lib/oeqa/core/tests/test_decorators.py
index 5095f39948d..2c668a9871d 100755
--- a/meta/lib/oeqa/core/tests/test_decorators.py
+++ b/meta/lib/oeqa/core/tests/test_decorators.py
@@ -112,6 +112,20 @@  class TestDependsDecorator(TestBase):
             msg = 'Expected OEQADependency exception having a circular dependency'
             self.assertTrue(result, msg=msg)
 
+    def test_depends_run(self):
+        # Dependencies given relative to the class must be found when the
+        # tests run, otherwise the dependent tests are skipped
+        tests =  ['depends.DependsTest.testDependsFirst',
+                  'depends.DependsTest.testDependsSecond',
+                  'depends.DependsTest.testDependsThird',
+                  'depends.DependsTest.testDependsFourth',
+                  'depends.DependsTest.testDependsFifth']
+        tc = self._testLoader(modules=self.modules, tests=tests)
+        result = tc.runTests()
+        self.assertTrue(result.wasSuccessful())
+        self.assertEqual(result.skipped, [])
+        self.assertEqual(len(result.successes), len(tests))
+
 class TestTimeoutDecorator(TestBase):
     modules = ['timeout']