From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 5FA79138A1A for ; Fri, 20 Feb 2015 23:35:15 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 19B55E082F; Fri, 20 Feb 2015 23:35:14 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id ECB63E080A for ; Fri, 20 Feb 2015 23:35:12 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B20B1340ED6 for ; Fri, 20 Feb 2015 22:19:21 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id E65BD12318 for ; Fri, 20 Feb 2015 22:19:17 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1424470907.4240e7476f0beacc8791a0439deee477a1654044.vapier@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: /, tests/qlist/ X-VCS-Repository: proj/portage-utils X-VCS-Files: qlist.c tests/qlist/dotest tests/qlist/list15.good X-VCS-Directories: tests/qlist/ / X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 4240e7476f0beacc8791a0439deee477a1654044 X-VCS-Branch: master Date: Fri, 20 Feb 2015 22:19:17 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: cc53c1ba-6a20-4a85-9d9f-50587641c7ff X-Archives-Hash: c922ba119b523359adcee9baf127b707 commit: 4240e7476f0beacc8791a0439deee477a1654044 Author: Mike Frysinger gentoo org> AuthorDate: Fri Feb 20 22:21:47 2015 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Fri Feb 20 22:21:47 2015 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=4240e747 qlist: exit non-0 when nothing is matched URL: https://bugs.gentoo.org/538438 --- qlist.c | 9 +++++---- tests/qlist/dotest | 43 ++++++++++++++++++++++++++----------------- tests/qlist/list15.good | 0 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/qlist.c b/qlist.c index d1d60ba..cccea33 100644 --- a/qlist.c +++ b/qlist.c @@ -311,7 +311,7 @@ _q_static int qlist_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv) atom_implode(atom); if (!state->all) - return 0; + return 1; } if (verbose > 1) @@ -319,7 +319,7 @@ _q_static int qlist_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv) fp = q_vdb_pkg_fopenat_ro(pkg_ctx, "CONTENTS"); if (fp == NULL) - return 0; + return 1; while (getline(&state->buf, &state->buflen, fp) != -1) { contents_entry *e; @@ -355,7 +355,7 @@ _q_static int qlist_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv) } fclose(fp); - return 0; + return 1; } int qlist_main(int argc, char **argv) @@ -413,7 +413,8 @@ int qlist_main(int argc, char **argv) free(state.buf); free(state.atoms); - return ret; + /* The return value is whether we matched anything. */ + return ret ? EXIT_SUCCESS : EXIT_FAILURE; } #else diff --git a/tests/qlist/dotest b/tests/qlist/dotest index b5e1a41..586ac1d 100755 --- a/tests/qlist/dotest +++ b/tests/qlist/dotest @@ -10,53 +10,62 @@ export Q_VDB=/ mktmpdir test() { - local num=$1; shift - eval "$@" > list - diff -u list ${as}/list${num}.good + local num=$1 exp=$2 ret=0 + shift 2 + eval "$@" > list || ret=$? + if ! diff -u list ${as}/list${num}.good ; then + tfail "output does not match" + fi + if [[ ${exp} -ne ${ret} ]] ; then + tfail "exit code (${ret}) does not match expected (${exp})" + fi tend $? "$*" } # simple install check -test 01 "qlist -IC" +test 01 0 "qlist -IC" # simple files list -test 02 "qlist -C --showdebug cpio" +test 02 0 "qlist -C --showdebug cpio" # symlink verbose list -test 03 "qlist -C --showdebug mtools -e -v" +test 03 0 "qlist -C --showdebug mtools -e -v" # dir test -test 04 "qlist -C --showdebug mtools -d" +test 04 0 "qlist -C --showdebug mtools -d" # obj test -test 05 "qlist -C --showdebug mtools -o" +test 05 0 "qlist -C --showdebug mtools -o" # sym test -test 06 "qlist -C --showdebug mtools -s" +test 06 0 "qlist -C --showdebug mtools -s" # SLOT test -test 07 "qlist -ICS" +test 07 0 "qlist -ICS" # showdebug test #1 -test 08 "qlist -C cpio" +test 08 0 "qlist -C cpio" # dir test -test 09 "qlist -C mtools -d" +test 09 0 "qlist -C mtools -d" # ver test -test 10 "qlist -Iv =mtools-4*" +test 10 0 "qlist -Iv =mtools-4*" # repo test -test 11 "qlist -ICR" +test 11 0 "qlist -ICR" # slot with repo test -test 12 "qlist -ICSR" +test 12 0 "qlist -ICSR" # exact CAT/PN:slot::repo files list test -test 13 "qlist -Ce --showdebug app-arch/cpio:0::gentoo" +test 13 0 "qlist -Ce --showdebug app-arch/cpio:0::gentoo" # sub-SLOT test -test 14 "qlist -ICSS" +test 14 0 "qlist -ICSS" + +# no matches +test 15 1 "qlist -Iv lajsdflkjasdflkjasdfljasdf" cleantmpdir diff --git a/tests/qlist/list15.good b/tests/qlist/list15.good new file mode 100644 index 0000000..e69de29