summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2014-01-17 08:43:14 +0100
committerMichael Vogt <mvo@debian.org>2014-01-17 08:43:14 +0100
commit1410955589dc9f0eaa290907cac070b7ebf93b6a (patch)
treeea69d4dcb856d793a0dcfad0176e40987655c1dd
parentb7159ec8835e61ea3069213d9188be91c109e32c (diff)
add missing integration test for "apt list"
-rw-r--r--apt-private/private-list.cc12
-rw-r--r--apt-private/private-output.cc8
-rw-r--r--cmdline/apt.cc23
-rw-r--r--test/integration/framework10
-rwxr-xr-xtest/integration/test-apt-binary47
5 files changed, 79 insertions, 21 deletions
diff --git a/apt-private/private-list.cc b/apt-private/private-list.cc
index a02ebf02d..fbb66d204 100644
--- a/apt-private/private-list.cc
+++ b/apt-private/private-list.cc
@@ -101,11 +101,15 @@ private:
/*}}}*/
void ListAllVersions(pkgCacheFile &CacheFile, pkgRecords &records, /*{{{*/
pkgCache::PkgIterator P,
- std::ostream &outs)
+ std::ostream &outs,
+ bool include_summary=true)
{
for (pkgCache::VerIterator Ver = P.VersionList();
Ver.end() == false; Ver++)
- ListSingleVersion(CacheFile, records, Ver, outs);
+ {
+ ListSingleVersion(CacheFile, records, Ver, outs, include_summary);
+ outs << "\n";
+ }
}
/*}}}*/
// list - list package based on criteria /*{{{*/
@@ -136,7 +140,7 @@ bool List(CommandLine &Cmd)
PackageNameMatcher matcher(patterns);
LocalitySortedVersionSet bag;
- OpTextProgress progress;
+ OpTextProgress progress(*_config);
progress.OverallProgress(0,
Cache->Head().PackageCount,
Cache->Head().PackageCount,
@@ -147,7 +151,7 @@ bool List(CommandLine &Cmd)
std::stringstream outs;
if(_config->FindB("APT::Cmd::All-Versions", false) == true)
{
- ListAllVersions(CacheFile, records, V.ParentPkg(), outs);
+ ListAllVersions(CacheFile, records, V.ParentPkg(), outs, includeSummary);
output_map.insert(std::make_pair<std::string, std::string>(
V.ParentPkg().Name(), outs.str()));
} else {
diff --git a/apt-private/private-output.cc b/apt-private/private-output.cc
index 91d13f31b..a8bbad9e5 100644
--- a/apt-private/private-output.cc
+++ b/apt-private/private-output.cc
@@ -114,11 +114,13 @@ std::string GetVersion(pkgCacheFile &CacheFile, pkgCache::VerIterator V)/*{{{*/
pkgCache::PkgIterator P = V.ParentPkg();
if (V == P.CurrentVer())
{
+ std::string inst_str = DeNull(V.VerStr());
+#if 0 // FIXME: do we want this or something like this?
pkgDepCache *DepCache = CacheFile.GetDepCache();
pkgDepCache::StateCache &state = (*DepCache)[P];
- std::string inst_str = DeNull(V.VerStr());
if (state.Upgradable())
return "**"+inst_str;
+#endif
return inst_str;
}
@@ -224,11 +226,11 @@ void ListSingleVersion(pkgCacheFile &CacheFile, pkgRecords &records, /*{{{*/
else
out << GetVersion(CacheFile, V);
}
- out << " " << GetArchitecture(CacheFile, P) << " ";
+ out << " " << GetArchitecture(CacheFile, P);
if (include_summary)
{
out << std::endl
- << " " << GetShortDescription(CacheFile, records, P)
+ << " " << GetShortDescription(CacheFile, records, P)
<< std::endl;
}
}
diff --git a/cmdline/apt.cc b/cmdline/apt.cc
index 2d3966e86..8dc4c292a 100644
--- a/cmdline/apt.cc
+++ b/cmdline/apt.cc
@@ -114,16 +114,6 @@ int main(int argc, const char *argv[]) /*{{{*/
std::vector<CommandLine::Args> Args = getCommandArgs("apt", CommandLine::GetCommand(Cmds, argc, argv));
- if(!isatty(1))
- {
- std::cerr << std::endl
- << "WARNING: " << argv[0] << " "
- << "does not have a stable CLI interface yet. "
- << "Use with caution in scripts."
- << std::endl
- << std::endl;
- }
-
InitOutput();
// Set up gettext support
@@ -149,6 +139,19 @@ int main(int argc, const char *argv[]) /*{{{*/
return 100;
}
+ if(!isatty(STDOUT_FILENO) &&
+ _config->FindB("Apt::Cmd::Disable-Script-Warning", false) == false)
+ {
+ std::cerr << std::endl
+ << "WARNING: " << argv[0] << " "
+ << "does not have a stable CLI interface yet. "
+ << "Use with caution in scripts."
+ << std::endl
+ << std::endl;
+ }
+ if (!isatty(STDOUT_FILENO) && _config->FindI("quiet", -1) == -1)
+ _config->Set("quiet","1");
+
// See if the help should be shown
if (_config->FindB("help") == true ||
_config->FindB("version") == true ||
diff --git a/test/integration/framework b/test/integration/framework
index a28363768..6620c78dd 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -99,6 +99,7 @@ aptconfig() { runapt apt-config $*; }
aptcache() { runapt apt-cache $*; }
aptcdrom() { runapt apt-cdrom $*; }
aptget() { runapt apt-get $*; }
+apt() { runapt apt $*; }
aptftparchive() { runapt apt-ftparchive $*; }
aptkey() { runapt apt-key $*; }
aptmark() { runapt apt-mark $*; }
@@ -202,6 +203,7 @@ setupenvironment() {
echo "DPKG::options:: \"--log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log\";" >> aptconfig.conf
echo 'quiet::NoUpdate "true";' >> aptconfig.conf
echo "Acquire::https::CaInfo \"${TESTDIR}/apt.pem\";" > rootdir/etc/apt/apt.conf.d/99https
+ echo "Apt::Cmd::Disable-Script-Warning \"1\";" > rootdir/etc/apt/apt.conf.d/apt-binary
export LC_ALL=C
export PATH="${PATH}:/usr/local/sbin:/usr/sbin:/sbin"
configcompression '.' 'gz' #'bz2' 'lzma' 'xz'
@@ -288,7 +290,7 @@ setupsimplenativepackage() {
local VERSION="$3"
local RELEASE="${4:-unstable}"
local DEPENDENCIES="$5"
- local DESCRIPTION="${6:-"Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
+ local DESCRIPTION="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
If you find such a package installed on your system,
something went horribly wrong! They are autogenerated
und used only by testcases and surf no other propose…"}"
@@ -338,7 +340,7 @@ buildsimplenativepackage() {
local VERSION="$3"
local RELEASE="${4:-unstable}"
local DEPENDENCIES="$5"
- local DESCRIPTION="${6:-"Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
+ local DESCRIPTION="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
If you find such a package installed on your system,
something went horribly wrong! They are autogenerated
und used only by testcases and surf no other propose…"}"
@@ -535,7 +537,7 @@ insertpackage() {
local VERSION="$4"
local DEPENDENCIES="$5"
local PRIORITY="${6:-optional}"
- local DESCRIPTION="${7:-"Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
+ local DESCRIPTION="${7:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
If you find such a package installed on your system,
something went horribly wrong! They are autogenerated
und used only by testcases and surf no other propose…"}"
@@ -595,7 +597,7 @@ insertinstalledpackage() {
local DEPENDENCIES="$4"
local PRIORITY="${5:-optional}"
local STATUS="${6:-install ok installed}"
- local DESCRIPTION="${7:-"Description: an autogenerated dummy ${NAME}=${VERSION}/installed
+ local DESCRIPTION="${7:-"an autogenerated dummy ${NAME}=${VERSION}/installed
If you find such a package installed on your system,
something went horribly wrong! They are autogenerated
und used only by testcases and surf no other propose…"}"
diff --git a/test/integration/test-apt-binary b/test/integration/test-apt-binary
new file mode 100755
index 000000000..8d5df9051
--- /dev/null
+++ b/test/integration/test-apt-binary
@@ -0,0 +1,47 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+configarchitecture "i386"
+
+insertpackage 'unstable' 'foo' 'all' '1.0'
+insertinstalledpackage 'bar' 'i386' '1.0'
+
+insertinstalledpackage 'foobar' 'i386' '1.0'
+insertpackage 'unstable' 'foobar' 'i386' '2.0'
+
+setupaptarchive
+
+APTARCHIVE=$(readlink -f ./aptarchive)
+
+testequal "Listing...
+bar/now 1.0 [installed,local] i386
+foo/unstable 1.0 all
+foobar/unstable 2.0 [upgradable from: 1.0] i386" apt list
+
+testequal "Listing...
+foo/unstable 1.0 all
+foobar/unstable 2.0 [upgradable from: 1.0] i386" apt list "foo*"
+
+testequal "Listing...
+foobar/unstable 2.0 [upgradable from: 1.0] i386" apt list --upgradable
+
+# FIXME: hm, hm - does it make sense to have this different? shouldn't
+# we use "installed,upgradable" consitently?
+testequal "Listing...
+bar/now 1.0 [installed,local] i386
+foobar/now 1.0 [installed,upgradable to: 2.0] i386" apt list --installed
+
+testequal "Listing...
+foobar/unstable 2.0 [upgradable from: 1.0] i386
+foobar/now 1.0 [installed,upgradable to: 2.0] i386
+" apt list foobar --all-versions
+
+testequal "Listing...
+bar/now 1.0 [installed,local] i386
+ an autogenerated dummy bar=1.0/installed
+" apt list bar --verbose
+