* [PATCH] cooker: fix -w with a file name that has no directory
@ 2026-11-14 18:55 Babanpreet Singh
0 siblings, 0 replies; only message in thread
From: Babanpreet Singh @ 2026-11-14 18:55 UTC (permalink / raw)
To: bitbake-devel; +Cc: Mathieu Dubois-Briand, Babanpreet Singh
"bitbake -w events.json" fails with:
FileNotFoundError: [Errno 2] No such file or directory: ''
There is no directory to create for a bare file name, so don't try.
Fixes: ee174b231897 ("cooker: Add support for BB_DEFAULT_EVENTLOG")
Signed-off-by: Babanpreet Singh <bbnpreetsingh@gmail.com>
---
Notes:
Found while looking at YOCTO #16492. Applies with or without Mathieu's
patch for that bug.
lib/bb/cooker.py | 5 +++--
lib/bb/tests/cooker.py | 18 ++++++++++++++++++
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index 8a422e506..f79cd5e6c 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -457,8 +457,9 @@ You can also remove the BB_HASHSERVE_UPSTREAM setting, but this may result in si
if not self.eventlog or self.eventlog[0] != eventlog:
# we log all events to a file if so directed
# register the log file writer as UI Handler
- if not os.path.exists(os.path.dirname(eventlog)):
- bb.utils.mkdirhier(os.path.dirname(eventlog))
+ dirname = os.path.dirname(eventlog)
+ if dirname and not os.path.exists(dirname):
+ bb.utils.mkdirhier(dirname)
writer = EventWriter(self, eventlog)
EventLogWriteHandler = namedtuple('EventLogWriteHandler', ['event'])
self.eventlog = (eventlog, bb.event.register_UIHhandler(EventLogWriteHandler(writer)), writer)
diff --git a/lib/bb/tests/cooker.py b/lib/bb/tests/cooker.py
index db4104d40..c6a0cac2a 100644
--- a/lib/bb/tests/cooker.py
+++ b/lib/bb/tests/cooker.py
@@ -409,3 +409,21 @@ addtask marker
with open(os.path.join(builddir, "marker.log")) as f:
self.assertEqual(f.read(), "bbappend-applied",
"bitbake -b did not apply the recipe's bbappend")
+
+
+class EventLogTest(_BitbakeSubprocessTestCase):
+ """Tests for the event log ("bitbake -w")."""
+
+ _parsetests = os.path.realpath(os.path.join(os.path.dirname(__file__), "parse-tests"))
+
+ def test_write_log_bare_filename(self):
+ """bitbake -w must accept a file name without a directory."""
+ with self._build_dir(prefix="eventlogtest") as builddir:
+ env = os.environ.copy()
+ env["BBPATH"] = self._parsetests
+ env["BB_ENV_PASSTHROUGH_ADDITIONS"] = "TOPDIR"
+ env["TOPDIR"] = builddir
+
+ self._run_subprocess(["bitbake", "-w", "events.json", "-e"], env, builddir)
+
+ self.assertTrue(os.path.exists(os.path.join(builddir, "events.json")))
--
2.43.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-14 18:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-14 18:55 [PATCH] cooker: fix -w with a file name that has no directory Babanpreet Singh
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.