@@ -142,6 +142,14 @@ class BitbakeLayers(OESelftestTestCase):
jsonschema = os.path.join(get_bb_var('COREBASE'), 'meta/files/layers.schema.json')
result = runCmd("{} {} -i {} {}".format(python, jsonvalidator, json, jsonschema))
+ def validate_layerscheckout(self, path):
+ testcheckoutdir = os.path.join(self.builddir, 'test-layer-checkout')
+ result = runCmd('{}/setup-layers --destdir {}'.format(path, testcheckoutdir))
+ # May not necessarily be named 'poky' or 'openembedded-core'
+ oecoredir = os.listdir(testcheckoutdir)[0]
+ testcheckoutfile = os.path.join(testcheckoutdir, oecoredir, "oe-init-build-env")
+ self.assertTrue(os.path.exists(testcheckoutfile), "File {} not found in test layer checkout".format(testcheckoutfile))
+
def test_validate_examplelayersjson(self):
json = os.path.join(get_bb_var('COREBASE'), "meta/files/layers.example.json")
self.validate_layersjson(json)
@@ -161,9 +169,47 @@ class BitbakeLayers(OESelftestTestCase):
with open(jsonfile, 'w') as f:
json.dump(data, f)
- testcheckoutdir = os.path.join(self.builddir, 'test-layer-checkout')
- result = runCmd('{}/setup-layers --destdir {}'.format(self.testlayer_path, testcheckoutdir))
- # May not necessarily be named 'poky' or 'openembedded-core'
- oecoredir = os.listdir(testcheckoutdir)[0]
- testcheckoutfile = os.path.join(testcheckoutdir, oecoredir, "oe-init-build-env")
- self.assertTrue(os.path.exists(testcheckoutfile), "File {} not found in test layer checkout".format(testcheckoutfile))
+ self.validate_layerscheckout(self.testlayer_path)
+
+ def test_bitbakelayers_updatelayer(self):
+ result = runCmd('bitbake-layers create-layers-setup {}'.format(self.testlayer_path))
+ jsonfile = os.path.join(self.testlayer_path, "setup-layers.json")
+ self.validate_layersjson(jsonfile)
+
+ import json
+ with open(jsonfile) as f:
+ data = json.load(f)
+ test_repo = None
+ for s in data['sources']:
+ if 'contains_this_file' not in data['sources'][s].keys():
+ test_repo = s
+ test_rev = data['sources'][s]['git-remote']['rev']
+ test_desc = data['sources'][s]['git-remote']['describe']
+ break
+
+ self.assertTrue(test_repo, "No test repo found")
+
+ result = runCmd('bitbake-layers update-layers-setup {json} {repo} --branch'.format(json=jsonfile, repo=test_repo))
+ self.validate_layersjson(jsonfile)
+
+ with open(jsonfile) as f:
+ data = json.load(f)
+
+ curr_rev = data['sources'][test_repo]['git-remote']['rev']
+ curr_desc = data['sources'][test_repo]['git-remote']['describe']
+
+ self.assertEqual(curr_rev, '', "Revision not cleared: '{}'".format(curr_rev))
+ self.assertEqual(curr_desc, '', "Describe not cleared: '{}'".format(curr_desc))
+
+ self.validate_layerscheckout(self.testlayer_path)
+
+ result = runCmd('bitbake-layers update-layers-setup {json} {repo}'.format(json=jsonfile, repo=test_repo))
+ self.validate_layersjson(jsonfile)
+
+ with open(jsonfile) as f:
+ data = json.load(f)
+
+ curr_rev = data['sources'][test_repo]['git-remote']['rev']
+ curr_desc = data['sources'][test_repo]['git-remote']['describe']
+ self.assertEqual(curr_rev, test_rev, "Revision incorrect: '{}', expected '{}'".format(curr_rev, test_rev))
+ self.assertEqual(curr_desc, test_desc, "Describe incorrect: '{}', expected '{}'".format(curr_desc, test_desc))