summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tests
diff options
context:
space:
mode:
authorAníbal Limón <anibal.limon@linux.intel.com>2014-11-05 12:10:28 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-11-12 15:25:17 +0000
commit7587877e5d683a30c2bd5e1ac1c4e327fac1ee1c (patch)
tree46be36149f9f63ce1a0a47268c8bcdaba318f65d /bitbake/lib/bb/tests
parent95c7b399518d102cd748c19017c564a53375c58c (diff)
downloadpoky-7587877e5d683a30c2bd5e1ac1c4e327fac1ee1c.tar.gz
bitbake: fetch/git: Add latest_versionstring method
Being able to generate a version string representing the most recent git commit given git is useful, not least for the package reporting system. This adds in a latest_versionstring method to the git fetcher which allows users to query the latest version using ls-remote and filtering the responses. The patch also adds unittests for this function so that if improvements are made, the original test urls can be used to evaulate the those changes. This is based on code from Irina Patru <irina.patru@intel.com>. (Bitbake rev: f71c8c0354e87fed80bc845db6728e6e18ce9c4d) Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/tests')
-rw-r--r--bitbake/lib/bb/tests/fetch.py44
1 files changed, 43 insertions, 1 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index d95b43a5e3..aa9b222612 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -24,6 +24,7 @@ import tempfile
24import subprocess 24import subprocess
25import os 25import os
26from bb.fetch2 import URI 26from bb.fetch2 import URI
27from bb.fetch2 import FetchMethod
27import bb 28import bb
28 29
29class URITest(unittest.TestCase): 30class URITest(unittest.TestCase):
@@ -565,5 +566,46 @@ class URLHandle(unittest.TestCase):
565 result = bb.fetch.encodeurl(v) 566 result = bb.fetch.encodeurl(v)
566 self.assertEqual(result, k) 567 self.assertEqual(result, k)
567 568
569class FetchMethodTest(FetcherTest):
570
571 test_git_uris = {
572 # version pattern "X.Y.Z"
573 ("mx-1.0", "git://github.com/clutter-project/mx.git;branch=mx-1.4", "9b1db6b8060bd00b121a692f942404a24ae2960f", "")
574 : "1.99.4",
575 # version pattern "vX.Y"
576 ("mtd-utils", "git://git.infradead.org/mtd-utils.git", "ca39eb1d98e736109c64ff9c1aa2a6ecca222d8f", "")
577 : "1.5.0",
578 # version pattern "pkg_name-X.Y"
579 ("presentproto", "git://anongit.freedesktop.org/git/xorg/proto/presentproto", "24f3a56e541b0a9e6c6ee76081f441221a120ef9", "")
580 : "1.0",
581 # version pattern "pkg_name-vX.Y.Z"
582 ("dtc", "git://git.qemu.org/dtc.git", "65cc4d2748a2c2e6f27f1cf39e07a5dbabd80ebf", "")
583 : "1.4.0",
584 # combination version pattern
585 ("sysprof", "git://git.gnome.org/sysprof", "cd44ee6644c3641507fb53b8a2a69137f2971219", "")
586 : "1.2.0",
587 ("u-boot-mkimage", "git://git.denx.de/u-boot.git;branch=master;protocol=git", "62c175fbb8a0f9a926c88294ea9f7e88eb898f6c", "")
588 : "2014.01",
589 # version pattern "yyyymmdd"
590 ("mobile-broadband-provider-info", "git://git.gnome.org/mobile-broadband-provider-info", "4ed19e11c2975105b71b956440acdb25d46a347d", "")
591 : "20120614",
592 # packages with a valid GITTAGREGEX
593 ("xf86-video-omap", "git://anongit.freedesktop.org/xorg/driver/xf86-video-omap", "ae0394e687f1a77e966cf72f895da91840dffb8f", "(?P<pver>(\d+\.(\d\.?)*))")
594 : "0.4.3",
595 ("build-appliance-image", "git://git.yoctoproject.org/poky", "b37dd451a52622d5b570183a81583cc34c2ff555", "(?P<pver>(([0-9][\.|_]?)+[0-9]))")
596 : "11.0.0",
597 ("chkconfig-alternatives-native", "git://github.com/kergoth/chkconfig;branch=sysroot", "cd437ecbd8986c894442f8fce1e0061e20f04dee", "chkconfig\-(?P<pver>((\d+[\.\-_]*)+))")
598 : "1.3.59",
599 ("remake", "git://github.com/rocky/remake.git", "f05508e521987c8494c92d9c2871aec46307d51d", "(?P<pver>(\d+\.(\d+\.)*\d*(\+dbg\d+(\.\d+)*)*))")
600 : "3.82+dbg0.9",
601 }
568 602
569 603 def test_git_latest_versionstring(self):
604 for k, v in self.test_git_uris.items():
605 self.d.setVar("SRCREV", k[2])
606 self.d.setVar("GITTAGREGEX", k[3])
607 ud = bb.fetch2.FetchData(k[1], self.d)
608 verstring = ud.method.latest_versionstring(ud, self.d)
609 print("Package %s, version: %s <= %s" % (k[0], v, verstring))
610 r = bb.utils.vercmp_string(v, verstring)
611 self.assertTrue(r == -1 or r == 0)