diff mbox series

[v2,2/2] oeqa/selftest/devtool: exercise devtool finish on an AUTOREV recipe

Message ID 20260714032029.7-2-bbnpreetsingh@gmail.com
State Under Review
Headers show
Series [v2,1/2] devtool: standard: fix finish/update-recipe for recipes using AUTOREV | expand

Commit Message

Babanpreet Singh July 14, 2026, 3:20 a.m. UTC
Adjust test_devtool_add_fetch_git() so that the recipe it creates with
SRCREV = "${AUTOREV}" is finished into a temporary layer instead of
just being reset: check that devtool finish succeeds (before the
previous commit srcrev mode failed with "fatal: bad revision
'AUTOINC'"), that the finished recipe still uses SRCREV = "${AUTOREV}",
and that no spurious patch files are generated. The reset it replaces
is covered by many other devtool tests.

srcrev mode is forced with --mode srcrev: update-mode guessing only
considers git:// URLs, so for this gitsm:// recipe auto mode would
select patch mode and never reach the code path being tested.

[YOCTO #16354]

Cc: Alexander Kanavin <alex.kanavin@gmail.com>
AI-Generated: Uses Claude (claude-sonnet-5)
Signed-off-by: Babanpreet Singh <bbnpreetsingh@gmail.com>
---
changes in v2:
- extend the existing test_devtool_add_fetch_git() instead of
  adding a new test (Alexander Kanavin)
- force --mode srcrev in the test: update-mode guessing never
  selects srcrev for the gitsm:// URL used there (verified the
  adjusted test passes with the fix reverted if the mode is not
  forced, i.e. it would not catch the bug)
 meta/lib/oeqa/selftest/cases/devtool.py | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/meta/lib/oeqa/selftest/cases/devtool.py b/meta/lib/oeqa/selftest/cases/devtool.py
index b2cd13e9a5..51f9d6f8b7 100644
--- a/meta/lib/oeqa/selftest/cases/devtool.py
+++ b/meta/lib/oeqa/selftest/cases/devtool.py
@@ -613,8 +613,27 @@  class DevtoolAddTests(DevtoolBase):
         checkvars['SRC_URI'] = url_branch
         checkvars['SRCREV'] = '${AUTOREV}'
         self._test_recipe_contents(recipefile, checkvars, [])
+        # Finish into a temporary layer instead of resetting; srcrev mode
+        # 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]. srcrev mode has to be forced
+        # because update-mode guessing never selects it for gitsm:// URLs.
+        templayerdir = tempfile.mkdtemp(prefix='devtoolqa')
+        self.track_for_cleanup(templayerdir)
+        self._create_temp_layer(templayerdir, False, 'selftestautorev')
+        result = runCmd('devtool finish --mode srcrev %s %s' % (testrecipe, templayerdir))
+        result = runCmd('devtool status')
+        self.assertNotIn(testrecipe, result.output, 'Recipe should have been removed from workspace by devtool finish')
+        newrecipefiles = glob.glob(os.path.join(templayerdir, 'recipes-*', testrecipe, '%s_git.bb' % testrecipe))
+        self.assertEqual(len(newrecipefiles), 1, 'Recipe not moved into destination layer by devtool finish')
+        # The finished 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-*', testrecipe, '*', '*.patch'))
+        self.assertEqual(patchfiles, [], 'Unexpected patch files generated by devtool finish')
         # Try with revision and version specified
-        result = runCmd('devtool reset -n %s' % testrecipe)
         shutil.rmtree(srcdir)
         url_rev = '%s;rev=%s' % (url, checkrev)
         result = runCmd('devtool add %s %s -f "%s" -V 1.5' % (testrecipe, srcdir, url_rev))