diff mbox series

oeqa devtool: Add tests to cover devtool handling of various git URL styles

Message ID 20220725105407.79478-1-throos@amazon.de
State New
Headers show
Series oeqa devtool: Add tests to cover devtool handling of various git URL styles | expand

Commit Message

Roos, Thomas July 25, 2022, 10:54 a.m. UTC
Add two test cases for git URL styles that trigger reformat_git_url.

[YOCTO #11394]

Signed-off-by: Thomas Roos <throos@amazon.de>
---
 meta/lib/oeqa/selftest/cases/devtool.py | 55 ++++++++++++++++++++++++-
 1 file changed, 54 insertions(+), 1 deletion(-)

Comments

Richard Purdie July 25, 2022, 11:18 a.m. UTC | #1
On Mon, 2022-07-25 at 12:54 +0200, Thomas Roos via
lists.openembedded.org wrote:
> Add two test cases for git URL styles that trigger reformat_git_url.
> 
> [YOCTO #11394]
> 
> Signed-off-by: Thomas Roos <throos@amazon.de>
> ---
>  meta/lib/oeqa/selftest/cases/devtool.py | 55 ++++++++++++++++++++++++-
>  1 file changed, 54 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/lib/oeqa/selftest/cases/devtool.py b/meta/lib/oeqa/selftest/cases/devtool.py
> index 34fc791f3a..dc3c4fba65 100644
> --- a/meta/lib/oeqa/selftest/cases/devtool.py
> +++ b/meta/lib/oeqa/selftest/cases/devtool.py
> @@ -379,6 +379,59 @@ class DevtoolAddTests(DevtoolBase):
>          checkvars['SRCREV'] = srcrev
>          checkvars['DEPENDS'] = set(['dbus'])
>          self._test_recipe_contents(recipefile, checkvars, [])
> +    
> +    def test_devtool_add_git_style_1(self):
> +         # this will trigger reformat_git_uri
> +        url = "'git://git@github.com/ARMmbed/mbedtls.git;protocol=https'"
> +        version = 'v3.1.0'
> +        pn = 'mbedtls'
> +        # Test devtool add
> +        self.track_for_cleanup(self.workspacedir)
> +        self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')        
> +        result = runCmd('devtool add --version %s %s %s' % (version, pn, url))
> +        self.assertExists(os.path.join(self.workspacedir, 'conf', 'layer.conf'), 'Workspace directory not created')
> +        # Check the recipe name is correct
> +        recipefile = get_bb_var('FILE', pn)
> +        self.assertIn('%s_git.bb' % pn, recipefile, 'Recipe file incorrectly named')
> +        self.assertIn(recipefile, result.output)
> +        # Test devtool status
> +        result = runCmd('devtool status')
> +        self.assertIn(pn, result.output)
> +        self.assertIn(recipefile, result.output)
> +        checkvars = {}
> +        checkvars['LICENSE'] = 'Apache-2.0'
> +        checkvars['LIC_FILES_CHKSUM'] = 'file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57'
> +        checkvars['S'] = '${WORKDIR}/git'
> +        checkvars['PV'] = 'v3.1.0+git${SRCPV}'
> +        checkvars['SRC_URI'] = 'git://git@github.com/ARMmbed/mbedtls.git;protocol=https;branch=master'
> +        self._test_recipe_contents(recipefile, checkvars, [])
> +
> +    def test_devtool_add_git_style_2(self):
> +         # this will trigger reformat_git_uri with branch parameter in url
> +        url = "'git://git@github.com/ARMmbed/mbedtls.git;branch=mbedtls-2.28;protocol=https'"
> +        version = 'v3.1.0'
> +        pn = 'mbedtls'
> +        # Test devtool add
> +        self.track_for_cleanup(self.workspacedir)
> +        self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')        
> +        result = runCmd('devtool add --version %s %s %s' % (version, pn, url))
> +        self.assertExists(os.path.join(self.workspacedir, 'conf', 'layer.conf'), 'Workspace directory not created')
> +        # Check the recipe name is correct
> +        recipefile = get_bb_var('FILE', pn)
> +        self.assertIn('%s_git.bb' % pn, recipefile, 'Recipe file incorrectly named')
> +        self.assertIn(recipefile, result.output)
> +        # Test devtool status
> +        result = runCmd('devtool status')
> +        self.assertIn(pn, result.output)
> +        self.assertIn(recipefile, result.output)
> +        checkvars = {}
> +        checkvars['LICENSE'] = 'Apache-2.0'
> +        checkvars['LIC_FILES_CHKSUM'] = 'file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57'
> +        checkvars['S'] = '${WORKDIR}/git'
> +        checkvars['PV'] = 'v3.1.0+git${SRCPV}'
> +        checkvars['SRC_URI'] = 'git://git@github.com/ARMmbed/mbedtls.git;branch=mbedtls-2.28;protocol=https'
> +        self._test_recipe_contents(recipefile, checkvars, [])
> +


Rather than copy and paste the test, could you parameterise it please?
That should make it clearer what is being tested and why too.

Cheers,

Richard
diff mbox series

Patch

diff --git a/meta/lib/oeqa/selftest/cases/devtool.py b/meta/lib/oeqa/selftest/cases/devtool.py
index 34fc791f3a..dc3c4fba65 100644
--- a/meta/lib/oeqa/selftest/cases/devtool.py
+++ b/meta/lib/oeqa/selftest/cases/devtool.py
@@ -379,6 +379,59 @@  class DevtoolAddTests(DevtoolBase):
         checkvars['SRCREV'] = srcrev
         checkvars['DEPENDS'] = set(['dbus'])
         self._test_recipe_contents(recipefile, checkvars, [])
+    
+    def test_devtool_add_git_style_1(self):
+         # this will trigger reformat_git_uri
+        url = "'git://git@github.com/ARMmbed/mbedtls.git;protocol=https'"
+        version = 'v3.1.0'
+        pn = 'mbedtls'
+        # Test devtool add
+        self.track_for_cleanup(self.workspacedir)
+        self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')        
+        result = runCmd('devtool add --version %s %s %s' % (version, pn, url))
+        self.assertExists(os.path.join(self.workspacedir, 'conf', 'layer.conf'), 'Workspace directory not created')
+        # Check the recipe name is correct
+        recipefile = get_bb_var('FILE', pn)
+        self.assertIn('%s_git.bb' % pn, recipefile, 'Recipe file incorrectly named')
+        self.assertIn(recipefile, result.output)
+        # Test devtool status
+        result = runCmd('devtool status')
+        self.assertIn(pn, result.output)
+        self.assertIn(recipefile, result.output)
+        checkvars = {}
+        checkvars['LICENSE'] = 'Apache-2.0'
+        checkvars['LIC_FILES_CHKSUM'] = 'file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57'
+        checkvars['S'] = '${WORKDIR}/git'
+        checkvars['PV'] = 'v3.1.0+git${SRCPV}'
+        checkvars['SRC_URI'] = 'git://git@github.com/ARMmbed/mbedtls.git;protocol=https;branch=master'
+        self._test_recipe_contents(recipefile, checkvars, [])
+
+    def test_devtool_add_git_style_2(self):
+         # this will trigger reformat_git_uri with branch parameter in url
+        url = "'git://git@github.com/ARMmbed/mbedtls.git;branch=mbedtls-2.28;protocol=https'"
+        version = 'v3.1.0'
+        pn = 'mbedtls'
+        # Test devtool add
+        self.track_for_cleanup(self.workspacedir)
+        self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')        
+        result = runCmd('devtool add --version %s %s %s' % (version, pn, url))
+        self.assertExists(os.path.join(self.workspacedir, 'conf', 'layer.conf'), 'Workspace directory not created')
+        # Check the recipe name is correct
+        recipefile = get_bb_var('FILE', pn)
+        self.assertIn('%s_git.bb' % pn, recipefile, 'Recipe file incorrectly named')
+        self.assertIn(recipefile, result.output)
+        # Test devtool status
+        result = runCmd('devtool status')
+        self.assertIn(pn, result.output)
+        self.assertIn(recipefile, result.output)
+        checkvars = {}
+        checkvars['LICENSE'] = 'Apache-2.0'
+        checkvars['LIC_FILES_CHKSUM'] = 'file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57'
+        checkvars['S'] = '${WORKDIR}/git'
+        checkvars['PV'] = 'v3.1.0+git${SRCPV}'
+        checkvars['SRC_URI'] = 'git://git@github.com/ARMmbed/mbedtls.git;branch=mbedtls-2.28;protocol=https'
+        self._test_recipe_contents(recipefile, checkvars, [])
+
 
     def test_devtool_add_library(self):
         # Fetch source
@@ -540,7 +593,7 @@  class DevtoolAddTests(DevtoolBase):
         result = runCmd('devtool status')
         self.assertIn(testrecipe, result.output)
         self.assertIn(srcdir, result.output)
-        # Check recipe
+        # Check recipedevtool add
         recipefile = get_bb_var('FILE', testrecipe)
         self.assertIn('%s_%s.bb' % (testrecipe, testver), recipefile, 'Recipe file incorrectly named')
         checkvars = {}