@@ -56,6 +56,8 @@ def analyze_result(results, patch, counts, return_code):
expected_result = str(patch["expected"])
for resultline in results.splitlines():
if testid in resultline:
+ if ':' not in resultline:
+ continue
result, _ = resultline.split(':', 1)
if expected_result.upper() == "FAIL" and result.upper() == "FAIL" and return_code != 0:
@@ -80,7 +82,10 @@ def analyze_result(results, patch, counts, return_code):
counts["error"] = counts["error"] + 1
break
else:
- print ("No test for=%s" % patch["patch"])
+ if return_code != 0:
+ print("patchtest failed before producing results:\n%s" % results.strip())
+ sys.exit(return_code)
+ print("No test for=%s" % patch["patch"])
return counts
@@ -131,12 +136,10 @@ def git_detach_head():
# Once the tests are in oe-core, we can remove the testdir param and use os.path.dirname to get relative paths
def test(root, patch):
- res = True
patchpath = os.path.abspath(os.path.join(root, patch))
-
- cmd = 'patchtest --base-commit HEAD --repodir %s --testdir %s/tests --patch %s' % (repodir, topdir, patchpath)
- results = subprocess.run(cmd, capture_output=True, universal_newlines=True, shell=True)
-
+ cmd = 'patchtest --base-commit HEAD --repodir %s --testdir %s/tests --patch %s' % (repodir, topdir, patchpath)
+ results = subprocess.run(cmd, universal_newlines=True, shell=True,
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
return results.returncode, results.stdout
def test_head_attached(patches, counts, branch):
@@ -171,10 +174,12 @@ def run_tests(patches, counts):
temp_branch = "test_patchtest_head_attached"
git_state = get_git_state()
assert git_state['branch'] != temp_branch, f"Cannot run patchtest selftest while on branch '{temp_branch}'"
- counts = test_head_attached(patches, counts, temp_branch)
- counts = test_head_detached(patches, counts)
- restore_git_state(git_state)
- run_sh(f"git branch -D {temp_branch}")
+ try:
+ counts = test_head_attached(patches, counts, temp_branch)
+ counts = test_head_detached(patches, counts)
+ finally:
+ restore_git_state(git_state)
+ run_sh(f"git branch -D {temp_branch}")
return counts
- Make sure that the selftest doesn't run the full suite and provide useless output if patchtest itself fails. Now we see this sort of message, for example when meta-selftest isn't in bblayers.conf: |(venv) tgamblin@megalith ~/workspace/yocto/openembedded-core (master)$ ./meta/lib/patchtest/selftest/selftest |patchtest failed before producing results: |patchtest: meta-selftest layer not found in /home/tgamblin/workspace/yocto/openembedded-core/build/conf/bblayers.conf - add it to BBLAYERS before running patchtest - If the selftest stops because patchtest does, the branch isn't reset. Make sure this happens. - Adjust the way we parse the resultline content in selftests so that malformed output lines are skipped instead of crashing the selftest script when we split on a ':' character. AI-Generated: Uses Claude Code Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com> --- meta/lib/patchtest/selftest/selftest | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)