Browse Source

meta-selftest: add test for .patch file with long filename and without subject

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Martin Jansa 4 years ago
parent
commit
7c3e17f34c

+ 9 - 0
meta-selftest/recipes-test/devtool/devtool-test-long-filename.bb

@@ -0,0 +1,9 @@
+LICENSE = "CLOSED"
+INHIBIT_DEFAULT_DEPS = "1"
+
+SRC_URI = "file://${BPN}.tar.gz \
+           file://0001-I-ll-patch-you-only-if-devtool-lets-me-to-do-it-corr.patch"
+
+S = "${WORKDIR}/${BPN}"
+
+EXCLUDE_FROM_WORLD = "1"

+ 7 - 0
meta-selftest/recipes-test/devtool/devtool-test-long-filename/0001-I-ll-patch-you-only-if-devtool-lets-me-to-do-it-corr.patch

@@ -0,0 +1,7 @@
+diff --git a/patch-me b/patch-me
+index a20b29a..5e35d1b 100644
+--- a/patch-me
++++ b/patch-me
+@@ -1 +1 @@
+-please
++NO

+ 16 - 0
meta-selftest/recipes-test/devtool/devtool-test-long-filename/0001-I-ll-patch-you-only-if-devtool-lets-me-to-do-it-corr.patch.expected

@@ -0,0 +1,16 @@
+From 45ba3d107ea60777a6b6e134fd00fe5009749177 Mon Sep 17 00:00:00 2001
+From: Martin Jansa <Martin.Jansa@gmail.com>
+Date: Thu, 28 May 2020 02:03:39 +0200
+Subject: [PATCH] meta-selftest: add test for .patch file with long filename
+
+---
+ patch-me | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/patch-me b/patch-me
+index a20b29a..5e35d1b 100644
+--- a/patch-me
++++ b/patch-me
+@@ -1 +1 @@
+-please
++NO

BIN
meta-selftest/recipes-test/devtool/devtool-test-long-filename/devtool-test-long-filename.tar.gz


+ 27 - 0
meta/lib/oeqa/selftest/cases/devtool.py

@@ -1134,6 +1134,33 @@ class DevtoolUpdateTests(DevtoolBase):
         # devtool-test-ignored manually, then it should generate exactly the same .patch file
         self.assertEqual(desiredlines[5:], newlines[5:])
 
+    def test_devtool_update_recipe_long_filename(self):
+        # First, modify the recipe
+        testrecipe = 'devtool-test-long-filename'
+        bb_vars = get_bb_vars(['FILE'], testrecipe)
+        recipefile = bb_vars['FILE']
+        patchfilename = '0001-I-ll-patch-you-only-if-devtool-lets-me-to-do-it-corr.patch'
+        patchfile = os.path.join(os.path.dirname(recipefile), testrecipe, patchfilename)
+        newpatchfile = os.path.join(os.path.dirname(recipefile), testrecipe, patchfilename + '.expected')
+        tempdir = tempfile.mkdtemp(prefix='devtoolqa')
+        self.track_for_cleanup(tempdir)
+        self.track_for_cleanup(self.workspacedir)
+        self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
+        # (don't bother with cleaning the recipe on teardown, we won't be building it)
+        result = runCmd('devtool modify %s' % testrecipe)
+        self.add_command_to_tearDown('cd %s; rm %s/*; git checkout %s %s' % (os.path.dirname(recipefile), testrecipe, testrecipe, os.path.basename(recipefile)))
+        result = runCmd('devtool finish --force-patch-refresh %s meta-selftest' % testrecipe)
+        # Check recipe got changed as expected
+        with open(newpatchfile, 'r') as f:
+            desiredlines = f.readlines()
+        with open(patchfile, 'r') as f:
+            newlines = f.readlines()
+        # Ignore the initial lines, because oe-selftest creates own meta-selftest repo
+        # which changes the metadata subject which is added into the patch, but keep
+        # .patch.expected as it is in case someone runs devtool finish --force-patch-refresh
+        # devtool-test-ignored manually, then it should generate exactly the same .patch file
+        self.assertEqual(desiredlines[5:], newlines[5:])
+
     def test_devtool_update_recipe_local_files_3(self):
         # First, modify the recipe
         testrecipe = 'devtool-test-localonly'