[OE-core] [PATCH] oeqa/oetest.py: add better pkg. search for hasPackage()

2015-08-21 Thread Costin Constantin
Modified hasPackage() to split the content of pkg. manifest file
in containing lines and search at the begining of each line the
existance of the needed pkg.

[YOCTO #8170]

Signed-off-by: Costin Constantin costin.c.constan...@intel.com
---
 meta/lib/oeqa/oetest.py | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py
index dfed3de..9bfc76d 100644
--- a/meta/lib/oeqa/oetest.py
+++ b/meta/lib/oeqa/oetest.py
@@ -99,10 +99,12 @@ class oeTest(unittest.TestCase):
 
 @classmethod
 def hasPackage(self, pkg):
-
-if re.search(pkg, oeTest.tc.pkgmanifest):
-return True
-return False
+for item in oeTest.tc.pkgmanifest.split('\n'):
+if re.match(pkg, item):
+return True
+break
+else:
+return False
 
 @classmethod
 def hasFeature(self,feature):
-- 
2.1.4

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH] oeqa/oetest.py: add better pkg. search for hasPackage()

2015-08-21 Thread Burton, Ross
On 21 August 2015 at 12:37, Costin Constantin costin.c.constan...@intel.com
 wrote:

 +for item in oeTest.tc.pkgmanifest.split('\n'):
 +if re.match(pkg, item):
 +return True
 +break
 +else:
 +return False


I just had to look up the for/else syntax as I'd never seen it before.
Whilst this works, the fact that the break statement is never executed (as
it returns beforehand) makes it a bit odd.  Personally I'd have done:

for item in ...:
  if re.match():
return True
return False

Ross
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core