summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tests
diff options
context:
space:
mode:
authorChristopher Larson <kergoth@gmail.com>2017-05-13 02:46:29 +0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-06-02 13:36:57 +0100
commitbf87c5cd194b5a24c388d6445b413b5f673bc1de (patch)
treebeef4530468ec0502c43a8692b0127fb613e2a4b /bitbake/lib/bb/tests
parent27d56982c7ba05e86a100b0cca2411ee5ac7a85e (diff)
downloadpoky-bf87c5cd194b5a24c388d6445b413b5f673bc1de.tar.gz
bitbake: fetch/git: support per-branch/per-url depths for shallow
Allow the user to explicitly adjust the depth for named urls/branches. The un-suffixed BB_GIT_SHALLOW_DEPTH is used as the default. Example usage: BB_GIT_SHALLOW_DEPTH = "1" BB_GIT_SHALLOW_DEPTH_doc = "0" BB_GIT_SHALLOW_DEPTH_meta = "0" (Bitbake rev: 9dfc517e5bcc6dd203a0ad685cc884676d2984c4) Signed-off-by: Christopher Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/tests')
-rw-r--r--bitbake/lib/bb/tests/fetch.py35
1 files changed, 33 insertions, 2 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index 019f22a11d..0b0116b455 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -1122,6 +1122,27 @@ class GitShallowTest(FetcherTest):
1122 self.fetch_shallow(disabled=True) 1122 self.fetch_shallow(disabled=True)
1123 self.assertRevCount(2) 1123 self.assertRevCount(2)
1124 1124
1125 def test_shallow_depth_default_override(self):
1126 self.add_empty_file('a')
1127 self.add_empty_file('b')
1128 self.assertRevCount(2, cwd=self.srcdir)
1129
1130 self.d.setVar('BB_GIT_SHALLOW_DEPTH', '2')
1131 self.d.setVar('BB_GIT_SHALLOW_DEPTH_default', '1')
1132 self.fetch_shallow()
1133 self.assertRevCount(1)
1134
1135 def test_shallow_depth_default_override_disable(self):
1136 self.add_empty_file('a')
1137 self.add_empty_file('b')
1138 self.add_empty_file('c')
1139 self.assertRevCount(3, cwd=self.srcdir)
1140
1141 self.d.setVar('BB_GIT_SHALLOW_DEPTH', '0')
1142 self.d.setVar('BB_GIT_SHALLOW_DEPTH_default', '2')
1143 self.fetch_shallow()
1144 self.assertRevCount(2)
1145
1125 def test_current_shallow_out_of_date_clone(self): 1146 def test_current_shallow_out_of_date_clone(self):
1126 # Create initial git repo 1147 # Create initial git repo
1127 self.add_empty_file('a') 1148 self.add_empty_file('a')
@@ -1206,13 +1227,15 @@ class GitShallowTest(FetcherTest):
1206 uri = self.d.getVar('SRC_URI', True).split()[0] 1227 uri = self.d.getVar('SRC_URI', True).split()[0]
1207 uri = '%s;branch=master,a_branch;name=master,a_branch' % uri 1228 uri = '%s;branch=master,a_branch;name=master,a_branch' % uri
1208 1229
1209 self.d.setVar('BB_GIT_SHALLOW_DEPTH', '2') 1230 self.d.setVar('BB_GIT_SHALLOW_DEPTH', '0')
1231 self.d.setVar('BB_GIT_SHALLOW_DEPTH_master', '3')
1232 self.d.setVar('BB_GIT_SHALLOW_DEPTH_a_branch', '1')
1210 self.d.setVar('SRCREV_master', '${AUTOREV}') 1233 self.d.setVar('SRCREV_master', '${AUTOREV}')
1211 self.d.setVar('SRCREV_a_branch', '${AUTOREV}') 1234 self.d.setVar('SRCREV_a_branch', '${AUTOREV}')
1212 1235
1213 self.fetch_shallow(uri) 1236 self.fetch_shallow(uri)
1214 1237
1215 self.assertRevCount(3, ['--all']) 1238 self.assertRevCount(4, ['--all'])
1216 self.assertRefs(['master', 'origin/master', 'origin/a_branch']) 1239 self.assertRefs(['master', 'origin/master', 'origin/a_branch'])
1217 1240
1218 def test_shallow_clone_preferred_over_shallow(self): 1241 def test_shallow_clone_preferred_over_shallow(self):
@@ -1262,6 +1285,14 @@ class GitShallowTest(FetcherTest):
1262 with self.assertRaises(bb.fetch2.FetchError): 1285 with self.assertRaises(bb.fetch2.FetchError):
1263 self.fetch() 1286 self.fetch()
1264 1287
1288 def test_shallow_invalid_depth_default(self):
1289 self.add_empty_file('a')
1290 self.add_empty_file('b')
1291
1292 self.d.setVar('BB_GIT_SHALLOW_DEPTH_default', '-12')
1293 with self.assertRaises(bb.fetch2.FetchError):
1294 self.fetch()
1295
1265 if os.environ.get("BB_SKIP_NETTESTS") == "yes": 1296 if os.environ.get("BB_SKIP_NETTESTS") == "yes":
1266 print("Unset BB_SKIP_NETTESTS to run network tests") 1297 print("Unset BB_SKIP_NETTESTS to run network tests")
1267 else: 1298 else: