From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: Olof Johansson <olof.johansson@axis.com>
Cc: bitbake-devel@lists.openembedded.org
Subject: Re: [RFC 3/5] bb.tests.fetch_git: initial set of tests for git fetcher
Date: Wed, 18 Dec 2013 11:43:56 +0000 [thread overview]
Message-ID: <1387367036.6402.37.camel@ted> (raw)
In-Reply-To: <1386866938-5932-4-git-send-email-olof.johansson@axis.com>
On Thu, 2013-12-12 at 17:48 +0100, Olof Johansson wrote:
> This commit introduces a set of whitebox unit tests for the git
> fetcher, including some minor refactoring of the fetcher itself
> to increase testability.
>
> Signed-off-by: Olof Johansson <olof.johansson@axis.com>
> ---
> bin/bitbake-selftest | 3 +-
> lib/bb/fetch2/git.py | 31 +++++++--
> lib/bb/tests/fetch_git.py | 164 ++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 190 insertions(+), 8 deletions(-)
> create mode 100644 lib/bb/tests/fetch_git.py
>
> diff --git a/bin/bitbake-selftest b/bin/bitbake-selftest
> index 48a58fe..7f02fbf 100755
> --- a/bin/bitbake-selftest
> +++ b/bin/bitbake-selftest
> @@ -25,10 +25,11 @@ try:
> except RuntimeError as exc:
> sys.exit(str(exc))
>
> -tests = ["bb.tests.codeparser",
> +tests = ["bb.tests.codeparser",
> "bb.tests.cow",
> "bb.tests.data",
> "bb.tests.fetch",
> + "bb.tests.fetch_git",
> "bb.tests.utils"]
>
> for t in tests:
> diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
> index bd107db..81bf282 100644
> --- a/lib/bb/fetch2/git.py
> +++ b/lib/bb/fetch2/git.py
> @@ -87,14 +87,10 @@ class Git(FetchMethod):
> init git specific variable within url data
> so that the git method like latest_revision() can work
> """
> - if 'protocol' in ud.parm:
> - ud.proto = ud.parm['protocol']
> - elif not ud.host:
> - ud.proto = 'file'
> - else:
> - ud.proto = "git"
>
> - if not ud.proto in ('git', 'file', 'ssh', 'http', 'https', 'rsync'):
> + ud.proto = self._fetch_url_proto(ud)
> +
> + if not self._valid_protocol(ud.proto):
> raise bb.fetch2.ParameterError("Invalid protocol type", ud.url)
>
> ud.nocheckout = ud.parm.get("nocheckout","0") == "1"
> @@ -287,6 +283,27 @@ class Git(FetchMethod):
> def supports_srcrev(self):
> return True
>
> + def _fetch_url_proto(self, ud):
> + """
> + Identify protocol for Git URL.
> +
> + The scheme prefix is used to couple the URL to this particular fetcher,
> + but it's not necessarily the git protocol we will use. If a protocol
> + URL parameter is supplied we will use that, otherwise we will use
> + git:// if the URL contains a hostname or file:// if it does not.
> +
> + """
> + if 'protocol' in ud.parm:
> + return ud.parm['protocol']
> +
> + if not ud.host:
> + return 'file'
> +
> + return "git"
> +
> + def _valid_protocol(self, proto):
> + return proto in ('git', 'file', 'ssh', 'http', 'https', 'rsync')
> +
> def _contains_ref(self, ud, d, name):
> cmd = "%s branch --contains %s --list %s 2> /dev/null | wc -l" % (
> ud.basecmd, ud.revisions[name], ud.branches[name])
> diff --git a/lib/bb/tests/fetch_git.py b/lib/bb/tests/fetch_git.py
> new file mode 100644
> index 0000000..89af515
> --- /dev/null
> +++ b/lib/bb/tests/fetch_git.py
> @@ -0,0 +1,164 @@
> +# ex:ts=4:sw=4:sts=4:et
> +# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
> +#
> +# BitBake Tests for the git fetcher (fetch2/git.py)
> +#
> +# Copyright (C) 2013 Olof Johansson
> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License version 2 as
> +# published by the Free Software Foundation.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License along
> +# with this program; if not, write to the Free Software Foundation, Inc.,
> +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
> +
> +import unittest
> +from mock import Mock, patch
This is going to cause some headaches since we don't have Mock listed in
and of the prerequisite documentation, nor is it present in our prebuilt
tools tarball or do we have a recipe for it.
This is probably enough to block the patch until we can find someone to
look at fixing that :(
Would it be possible to separate out the tests from the other changes?
Cheers,
Richard
next prev parent reply other threads:[~2013-12-18 11:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-12 16:48 [RFC 0/5] Git fetcher changes for resolving tags Olof Johansson
2013-12-12 16:48 ` [RFC 1/5] fetch2/git: Improve handling of unresolved names verses branches Olof Johansson
2013-12-12 16:48 ` [RFC 2/5] bb.fetch2.git: reuse basecmd attribute Olof Johansson
2013-12-12 16:48 ` [RFC 3/5] bb.tests.fetch_git: initial set of tests for git fetcher Olof Johansson
2013-12-18 11:43 ` Richard Purdie [this message]
2013-12-18 11:51 ` Olof Johansson
2013-12-18 12:25 ` Richard Purdie
2013-12-12 16:48 ` [RFC 4/5] bb.fetch2.git: support resolving both tags and branches Olof Johansson
2013-12-12 16:48 ` [RFC 5/5] bb.fetch2.git: use the _gen_git_url() function Olof Johansson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1387367036.6402.37.camel@ted \
--to=richard.purdie@linuxfoundation.org \
--cc=bitbake-devel@lists.openembedded.org \
--cc=olof.johansson@axis.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.