Add a test checking that a recipe created with devtool add --autorev
can be finished into a layer, that the finished recipe still uses
SRCREV = "${AUTOREV}", and that no spurious patch files are generated.

Before the previous commit, devtool finish failed on such recipes with:

    fatal: bad revision 'AUTOINC'

Test requested by Randy MacLeod in the bug report.

[YOCTO #16354]

AI-Generated: Uses Claude (claude-sonnet-5)
Signed-off-by: Babanpreet Singh <[email protected]>
---
 meta/lib/oeqa/selftest/cases/devtool.py | 32 +++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/meta/lib/oeqa/selftest/cases/devtool.py 
b/meta/lib/oeqa/selftest/cases/devtool.py
index b2cd13e9a5..a3c7c293c5 100644
--- a/meta/lib/oeqa/selftest/cases/devtool.py
+++ b/meta/lib/oeqa/selftest/cases/devtool.py
@@ -469,6 +469,38 @@ class DevtoolAddTests(DevtoolBase):
         checkvars['DEPENDS'] = set(['dbus'])
         self._test_recipe_contents(recipefile, checkvars, [])
 
+    def test_devtool_add_git_autorev_finish(self):
+        # Test that a recipe created by devtool add --autorev can be finished
+        # into a layer; this used to fail with "fatal: bad revision 'AUTOINC'"
+        # because the unresolved AUTOREV placeholder was used as the git
+        # revision to export patches from [YOCTO #16354]
+        pn = 'dbus-wait'
+        url = 
'git://git.yoctoproject.org/dbus-wait;protocol=https;branch=master'
+        self.track_for_cleanup(self.workspacedir)
+        self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
+        result = runCmd("devtool add --autorev %s '%s'" % (pn, url))
+        recipefile = os.path.join(self.workspacedir, 'recipes', pn, 
'%s_git.bb' % pn)
+        self.assertExists(recipefile, 'Recipe not created by devtool add')
+        checkvars = {}
+        checkvars['SRCREV'] = '${AUTOREV}'
+        self._test_recipe_contents(recipefile, checkvars, [])
+        # Finish the recipe into a temporary layer
+        templayerdir = tempfile.mkdtemp(prefix='devtoolqa')
+        self.track_for_cleanup(templayerdir)
+        self._create_temp_layer(templayerdir, False, 'selftestautorev')
+        result = runCmd('devtool finish %s %s' % (pn, templayerdir))
+        result = runCmd('devtool status')
+        self.assertNotIn(pn, result.output, 'Recipe should have been reset by 
finish but wasn\'t')
+        newrecipefiles = glob.glob(os.path.join(templayerdir, 'recipes-*', pn, 
'%s_git.bb' % pn))
+        self.assertEqual(len(newrecipefiles), 1, 'Recipe not moved into 
destination layer by devtool finish')
+        # The recipe should still use a floating revision and no patch
+        # files should have been created
+        checkvars = {}
+        checkvars['SRCREV'] = '${AUTOREV}'
+        self._test_recipe_contents(newrecipefiles[0], checkvars, [])
+        patchfiles = glob.glob(os.path.join(templayerdir, 'recipes-*', pn, 
'*', '*.patch'))
+        self.assertEqual(patchfiles, [], 'Unexpected patch files generated by 
devtool finish')
+
     def test_devtool_add_git_style1(self):
         version = 'v3.1.0'
         pn = 'mbedtls'
-- 
2.43.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#240827): 
https://lists.openembedded.org/g/openembedded-core/message/240827
Mute This Topic: https://lists.openembedded.org/mt/120245027/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to