From patchwork Fri Oct 18 20:52:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ryan S. Arnold" X-Patchwork-Id: 21178 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f71.google.com (mail-pb0-f71.google.com [209.85.160.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 418A8202E6 for ; Fri, 18 Oct 2013 20:53:41 +0000 (UTC) Received: by mail-pb0-f71.google.com with SMTP id uo15sf4717576pbc.2 for ; Fri, 18 Oct 2013 13:53:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=s/XgjDzDChHM5SOaTnCvlmV1XCAdrYQoaw+rTM+HtCk=; b=WL5fqWcXYR8f4GRVKqVReOxPmyKYnr29UvpuyBL3/Ijvoqp61r7O9gwXgLECtok2E0 GjLc+A8ym/4Dp49XgPBAYpxRd3mBOJ7PjhjA6CnvN3scnfg9tXZnyj8Dlp04nEekrnLY k6qSX8dHktDl8iTvZhnhorJUeg3suJZU05zzQbUM7RjmdsziXcwEcIIEcav5XQ7tU/tQ iDiWY3BKUgnS5/fAfng1t0ERO0J/d/6wDb1YClEqFcbEPMnEwnv9JNDPgSAYxNImHbMI yaxdfqtH1tXAk84GlYn1moqJ/ijlTKf+0nP6r9bSG93t47vKl1yh5h82gkzZuzodpyVf DfXw== X-Received: by 10.67.2.41 with SMTP id bl9mr2263189pad.16.1382129620546; Fri, 18 Oct 2013 13:53:40 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.84.1 with SMTP id u1ls1362851qey.8.gmail; Fri, 18 Oct 2013 13:53:40 -0700 (PDT) X-Received: by 10.58.155.10 with SMTP id vs10mr3464330veb.4.1382129620326; Fri, 18 Oct 2013 13:53:40 -0700 (PDT) Received: from mail-vb0-f45.google.com (mail-vb0-f45.google.com [209.85.212.45]) by mx.google.com with ESMTPS id qg2si669238veb.88.2013.10.18.13.53.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Oct 2013 13:53:40 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.45 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.45; Received: by mail-vb0-f45.google.com with SMTP id e15so2210938vbg.32 for ; Fri, 18 Oct 2013 13:53:40 -0700 (PDT) X-Gm-Message-State: ALoCoQnRHVMw3TPWUEbGBVXTPmbsUL43WXgHGIqiE783LRL9IuSA6dtfDhI/I9lt9FgqBIVxjmwG X-Received: by 10.58.168.205 with SMTP id zy13mr2782799veb.19.1382129620208; Fri, 18 Oct 2013 13:53:40 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp63330vcz; Fri, 18 Oct 2013 13:53:39 -0700 (PDT) X-Received: by 10.43.60.139 with SMTP id ws11mr3124132icb.12.1382129619513; Fri, 18 Oct 2013 13:53:39 -0700 (PDT) Received: from mail-ie0-f181.google.com (mail-ie0-f181.google.com [209.85.223.181]) by mx.google.com with ESMTPS id jb1si3312833icb.148.2013.10.18.13.53.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Oct 2013 13:53:39 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.223.181 is neither permitted nor denied by best guess record for domain of ryan.arnold@linaro.org) client-ip=209.85.223.181; Received: by mail-ie0-f181.google.com with SMTP id ar20so7273044iec.26 for ; Fri, 18 Oct 2013 13:53:39 -0700 (PDT) X-Received: by 10.50.30.67 with SMTP id q3mr961068igh.46.1382129619101; Fri, 18 Oct 2013 13:53:39 -0700 (PDT) Received: from badwing.hsd1.mn.comcast.net. (c-71-195-40-9.hsd1.mn.comcast.net. [71.195.40.9]) by mx.google.com with ESMTPSA id cl4sm14877361igc.1.2013.10.18.13.53.37 for (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Fri, 18 Oct 2013 13:53:38 -0700 (PDT) From: "Ryan S. Arnold" To: Rob Savoye Cc: patches@linaro.org, "Ryan S. Arnold" Subject: [PATCH][Cbuildv2/get_source 06/17] lib/common.sh: find_snapshot should return list of found snapshots even on error. Date: Fri, 18 Oct 2013 15:52:48 -0500 Message-Id: <1382129579-5777-7-git-send-email-ryan.arnold@linaro.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1382129579-5777-1-git-send-email-ryan.arnold@linaro.org> References: <1382129579-5777-1-git-send-email-ryan.arnold@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ryan.arnold@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.45 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: "Ryan S. Arnold" Added a new test which tries to find an ambiguous snapshot. This exposed a bug in find_snapshot where it wasn't echoing the snapshots to stdout when there was an error (such as too many matching snapshots). This patches adds the new test and fixes this error case. This test also causes a return of '1' if too many matching snapshots were found but one wasn't chosen, whereas in the past it would erroneously return '0'. --- lib/common.sh | 21 ++++++++++++++------- testsuite/test.sh | 8 ++++++++ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/lib/common.sh b/lib/common.sh index 1e3bc9f..1fcc06b 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -323,6 +323,7 @@ find_snapshot() if test x"${snapshot}" != x; then if test `echo "${snapshot}" | grep -c $1` -gt 1; then warning "Too many results for $1!" + echo "${snapshot}" return 1 fi echo "${snapshot}" @@ -336,6 +337,7 @@ find_snapshot() fi if test `echo "${snapshot}" | grep -c $1` -gt 1; then warning "Too many results for $1!" + echo "${snapshot}" return 1 fi @@ -367,7 +369,7 @@ get_source() snapshot=`find_snapshot $1` if test $? -gt 0; then if test x"${interactive}" = x"yes"; then - notice "Pick a unique snapshot name from this list: " + echo "Pick a unique snapshot name from this list: " 1>&2 for i in ${snapshot}; do echo " $i" 1>&2 done @@ -379,15 +381,20 @@ get_source() # If there is a config file for this toolchain component, # see if it has a latest version set. If so, we use that. if test x"${latest}" != x; then + fixme "explicit snapshot listed in latest." 1>&2 local url=`find_snapshot ${latest}` return $? fi - notice "Pick a unique snapshot name from this list and try again: " - for i in ${snapshot}; do - echo " $i" 1>&2 - done - list_URL $1 - return 0 + # Technically 'notice' and 'get_URL' already suppress without + # verbose being set but no reason to do unnecessary work. + if test "${verbose}" -gt 0; then + notice "Pick a unique snapshot name from this list and try again: " + for i in ${snapshot}; do + echo " $i" 1>&2 + done + list_URL $1 + fi + return 1 fi fi fi diff --git a/testsuite/test.sh b/testsuite/test.sh index 3859c0e..37b0f2a 100755 --- a/testsuite/test.sh +++ b/testsuite/test.sh @@ -363,6 +363,14 @@ else fixme "get_source returned \"${out}\"" fi +in="gcc-linaro" +out="`get_source ${in} 2>/dev/null`" +if test $? -eq 1; then + pass "get_source: Too many snapshot matches." +else + fail "get_source: Too many snapshot matches." + fixme "get_source returned ${out}" +fi # ----------------------------------------------------------------------------------