diff options
author | Bernard Ogden <bernie.ogden@linaro.org> | 2015-04-20 14:37:46 +0100 |
---|---|---|
committer | Bernard Ogden <bernie.ogden@linaro.org> | 2015-04-20 14:37:46 +0100 |
commit | 7c5e743e2bdedaf5cc2b3213eebc37a4dec177a7 (patch) | |
tree | 03f8211e2609715c7d7ac3a8dd18d49d3e657f8a | |
parent | 057a64d54acd14dfe07d8eb7725985df110237e2 (diff) |
Propagate git-parsing errors from checkout.sh
Lets us fail fast, in a place that indicates what the problem is.
Most of these failure cases can't occur in the present state of
the code, so most of them don't have tests. It's still worth
propagating the errors, in case the code changes.
Change-Id: I270182cd5938e56dde62c934a76c41c00805d68f
-rw-r--r-- | lib/checkout.sh | 15 | ||||
-rwxr-xr-x | testsuite/test.sh | 18 |
2 files changed, 27 insertions, 6 deletions
diff --git a/lib/checkout.sh b/lib/checkout.sh index 83fbb957..81beb2fb 100644 --- a/lib/checkout.sh +++ b/lib/checkout.sh @@ -201,18 +201,21 @@ checkout() fi local repo= - repo="`get_git_repo $1`" + repo="`get_git_repo $1`" || return 1 + #None of the following should be able to fail with the code as it is + #written today (and failures are therefore untestable) but propagate + #errors anyway, in case that situation changes. local tool= - tool="`get_toolname $1`" + tool="`get_toolname $1`" || return 1 local url= - url="`get_git_url $1`" + url="`get_git_url $1`" || return 1 local branch= - branch="`get_git_branch $1`" + branch="`get_git_branch $1`" || return 1 local revision= - revision="`get_git_revision $1`" + revision="`get_git_revision $1`" || return 1 local srcdir= - srcdir="`get_srcdir $1`" + srcdir="`get_srcdir $1`" || return 1 case $1 in svn*) diff --git a/testsuite/test.sh b/testsuite/test.sh index 42f5269d..adb6dba7 100755 --- a/testsuite/test.sh +++ b/testsuite/test.sh @@ -1386,6 +1386,24 @@ for service in "foomatic://" "http:" "http:/fake.git" "http/" "http//" ""; do fi done +#confirm that checkout fails with bad repo - abe is so forgiving that I can only find one suitable input +in="http://" +testing="checkout: ${in} should fail with 'cannot parse repo' message." +if test x"${debug}" = xyes; then + out="`cd ${local_snapshots} && checkout ${in} 2> >(tee /dev/stderr)`" +else + out="`cd ${local_snapshots} && checkout ${in} 2>&1`" +fi +if test $? -eq 0; then + fail "${testing}" +else + if echo "${out}" | tail -n1 | grep -q "^ERROR.*: git_parser (Malformed input\\. No repo found\\.)$"; then + pass "${testing}" + else + fail "${testing}" + fi +fi + test_checkout () { local should="$1" |