* [gentoo-commits] proj/portage-utils:master commit in: /, tests/qlist/
@ 2015-02-20 22:19 Mike Frysinger
0 siblings, 0 replies; only message in thread
From: Mike Frysinger @ 2015-02-20 22:19 UTC (permalink / raw
To: gentoo-commits
commit: 4240e7476f0beacc8791a0439deee477a1654044
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 20 22:21:47 2015 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> 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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2015-02-20 23:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-20 22:19 [gentoo-commits] proj/portage-utils:master commit in: /, tests/qlist/ Mike Frysinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox