commit:     61a961b295ff529961d0a29356a02465d0808790
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 17 07:12:02 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Wed Feb 17 07:12:02 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=61a961b2

qlop: fix default -l/-u match behavior

Adding atom parsing support accidentally broke the default behavior
of matching all packages.  Restore that edge case and add tests.

URL: https://bugs.gentoo.org/574832
Reported-by: Nikos Chantziaras <realnc <AT> gmail.com>

 qlop.c                 | 14 +++++++++++---
 tests/qlop/dotest      | 14 +++++++++++++-
 tests/qlop/list02.good |  3 +++
 tests/qlop/list03.good |  4 ++++
 tests/qlop/list04.good |  1 +
 tests/qlop/list05.good |  1 +
 tests/qlop/sync.log    | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/qlop/test04.good |  0
 8 files changed, 79 insertions(+), 4 deletions(-)

diff --git a/qlop.c b/qlop.c
index 8a89fba..dbbae06 100644
--- a/qlop.c
+++ b/qlop.c
@@ -241,6 +241,7 @@ show_emerge_history(int listflag, array_t *atoms, const 
char *logfile)
        size_t buflen, linelen;
        char *buf, merged;
        char *p, *q;
+       bool showit;
        size_t i;
        time_t t;
        depend_atom *atom, *logatom;
@@ -283,10 +284,17 @@ show_emerge_history(int listflag, array_t *atoms, const 
char *logfile)
                        continue;
 
                logatom = atom_explode(q);
