Skip to contentSkip to conversation

oeqa/selftest: add a newline in local.conf (newbuilddir)

PATCH Superseded Christos Gavros 3 participants 3 messages Feb 25, 2025 1 message not in the archive

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH v2 1/1 oeqa/selftest: add a newline in local.conf (newbuilddir)

If the build-st/conf/local.conf does not end with a newline when is generated then add one
Fixes [YOCTO #15734]

---
v1->v2
* the comment is changed
* last_line is initialized to "None"
* add a new line by using f.write("\n")

---
 meta/lib/oeqa/selftest/context.py | 9 +++++++++
 1 file changed, 9 insertions(+)
meta/lib/oeqa/selftest/context.py +9 -0
index 5eb4cc44fd..9145cbd72b 100644
@@ -102,6 +102,15 @@ class OESelftestTestContext(OETestContext):
         oe.path.copytree(builddir + "/cache", newbuilddir + "/cache")
         oe.path.copytree(selftestdir, newselftestdir)
 
+        # if the last line of local.conf in newbuilddir is not empty and does not end with newline then add one
+        localconf_path = newbuilddir + "/conf/local.conf"
+        with open(localconf_path, "r+", encoding="utf-8") as f:
+            last_line = None
+            for line in f:
+                last_line = line
+            if last_line and not last_line.endswith("\n"):
+                f.write("\n")
+
         subprocess.check_output("git init && git add * && git commit -a -m 'initial'", cwd=newselftestdir, shell=True)
 
         # Tried to used bitbake-layers add/remove but it requires recipe parsing and hence is too slow
Signature · 1 line
2.34.1
#2 lore raw

meta/lib/oeqa/selftest/context.py class OESelftestTestContext(OETestContext): · line 110

Quoted 6 lines · Christos Gavros via lists.openembedded.org
meta/lib/oeqa/selftest/context.py +6 -0
+        # if the last line of local.conf in newbuilddir is not empty and does not end with newline then add one
+        localconf_path = newbuilddir + "/conf/local.conf"
+        with open(localconf_path, "r+", encoding="utf-8") as f:
+            last_line = None
+            for line in f:
+                last_line = line

You can replace this with 'last_line = f.readlines()[-1]'.

Alex

#3 lore raw
In reply to Christos Gavros

Hello Chistos,

Quoted 7 lines · Christos Gavros

If the build-st/conf/local.conf does not end with a newline when is generated then add one
Fixes [YOCTO #15734]

FYI, you can't add a Reviewed-by from someone without an explicit email (Often stating the full line "Reviewed-by: Xxx Yyy <...@...>"). On your v1, I merely commented, that is not sufficient for adding my reviewed-by.

Quoted 37 lines

---
v1->v2
* the comment is changed
* last_line is initialized to "None"
* add a new line by using f.write("\n")

---
 meta/lib/oeqa/selftest/context.py | 9 +++++++++
 1 file changed, 9 insertions(+)
meta/lib/oeqa/selftest/context.py +1 -0
index 5eb4cc44fd..9145cbd72b 100644
@@ -102,6 +102,15 @@ class OESelftestTestContext(OETestContext):
         oe.path.copytree(builddir + "/cache", newbuilddir + "/cache")
         oe.path.copytree(selftestdir, newselftestdir)
 
+        # if the last line of local.conf in newbuilddir is not empty and

does not end with newline then add one

meta/lib/oeqa/selftest/context.py +8 -1
+        localconf_path = newbuilddir + "/conf/local.conf"
+        with open(localconf_path, "r+", encoding="utf-8") as f:
+            last_line = None
+            for line in f:
+                last_line = line
+            if last_line and not last_line.endswith("\n"):
+                f.write("\n")
+
         subprocess.check_output("git init && git add * && git commit -a
-m 'initial'", cwd=newselftestdir, shell=True)
 
         # Tried to used bitbake-layers add/remove but it requires recipe

parsing and hence is too slow
--
2.34.1

Signature · 2 lines
Yoann Congal
Smile ECS - Tech expert