summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Hoyes <Peter.Hoyes@arm.com>2023-06-16 13:36:49 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-06-27 15:28:56 +0100
commit8b0fc4850dc31bb7e7be0001414468b1d3f80846 (patch)
treeac11c4c538f578e219297344c9dfea52f87d568b
parentbaf345598d147fa798e4b1dd20992f8bed0a5c0e (diff)
downloadpoky-8b0fc4850dc31bb7e7be0001414468b1d3f80846.tar.gz
bitbake: bitbake: tests/fetch: Set git config if not already set
git config returns an error code if user.email or user.name are not set, so bb.process.run raises an ExecutionError, failing the test. Improve the logic by catching the ExectionError and using this to set a default value. Change a direct invocation of 'git init' to use self.git_init so that it follows the code path above. Remove the related comment from the README now that git sets up the user details automatically. (Bitbake rev: 0c7079d0609a13713b890a9675abd9fba032f199) Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/README3
-rw-r--r--bitbake/lib/bb/tests/fetch.py12
2 files changed, 10 insertions, 5 deletions
diff --git a/bitbake/README b/bitbake/README
index a5f5c1b64f..bdb1e81dc1 100644
--- a/bitbake/README
+++ b/bitbake/README
@@ -45,8 +45,7 @@ it has so many corner cases. The datastore has many tests too. Testing with the
45recommended before submitting patches, particularly to the fetcher and datastore. We also 45recommended before submitting patches, particularly to the fetcher and datastore. We also
46appreciate new test cases and may require them for more obscure issues. 46appreciate new test cases and may require them for more obscure issues.
47 47
48To run the tests "zstd" and "git" must be installed. Git must be correctly configured, in 48To run the tests "zstd" and "git" must be installed.
49particular the user.email and user.name values must be set.
50 49
51The assumption is made that this testsuite is run from an initialized OpenEmbedded build 50The assumption is made that this testsuite is run from an initialized OpenEmbedded build
52environment (i.e. `source oe-init-build-env` is used). If this is not the case, run the 51environment (i.e. `source oe-init-build-env` is used). If this is not the case, run the
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index 871c174e82..8ca7e6c155 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -429,9 +429,15 @@ class FetcherTest(unittest.TestCase):
429 # a common setup is to use other default 429 # a common setup is to use other default
430 # branch than master. 430 # branch than master.
431 self.git(['checkout', '-b', 'master'], cwd=cwd) 431 self.git(['checkout', '-b', 'master'], cwd=cwd)
432 if not self.git(['config', 'user.email'], cwd=cwd): 432
433 try:
434 self.git(['config', 'user.email'], cwd=cwd)
435 except bb.process.ExecutionError:
433 self.git(['config', 'user.email', 'you@example.com'], cwd=cwd) 436 self.git(['config', 'user.email', 'you@example.com'], cwd=cwd)
434 if not self.git(['config', 'user.name'], cwd=cwd): 437
438 try:
439 self.git(['config', 'user.name'], cwd=cwd)
440 except bb.process.ExecutionError:
435 self.git(['config', 'user.name', 'Your Name'], cwd=cwd) 441 self.git(['config', 'user.name', 'Your Name'], cwd=cwd)
436 442
437class MirrorUriTest(FetcherTest): 443class MirrorUriTest(FetcherTest):
@@ -3038,7 +3044,7 @@ class FetchPremirroronlyLocalTest(FetcherTest):
3038 self.mirrorname = "git2_git.fake.repo.bitbake.tar.gz" 3044 self.mirrorname = "git2_git.fake.repo.bitbake.tar.gz"
3039 recipeurl = "git:/git.fake.repo/bitbake" 3045 recipeurl = "git:/git.fake.repo/bitbake"
3040 os.makedirs(self.gitdir) 3046 os.makedirs(self.gitdir)
3041 self.git("init", self.gitdir) 3047 self.git_init(cwd=self.gitdir)
3042 for i in range(0): 3048 for i in range(0):
3043 self.git_new_commit() 3049 self.git_new_commit()
3044 bb.process.run('tar -czvf {} .'.format(os.path.join(self.mirrordir, self.mirrorname)), cwd = self.gitdir) 3050 bb.process.run('tar -czvf {} .'.format(os.path.join(self.mirrordir, self.mirrorname)), cwd = self.gitdir)