mirror of
https://git.yoctoproject.org/poky
synced 2026-02-09 10:13:03 +01:00
Currently if all recipes in a layer are skipped, there are warnings that the BBFILE_PATTERN_ entry didn't match anything. We probably shouldn't do this for skipped recipes. The current code is hard to understand, not least as it passes variables which functions modify by reference rather than giving a return value. Update calc_bbfile_priority() to return values rather than modifying them. Refactor the code to try and make it clearer what its doing and fix the skipped recipe issue by passing in the list of parsed files. The function is complicated by the need to not rerun regex matching more than we ever have to which complicates the flow, it would be easier if we just reran operations multiple times. (Bitbake rev: 969cb27b4d978551817612ff4558bec81cfb655c) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
70 lines
2.5 KiB
Python
70 lines
2.5 KiB
Python
#
|
|
# BitBake Tests for cooker.py
|
|
#
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
|
#
|
|
|
|
import unittest
|
|
import os
|
|
import bb, bb.cooker
|
|
import re
|
|
import logging
|
|
|
|
# Cooker tests
|
|
class CookerTest(unittest.TestCase):
|
|
def setUp(self):
|
|
# At least one variable needs to be set
|
|
self.d = bb.data.init()
|
|
topdir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "testdata/cooker")
|
|
self.d.setVar('TOPDIR', topdir)
|
|
|
|
def test_CookerCollectFiles_sublayers(self):
|
|
'''Test that a sublayer of an existing layer does not trigger
|
|
No bb files matched ...'''
|
|
|
|
def append_collection(topdir, path, d):
|
|
collection = path.split('/')[-1]
|
|
pattern = "^" + topdir + "/" + path + "/"
|
|
regex = re.compile(pattern)
|
|
priority = 5
|
|
|
|
d.setVar('BBFILE_COLLECTIONS', (d.getVar('BBFILE_COLLECTIONS') or "") + " " + collection)
|
|
d.setVar('BBFILE_PATTERN_%s' % (collection), pattern)
|
|
d.setVar('BBFILE_PRIORITY_%s' % (collection), priority)
|
|
|
|
return (collection, pattern, regex, priority)
|
|
|
|
topdir = self.d.getVar("TOPDIR")
|
|
|
|
# Priorities: list of (collection, pattern, regex, priority)
|
|
bbfile_config_priorities = []
|
|
# Order is important for this test, shortest to longest is typical failure case
|
|
bbfile_config_priorities.append( append_collection(topdir, 'first', self.d) )
|
|
bbfile_config_priorities.append( append_collection(topdir, 'second', self.d) )
|
|
bbfile_config_priorities.append( append_collection(topdir, 'second/third', self.d) )
|
|
|
|
pkgfns = [ topdir + '/first/recipes/sample1_1.0.bb',
|
|
topdir + '/second/recipes/sample2_1.0.bb',
|
|
topdir + '/second/third/recipes/sample3_1.0.bb' ]
|
|
|
|
class LogHandler(logging.Handler):
|
|
def __init__(self):
|
|
logging.Handler.__init__(self)
|
|
self.logdata = []
|
|
|
|
def emit(self, record):
|
|
self.logdata.append(record.getMessage())
|
|
|
|
# Move cooker to use my special logging
|
|
logger = bb.cooker.logger
|
|
log_handler = LogHandler()
|
|
logger.addHandler(log_handler)
|
|
collection = bb.cooker.CookerCollectFiles(bbfile_config_priorities)
|
|
collection.collection_priorities(pkgfns, pkgfns, self.d)
|
|
logger.removeHandler(log_handler)
|
|
|
|
# Should be empty (no generated messages)
|
|
expected = []
|
|
|
|
self.assertEqual(log_handler.logdata, expected)
|