oe-selftest: devtool: fix test_devtool_update_recipe_git

Make this test work after recent changes to the mtd-utils recipe, and
hopefully make it robust against any future changes.

(From OE-Core rev: 5be62624a6537659f9f6229c82762da45909f902)

(From OE-Core rev: fd4b4390af0bcbfdaee0d4ddbc6766d7775c52d0)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Paul Eggleton
2015-04-27 10:53:15 +01:00
committed by Richard Purdie
parent 2468978cb4
commit 08607f7864

View File

@@ -370,6 +370,11 @@ class DevtoolTests(oeSelfTest):
recipefile = get_bb_var('FILE', testrecipe)
src_uri = get_bb_var('SRC_URI', testrecipe)
self.assertIn('git://', src_uri, 'This test expects the %s recipe to be a git recipe' % testrecipe)
patches = []
for entry in src_uri.split():
if entry.startswith('file://') and entry.endswith('.patch'):
patches.append(entry[7:].split(';')[0])
self.assertGreater(len(patches), 0, 'The %s recipe does not appear to contain any patches, so this test will not be effective' % testrecipe)
result = runCmd('git status . --porcelain', cwd=os.path.dirname(recipefile))
self.assertEqual(result.output.strip(), "", '%s recipe is not clean' % testrecipe)
# First, modify a recipe
@@ -397,19 +402,22 @@ class DevtoolTests(oeSelfTest):
result = runCmd('git status . --porcelain', cwd=os.path.dirname(recipefile))
self.assertNotEqual(result.output.strip(), "", '%s recipe should be modified' % testrecipe)
status = result.output.splitlines()
self.assertEqual(len(status), 3, 'Less/more files modified than expected. Entire status:\n%s' % result.output)
for line in status:
if line.endswith('add-exclusion-to-mkfs-jffs2-git-2.patch'):
self.assertEqual(line[:3], ' D ', 'Unexpected status in line: %s' % line)
elif line.endswith('fix-armv7-neon-alignment.patch'):
self.assertEqual(line[:3], ' D ', 'Unexpected status in line: %s' % line)
elif re.search('%s_[^_]*.bb$' % testrecipe, line):
self.assertEqual(line[:3], ' M ', 'Unexpected status in line: %s' % line)
for patch in patches:
if line.endswith(patch):
self.assertEqual(line[:3], ' D ', 'Unexpected status in line: %s' % line)
break
else:
raise AssertionError('Unexpected modified file in status: %s' % line)
if re.search('%s_[^_]*.bb$' % testrecipe, line):
self.assertEqual(line[:3], ' M ', 'Unexpected status in line: %s' % line)
else:
raise AssertionError('Unexpected modified file in status: %s' % line)
result = runCmd('git diff %s' % os.path.basename(recipefile), cwd=os.path.dirname(recipefile))
addlines = ['SRCREV = ".*"', 'SRC_URI = "git://git.infradead.org/mtd-utils.git"']
removelines = ['SRCREV = ".*"', 'SRC_URI = "git://git.infradead.org/mtd-utils.git \\\\', 'file://add-exclusion-to-mkfs-jffs2-git-2.patch \\\\', 'file://fix-armv7-neon-alignment.patch \\\\', '"']
srcurilines = src_uri.split()
srcurilines[0] = 'SRC_URI = "' + srcurilines[0]
srcurilines.append('"')
removelines = ['SRCREV = ".*"'] + srcurilines
for line in result.output.splitlines():
if line.startswith('+++') or line.startswith('---'):
continue