summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/classes-global/insane.bbclass22
1 files changed, 22 insertions, 0 deletions
diff --git a/meta/classes-global/insane.bbclass b/meta/classes-global/insane.bbclass
index c40bae7e3d..99b8faccf5 100644
--- a/meta/classes-global/insane.bbclass
+++ b/meta/classes-global/insane.bbclass
@@ -1351,12 +1351,34 @@ python do_qa_patch() {
1351 ########################################################################### 1351 ###########################################################################
1352 # Check for missing ptests 1352 # Check for missing ptests
1353 ########################################################################### 1353 ###########################################################################
1354 def match_line_in_files(toplevel, filename_glob, line_regex):
1355 import pathlib
1356 toppath = pathlib.Path(toplevel)
1357 for entry in toppath.glob(filename_glob):
1358 try:
1359 with open(entry, 'r', encoding='utf-8', errors='ignore') as f:
1360 for line in f.readlines():
1361 if re.match(line_regex, line):
1362 return True
1363 except FileNotFoundError:
1364 # Broken symlink in source
1365 pass
1366 return False
1367
1354 srcdir = d.getVar('S') 1368 srcdir = d.getVar('S')
1355 if not bb.utils.contains('DISTRO_FEATURES', 'ptest', True, False, d): 1369 if not bb.utils.contains('DISTRO_FEATURES', 'ptest', True, False, d):
1356 pass 1370 pass
1357 elif bb.data.inherits_class('ptest', d): 1371 elif bb.data.inherits_class('ptest', d):
1358 bb.note("Package %s QA: skipping unimplemented-ptest: ptest implementation detected" % d.getVar('PN')) 1372 bb.note("Package %s QA: skipping unimplemented-ptest: ptest implementation detected" % d.getVar('PN'))
1359 1373
1374 # Detect perl Test:: based tests
1375 elif os.path.exists(os.path.join(srcdir, "t")) and any(filename.endswith('.t') for filename in os.listdir(os.path.join(srcdir, 't'))):
1376 oe.qa.handle_error("unimplemented-ptest", "%s: perl Test:: based tests detected" % d.getVar('PN'), d)
1377
1378 # Detect pytest-based tests
1379 elif match_line_in_files(srcdir, "**/*.py", r'\s*(?:import\s*pytest|from\s*pytest)'):
1380 oe.qa.handle_error("unimplemented-ptest", "%s: pytest-based tests detected" % d.getVar('PN'), d)
1381
1360 oe.qa.exit_if_errors(d) 1382 oe.qa.exit_if_errors(d)
1361} 1383}
1362 1384