-               array_for_each(atoms, i, atom) {
-                       if (atom_compare(atom, logatom) != EQUAL)
-                               continue;
+               if (array_cnt(atoms)) {
+                       showit = false;
+                       array_for_each(atoms, i, atom)
+                               if (atom_compare(atom, logatom) == EQUAL) {
+                                       showit = true;
+                                       break;
+                               }
+               } else
+                       showit = true;
 
+               if (showit) {
                        if (!quiet)
                                printf("%s %s %s%s%s\n", chop_ctime(t), (merged 
? ">>>" : "<<<"), (merged ? GREEN : RED), q, NORM);
                        else {

diff --git a/tests/qlop/dotest b/tests/qlop/dotest
index 6525594..fad6011 100755
--- a/tests/qlop/dotest
+++ b/tests/qlop/dotest
@@ -22,9 +22,21 @@ test() {
 # We output dates, so make sure it matches our logs.
 export LC_TIME="C"
 
-# simple install check
+# simple sync check
 test 01 0 "qlop -s -f ${as}/sync.log"
 
+# check all installed pkgs
+test 02 0 "qlop -l -f ${as}/sync.log"
+
+# check all uninstalled pkgs
+test 03 0 "qlop -u -f ${as}/sync.log"
+
+# verify atom parsing works (and not partial strings)
+test 04 0 "qlop -l gcc -f ${as}/sync.log"
+
+# verify atom version parsing works
+test 05 0 "qlop -l '<gcc-5' -f ${as}/sync.log"
+
 cleantmpdir
 
 end

diff --git a/tests/qlop/list02.good b/tests/qlop/list02.good
new file mode 100644
index 0000000..a00a3f6
--- /dev/null
+++ b/tests/qlop/list02.good
@@ -0,0 +1,3 @@
+Thu Oct 28 06:49:14 2004 >>> dev-util/ccache-2.3
+Thu Jan 27 05:56:39 2005 >>> sys-devel/gcc-config-1.3.9
+Thu Jan 27 06:17:10 2005 >>> sys-devel/gcc-3.4.3-r1

diff --git a/tests/qlop/list03.good b/tests/qlop/list03.good
new file mode 100644
index 0000000..add774a
--- /dev/null
+++ b/tests/qlop/list03.good
@@ -0,0 +1,4 @@
+Thu Jan 27 05:56:39 2005 <<< sys-devel/gcc-config-1.3.6-r3
+Thu Jan 27 05:58:04 2005 <<< sys-apps/pam-login-3.14
+Thu Jan 27 05:58:06 2005 <<< sys-libs/pam-0.77-r1
+Thu Jan 27 05:58:16 2005 <<< sys-fs/devfsd-1.3.25-r8

diff --git a/tests/qlop/list04.good b/tests/qlop/list04.good
new file mode 100644
index 0000000..c3de519
--- /dev/null
+++ b/tests/qlop/list04.good
@@ -0,0 +1 @@
+Thu Jan 27 06:17:10 2005 >>> sys-devel/gcc-3.4.3-r1

diff --git a/tests/qlop/list05.good b/tests/qlop/list05.good
new file mode 100644
index 0000000..c3de519
--- /dev/null
+++ b/tests/qlop/list05.good
@@ -0,0 +1 @@
+Thu Jan 27 06:17:10 2005 >>> sys-devel/gcc-3.4.3-r1

diff --git a/tests/qlop/sync.log b/tests/qlop/sync.log
index fc31edb..8979b23 100644
--- a/tests/qlop/sync.log
+++ b/tests/qlop/sync.log
@@ -1,3 +1,49 @@
+1098946153: Started emerge on: Oct 28, 2004 06:49:13
+1098946153:  *** emerge --buildpkg --usepkg --oneshot --nodeps ccache
+1098946153:  >>> emerge (1 of 1) dev-util/ccache-2.3 to /
+1098946153:  === (1 of 1) Merging Binary 
(dev-util/ccache-2.3::/usr/portage/packages/All/ccache-2.3.tbz2)
+1098946154:  >>> AUTOCLEAN: dev-util/ccache
+1098946154:  --- AUTOCLEAN: Nothing unmerged.
+1098946154:  ::: completed emerge (1 of 1) dev-util/ccache-2.3 to /
+1098946154:  *** Finished. Cleaning up...
+1098946154:  *** exiting successfully.
+1098946154:  *** terminating.
+
+1106805388: Started emerge on: Jan 27, 2005 05:56:28
+1106805388:  *** emerge  gcc
+1106805388:  >>> emerge (1 of 2) sys-devel/gcc-config-1.3.9 to /
+1106805388:  === (1 of 2) Cleaning 
(sys-devel/gcc-config-1.3.9::/usr/portage/sys-devel/gcc-config/gcc-config-1.3.9.ebuild)
+1106805388:  === (1 of 2) Compiling/Merging 
(sys-devel/gcc-config-1.3.9::/usr/portage/sys-devel/gcc-config/gcc-config-1.3.9.ebuild)
+1106805393:  === (1 of 2) Post-Build Cleaning 
(sys-devel/gcc-config-1.3.9::/usr/portage/sys-devel/gcc-config/gcc-config-1.3.9.ebuild)
+1106805393:  >>> AUTOCLEAN: sys-devel/gcc-config
+1106805398: === Unmerging... (sys-devel/gcc-config-1.3.6-r3)
+1106805399:  >>> unmerge success: sys-devel/gcc-config-1.3.6-r3
+1106805399:  ::: completed emerge (1 of 2) sys-devel/gcc-config-1.3.9 to /
+1106805399:  >>> emerge (2 of 2) sys-devel/gcc-3.4.3-r1 to /
+1106805399:  === (2 of 2) Cleaning 
(sys-devel/gcc-3.4.3-r1::/usr/portage/sys-devel/gcc/gcc-3.4.3-r1.ebuild)
+1106805399:  === (2 of 2) Compiling/Merging 
(sys-devel/gcc-3.4.3-r1::/usr/portage/sys-devel/gcc/gcc-3.4.3-r1.ebuild)
+1106805477: Started emerge on: Jan 27, 2005 05:57:57
+1106805477:  *** emerge  unmerge pam pam-login
+1106805482: === Unmerging... (sys-apps/pam-login-3.14)
+1106805484:  >>> unmerge success: sys-apps/pam-login-3.14
+1106805484: === Unmerging... (sys-libs/pam-0.77-r1)
+1106805486:  >>> unmerge success: sys-libs/pam-0.77-r1
+1106805487:  *** exiting successfully.
+1106805487:  *** terminating.
+1106805490: Started emerge on: Jan 27, 2005 05:58:10
+1106805490:  *** emerge  unmerge devfsd
+1106805495: === Unmerging... (sys-fs/devfsd-1.3.25-r8)
+1106805496:  >>> unmerge success: sys-fs/devfsd-1.3.25-r8
+1106805497:  *** exiting successfully.
+1106805497:  *** terminating.
+1106806630:  === (2 of 2) Post-Build Cleaning 
(sys-devel/gcc-3.4.3-r1::/usr/portage/sys-devel/gcc/gcc-3.4.3-r1.ebuild)
+1106806630:  >>> AUTOCLEAN: sys-devel/gcc
+1106806630:  --- AUTOCLEAN: Nothing unmerged.
+1106806630:  ::: completed emerge (2 of 2) sys-devel/gcc-3.4.3-r1 to /
+1106806630:  *** Finished. Cleaning up...
+1106806630:  *** exiting successfully.
+1106806630:  *** terminating.
+
 1106804103: Started emerge on: Jan 27, 2005 05:35:03
 1106804103:  *** emerge  sync
 1106804103:  === sync

diff --git a/tests/qlop/test04.good b/tests/qlop/test04.good
new file mode 100644
index 0000000..e69de29

Reply via email to