mirror of
https://git.yoctoproject.org/poky
synced 2026-09-14 12:49:34 +02:00
bitbake: tests/data: Add log parsing test code
This allows us to write tests which ensure a particular action generates a particular log message. (Bitbake rev: b30ee0aba51a35a194a4338b988f93ece1ed281c) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -24,6 +24,30 @@ import unittest
|
|||||||
import bb
|
import bb
|
||||||
import bb.data
|
import bb.data
|
||||||
import bb.parse
|
import bb.parse
|
||||||
|
import logging
|
||||||
|
|
||||||
|
class LogRecord():
|
||||||
|
def __enter__(self):
|
||||||
|
logs = []
|
||||||
|
class LogHandler(logging.Handler):
|
||||||
|
def emit(self, record):
|
||||||
|
logs.append(record)
|
||||||
|
logger = logging.getLogger("BitBake")
|
||||||
|
handler = LogHandler()
|
||||||
|
self.handler = handler
|
||||||
|
logger.addHandler(handler)
|
||||||
|
return logs
|
||||||
|
def __exit__(self, type, value, traceback):
|
||||||
|
logger = logging.getLogger("BitBake")
|
||||||
|
logger.removeHandler(self.handler)
|
||||||
|
return
|
||||||
|
|
||||||
|
def logContains(item, logs):
|
||||||
|
for l in logs:
|
||||||
|
m = l.getMessage()
|
||||||
|
if item in m:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
class DataExpansions(unittest.TestCase):
|
class DataExpansions(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@@ -301,7 +325,6 @@ class TestOverrides(unittest.TestCase):
|
|||||||
bb.data.update_data(self.d)
|
bb.data.update_data(self.d)
|
||||||
self.assertEqual(self.d.getVar("TEST", True), "testvalue3")
|
self.assertEqual(self.d.getVar("TEST", True), "testvalue3")
|
||||||
|
|
||||||
|
|
||||||
class TestFlags(unittest.TestCase):
|
class TestFlags(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.d = bb.data.init()
|
self.d = bb.data.init()
|
||||||
|
|||||||
Reference in New Issue
Block a user