oeqa/selftest: add a newline in local.conf (newbuilddir)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 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]
--- meta/lib/oeqa/selftest/context.py | 10 ++++++++++ 1 file changed, 10 insertions(+)
meta/lib/oeqa/selftest/context.py +10 -0
@@ -102,6 +102,16 @@ 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 or does not end with newline then add one + localconf_path = newbuilddir + "/conf/local.conf" + last_line = "" + with open(localconf_path, "r", encoding="utf-8") as f: + for line in f: + last_line = line + + if last_line != "" and not last_line.endswith("\n"): + subprocess.check_output("echo >> %s/conf/local.conf" % newbuilddir, cwd=newbuilddir, shell=True) + 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
Hello,
Quoted 9 lines · Christos Gavros
If the
build-st/conf/local.confdoes not end with a newline when is generated then add one
Fixes [YOCTO #15734]CC Yoann Congal <[email protected]>CC Randy MacLeod <[email protected]>Signed-off-by Christos Gavros <[email protected]>---
Thanks for looking into this!
Quoted 13 lines
meta/lib/oeqa/selftest/context.py | 10 ++++++++++ 1 file changed, 10 insertions(+)meta/lib/oeqa/selftest/context.py +1
-0@@ -102,6 +102,16 @@ 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 or
Quoted 2 lines
does not end with newline then add one
That comment should read "... is not empty AND does not end with newline..." ?
+ localconf_path = newbuilddir + "/conf/local.conf"
Quoted 9 lines
meta/lib/oeqa/selftest/context.py +7
-0+ last_line = "" + with open(localconf_path, "r", encoding="utf-8") as f: + for line in f: + last_line = line + + if last_line != "" and not last_line.endswith("\n"): + subprocess.check_output("echo >> %s/conf/local.conf" %newbuilddir, cwd=newbuilddir, shell=True)
I'm no Python expert but I would simplify by writing the "\n" directly from Python with something like (using the "update" mode "r+"):
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")
Also, I find using None instead of "" better to mean "missing value"
Quoted 10 lines
meta/lib/oeqa/selftest/context.py +1
-1+ 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 recipeparsing and hence is too slow
--
2.34.1
Regards,
Signature · 2 lines
Yoann Congal Smile ECS - Tech expert
hi
I will change the comment.
Regarding 'None'(NoneType) and ""(str) , I don't see any significant difference here but it can be changed.
I considered "f.write" and is simpler as you said but lower in "context.py" is used subprocess to write SSTATE_DIR and I thought of using the same to keep consistency.
I will wait a bit to see if someone else will comment something and I will submit v2.
Br
Christos