Skip to contentSkip to conversation

selftest/seltest.py: Add test to check imports from other layers

PATCH Superseded [email protected] 2 participants 3 messages Jul 12, 2016 – Jul 13, 2016 1 message not in the archive

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 selftest/seltest.py: Add test to check imports from other layers

From: Mariano Lopez <[email protected]>

This tests adds a check of selftest itself to verify if can add test from other layers.

[YOCTO #9770]

---
 meta-selftest/lib/oeqa/selftest/imported.py | 14 ++++++++++++++
 meta/lib/oeqa/selftest/seltest.py           | 19 +++++++++++++++++++
 2 files changed, 33 insertions(+)
 create mode 100644 meta-selftest/lib/oeqa/selftest/imported.py
 create mode 100644 meta/lib/oeqa/selftest/seltest.py
meta-selftest/lib/oeqa/selftest/imported.py new file +14 -0
new file mode 100644
index 0000000..b80150b
@@ -0,0 +1,14 @@
+from oeqa.selftest.base import oeSelfTest
+from oeqa.utils.decorators import testcase
+
+class ImportedTests(oeSelfTest):
+
+    def test_import_dummy(self):
+        """
+        Summary: Doesn't check anything, used to check import test from other layers.
+        Expected: 1. Pass unconditionally
+        Product: oe-core
+        Author: Mariano Lopez <[email protected]
+        """
+
+        self.assertEqual(True, True, msg = "Impossible to fail this test")
meta/lib/oeqa/selftest/seltest.py new file +19 -0
new file mode 100644
index 0000000..ea185ec
@@ -0,0 +1,19 @@
+from oeqa.selftest.base import oeSelfTest
+from oeqa.utils.commands import runCmd
+from oeqa.utils.decorators import testcase
+
+class Selftest(oeSelfTest):
+
+    def test_import_test_from_layer(self):
+        """
+        Summary: Checks functionality to import tests from other layers.
+        Expected: 1. Must show "test_import_dummy" in the test list.
+        Product: oe-core
+        Author: Mariano Lopez <[email protected]>
+        """
+
+        test_name = "imported.ImportedTests.test_import_dummy"
+        error_msg = "Couldn't find test: %s; Not importing tests from other layers" % test_name
+        result = runCmd("oe-selftest --list-tests")
+        success = True if test_name in result.output else False
+        self.assertEqual(success, True, msg = error_msg)
Signature · 1 line
2.6.6
#2 lore raw

Comments below

The test looks good.

Quoted 10 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Tuesday, July 12, 2016 8:10 AM
To: [email protected]
Cc: [email protected]; Mariano Lopez <[email protected]>
Subject: [PATCH 1/1] selftest/seltest.py: Add test to check imports from other layers

Quoted 3 lines

From: Mariano Lopez <[email protected]>

This tests adds a check of selftest itself to verify if can add test from

other

Quoted 19 lines

layers.

[YOCTO #9770]

---
 meta-selftest/lib/oeqa/selftest/imported.py | 14 ++++++++++++++
 meta/lib/oeqa/selftest/seltest.py           | 19 +++++++++++++++++++
 2 files changed, 33 insertions(+)
 create mode 100644 meta-selftest/lib/oeqa/selftest/imported.py
 create mode 100644 meta/lib/oeqa/selftest/seltest.py
meta- renamed from meta-selftest/lib/oeqa/selftest/imported.py +0 -0

selftest/lib/oeqa/selftest/imported.py
new file mode 100644
index 0000000..b80150b

meta-selftest/lib/oeqa/selftest/imported.py line 6

Quoted 6 lines
meta-selftest/lib/oeqa/selftest/imported.py new file +6 -0
@@ -0,0 +1,14 @@
+from oeqa.selftest.base import oeSelfTest from oeqa.utils.decorators
+import testcase
+
+class ImportedTests(oeSelfTest):
+
+    def test_import_dummy(self):

There is a bug where I am proposing some changes to the naming of the tests. I'll take this test name as an example:
imported.ImportedTests.test_import_dummy. With my proposal I'd name this test something more along these lines:
external_layer.ImportedTests.test_inconditional_pass.

meta-selftest/lib/oeqa/selftest/imported.py line 8

Quoted 2 lines
meta-selftest/lib/oeqa/selftest/imported.py new file +2 -0
+        """
+        Summary: Doesn't check anything, used to check import test from

other

meta-selftest/lib/oeqa/selftest/imported.py line 11

Quoted 4 lines

layers.

meta-selftest/lib/oeqa/selftest/imported.py new file +3 -0
+        Expected: 1. Pass unconditionally
+        Product: oe-core
+        Author: Mariano Lopez <[email protected]

typo at the end of the line

Quoted 11 lines
meta-selftest/lib/oeqa/selftest/imported.py new file +4 -0
+        """
+
+        self.assertEqual(True, True, msg = "Impossible to fail this
+ test")
meta/lib/oeqa/selftest/seltest.py new file +0 -0
new file mode 100644
index 0000000..ea185ec

meta/lib/oeqa/selftest/seltest.py line 6

Quoted 6 lines
meta/lib/oeqa/selftest/seltest.py new file +6 -0
@@ -0,0 +1,19 @@
+from oeqa.selftest.base import oeSelfTest from oeqa.utils.commands
+import runCmd from oeqa.utils.decorators import testcase
+
+class Selftest(oeSelfTest):
+
+    def test_import_test_from_layer(self):

Based on the naming guidelines comment above, proposing something like:
selftest.externalLayer.test_list_imported

meta/lib/oeqa/selftest/seltest.py

Quoted 9 lines
meta/lib/oeqa/selftest/seltest.py new file +9 -0
+        """
+        Summary: Checks functionality to import tests from other layers.
+        Expected: 1. Must show "test_import_dummy" in the test list.
+        Product: oe-core
+        Author: Mariano Lopez <[email protected]>
+        """
+
+        test_name = "imported.ImportedTests.test_import_dummy"
+        error_msg = "Couldn't find test: %s; Not importing tests from

other

Quoted 6 lines

layers" % test_name

meta/lib/oeqa/selftest/seltest.py new file +3 -1
+        result = runCmd("oe-selftest --list-tests")
+        success = True if test_name in result.output else False
+        self.assertEqual(success, True, msg = error_msg)
--

2.6.6

#3 lore raw
Quoted 4 lines · Benjamin Esquivel

Comments below

The test looks good.

Quoted 14 lines

meta-selftest/lib/oeqa/selftest/imported.py line 6

Quoted 9 lines
meta-selftest/lib/oeqa/selftest/imported.py new file +6 -0
@@ -0,0 +1,14 @@
+from oeqa.selftest.base import oeSelfTest from oeqa.utils.decorators
+import testcase
+
+class ImportedTests(oeSelfTest):
+
+    def test_import_dummy(self):

There is a bug where I am proposing some changes to the naming of the tests. I'll take this test name as an example:
imported.ImportedTests.test_import_dummy. With my proposal I'd name this test something more along these lines:
external_layer.ImportedTests.test_inconditional_pass.

I'll send v2 with the revised name

Mariano Lopez