diff mbox series

[03/10] bitbake-setup: test after every update that config hasn't changed

Message ID 20260102193438.2960561-3-alex.kanavin@gmail.com
State New
Headers show
Series [01/10] bitbake-setup: move the local source tests to the end | expand

Commit Message

Alexander Kanavin Jan. 2, 2026, 7:34 p.m. UTC
From: Alexander Kanavin <alex@linutronix.de>

This would catch situations where update hasn't run through to
completion even though bitbake-setup finished without error,
such as the one fixed in the previous commit.

Also unset BBPATH from environment so that it doesn't leak out
of the function where it's used. Adjust buildtools test to pass
setup dir explicitly, as it was previously relying on BBPATH being set.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 lib/bb/tests/setup.py | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/lib/bb/tests/setup.py b/lib/bb/tests/setup.py
index ad09913f4..55e9e50ec 100644
--- a/lib/bb/tests/setup.py
+++ b/lib/bb/tests/setup.py
@@ -180,6 +180,14 @@  print("BBPATH is {{}}".format(os.environ["BBPATH"]))
         self.git('add {}'.format(name), cwd=self.testrepopath)
         self.git('commit -m "Adding {}"'.format(name), cwd=self.testrepopath)
 
+    def config_is_unchanged(self, setuppath):
+        os.environ['BBPATH'] = os.path.join(setuppath, 'build')
+        out = self.runbbsetup("status")
+        self.assertIn("Configuration in {} has not changed".format(setuppath), out[0])
+        out = self.runbbsetup("update --update-bb-conf='yes'")
+        self.assertIn("Configuration in {} has not changed".format(setuppath), out[0])
+        del os.environ['BBPATH']
+
     def check_setupdir_files(self, setuppath, test_file_content):
         with open(os.path.join(setuppath, 'config', "config-upstream.json")) as f:
             config_upstream = json.load(f)
@@ -228,6 +236,8 @@  print("BBPATH is {{}}".format(os.environ["BBPATH"]))
             self.assertTrue('BUILD_SERVER' in init_build_env)
             # a more throrough test could be to initialize a bitbake build-env, export FOO to the shell environment, set the env-passthrough on it and finally check against 'bitbake-getvar FOO'
 
+        self.config_is_unchanged(setuppath)
+
     def get_setup_path(self, cf, c):
         if c == 'gizmo':
             return os.path.join(self.tempdir, 'bitbake-builds', 'this-is-a-custom-gizmo-build')
@@ -314,14 +324,9 @@  print("BBPATH is {{}}".format(os.environ["BBPATH"]))
                 out = self.runbbsetup("init --non-interactive {} {}".format(v['cmdline'], c))
                 setuppath = self.get_setup_path(cf, c)
                 self.check_setupdir_files(setuppath, test_file_content)
-                os.environ['BBPATH'] = os.path.join(setuppath, 'build')
-                out = self.runbbsetup("status")
-                self.assertIn("Configuration in {} has not changed".format(setuppath), out[0])
-                out = self.runbbsetup("update --update-bb-conf='yes'")
-                self.assertIn("Configuration in {} has not changed".format(setuppath), out[0])
 
         # install buildtools
-        out = self.runbbsetup("install-buildtools")
+        out = self.runbbsetup("install-buildtools --setup-dir {}".format(setuppath))
         self.assertIn("Buildtools installed into", out[0])
         self.assertTrue(os.path.exists(os.path.join(setuppath, 'buildtools')))