diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2011-10-05 23:00:47 +0200 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2011-10-05 23:00:47 +0200 |
commit | d073d7db69eddd2d9c22e8ded7c6b871bca1716a (patch) | |
tree | b8244eb97f78e96e34cf1fc5f1c0b19ec4bd5ab3 /test | |
parent | 061c58b61ab5aae4689386bd2ab1e36e71470dfc (diff) |
cherrypick from my apt/experimental branch
* apt-pkg/deb/debmetaindex.cc:
- none is a separator, not a language: no need for Index (Closes: #624218)
* apt-pkg/aptconfiguration.cc:
- do not builtin languages only if none is forced (Closes: #643787)
Diffstat (limited to 'test')
-rwxr-xr-x | test/integration/test-bug-624218-Translation-file-handling | 87 | ||||
-rw-r--r-- | test/libapt/assert.h | 15 | ||||
-rw-r--r-- | test/libapt/getlanguages_test.cc | 12 | ||||
-rwxr-xr-x | test/libapt/run-tests | 3 |
4 files changed, 113 insertions, 4 deletions
diff --git a/test/integration/test-bug-624218-Translation-file-handling b/test/integration/test-bug-624218-Translation-file-handling new file mode 100755 index 000000000..a1e708d2e --- /dev/null +++ b/test/integration/test-bug-624218-Translation-file-handling @@ -0,0 +1,87 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture 'i386' + +buildsimplenativepackage 'coolstuff' 'all' '1.0' 'unstable' + +setupaptarchive + +changetowebserver + +rm -rf rootdir/var/lib/apt/lists + +msgtest 'No download of non-existent locals' 'with Index' +LC_ALL="" aptget update -o Acquire::Languages=en | grep -q -e 'Translation-[^e][^n] ' && msgfail || msgpass +rm -rf rootdir/var/lib/apt/lists + +msgtest 'Download of existent locals' 'with Index' +LC_ALL="" aptget update | grep -q -e 'Translation-en ' && msgpass || msgfail +rm -rf rootdir/var/lib/apt/lists + +msgtest 'Download of en in LC_ALL=C' 'with Index' +LC_ALL=C aptget update | grep -q -e 'Translation-en ' && msgpass || msgfail +rm -rf rootdir/var/lib/apt/lists + +msgtest 'Download of en as forced language' 'with Index' +aptget update -o Acquire::Languages=en | grep -q -e 'Translation-en ' && msgpass || msgfail +rm -rf rootdir/var/lib/apt/lists + +msgtest 'Download of nothing else in forced language' 'with Index' +aptget update -o Acquire::Languages=en | grep -q -e 'Translation-[^e][^n] ' && msgfail || msgpass +rm -rf rootdir/var/lib/apt/lists + +msgtest 'Download no Translation- if forced language is non-existent' 'with Index' +aptget update -o Acquire::Languages=ast_DE | grep -q -e 'Translation-' && msgfail || msgpass +rm -rf rootdir/var/lib/apt/lists + +msgtest 'Download of nothing if none is forced' 'with Index' +aptget update -o Acquire::Languages=none | grep -q -e 'Translation' && msgfail || msgpass +rm -rf rootdir/var/lib/apt/lists + +sed -i '/i18n\/Index$/ d' $(find aptarchive -name 'Release') +signreleasefiles + +# we have to try as not every archive includes the i18n Index in the Release file - if it has one at all +msgtest 'Download no Translation- if forced language is non-existent' 'with not-announced Index' +aptget update -o Acquire::Languages=ast_DE | grep -q -e 'Translation-' && msgfail || msgpass +rm -rf rootdir/var/lib/apt/lists + +find aptarchive -name 'Index' -delete + +msgtest 'Download of en as forced language' 'without Index' +aptget update -o Acquire::Languages=en | grep -q -e 'Translation-en ' && msgpass || msgfail +rm -rf rootdir/var/lib/apt/lists + +msgtest 'Download of nothing else in forced language' 'without Index' +aptget update -o Acquire::Languages=en | grep -q -e 'Translation-[^e][^n] ' && msgfail || msgpass +rm -rf rootdir/var/lib/apt/lists + +msgtest 'Download of ast_DE as forced language' 'without Index' +aptget update -o Acquire::Languages=ast_DE | grep -q -e 'Translation-ast_DE$' && msgpass || msgfail +rm -rf rootdir/var/lib/apt/lists + +msgtest 'Download of nothing else in forced language' 'without Index' +aptget update -o Acquire::Languages=ast_DE | grep -q -e 'Translation-[^a][^s]' && msgfail || msgpass +rm -rf rootdir/var/lib/apt/lists + +msgtest 'Download of nothing if none is forced' 'without Index' +aptget update -o Acquire::Languages=none | grep -q -e 'Translation' && msgfail || msgpass +rm -rf rootdir/var/lib/apt/lists + +mkdir -p rootdir/var/lib/apt/lists +touch rootdir/var/lib/apt/lists/localhost:8080_dists_unstable_main_i18n_Translation-ast_DE + +msgtest 'Download of builtin files' 'without Index' +aptget update | grep -q -e 'Translation-ast_DE' && msgpass || msgfail +rm -rf rootdir/var/lib/apt/lists + +mkdir -p rootdir/var/lib/apt/lists +touch rootdir/var/lib/apt/lists/localhost:8080_dists_unstable_main_i18n_Translation-ast_DE + +msgtest 'Download of nothing (even builtin) if none is forced' 'without Index' +aptget update -o Acquire::Languages=none | grep -q -e 'Translation' && msgfail || msgpass +rm -rf rootdir/var/lib/apt/lists diff --git a/test/libapt/assert.h b/test/libapt/assert.h index fae9b6c64..ce5accc1c 100644 --- a/test/libapt/assert.h +++ b/test/libapt/assert.h @@ -54,6 +54,21 @@ void assertEqualsOr2(int const &expect1, int const &expect2, unsigned int const } +#define equalsOr3(w,x,y,z) assertEqualsOr3(x, y, z, w, __LINE__) + +template < typename X, typename Y > +void OutputAssertEqualOr3(X expect1, X expect2, X expect3, char const* compare, Y get, unsigned long const &line) { + std::cerr << "Test FAILED: »" << expect1 << "« or »" << expect2 << "« or »" << expect3 << "« " << compare << " »" << get << "« at line " << line << std::endl; +} + +template < typename X, typename Y > +void assertEqualsOr3(X expect1, X expect2, X expect3, Y get, unsigned long const &line) { + if (expect1 == get || expect2 == get || expect3 == get) + return; + OutputAssertEqualOr3(expect1, expect2, expect3, "==", get, line); +} + + // simple helper to quickly output a vectors template < typename X > void dumpVector(X vec) { diff --git a/test/libapt/getlanguages_test.cc b/test/libapt/getlanguages_test.cc index f6aa7a697..a1c801ea2 100644 --- a/test/libapt/getlanguages_test.cc +++ b/test/libapt/getlanguages_test.cc @@ -126,13 +126,19 @@ int main(int argc,char *argv[]) _config->Set("Dir::State::lists", argv[1]); vec = APT::Configuration::getLanguages(true, false, env); - equals(vec.size(), 6); + equals(vec.size(), 7); equals(vec[0], "de_DE"); equals(vec[1], "de"); equals(vec[2], "en"); equals(vec[3], "none"); - equalsOr2(vec[4], "pt", "tr"); - equalsOr2(vec[5], "tr", "pt"); + equalsOr3(vec[4], "pt", "tr", "ast_DE"); + equalsOr3(vec[5], "tr", "pt", "ast_DE"); + equalsOr3(vec[6], "tr", "pt", "ast_DE"); + + _config->Set("Acquire::Languages", "none"); + vec = APT::Configuration::getLanguages(true, false, env); + equals(vec.size(), 0); + _config->Set("Acquire::Languages", ""); _config->Set("Dir::State::lists", "/non-existing-dir"); _config->Set("Acquire::Languages::1", "none"); diff --git a/test/libapt/run-tests b/test/libapt/run-tests index 275a789b2..9dad36f5b 100755 --- a/test/libapt/run-tests +++ b/test/libapt/run-tests @@ -64,7 +64,8 @@ do touch "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-tr" \ "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-pt" \ "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-se~" \ - "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-st.bak" + "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-st.bak" \ + "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-ast_DE" elif [ $name = "CompareVersion${EXT}" ]; then tmppath="${DIR}/versions.lst" fi |