From 19033186919b9c6d31ca3aabaacfb069a4b64f88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9=20=D0=A8=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=D0=BD?= Date: Mon, 25 Nov 2019 09:59:38 +0000 Subject: Search in all available description translations When multiple translations of package descriptions are available, perform search in all of them. It allows using search patterns in any of the configured languages. Previously, only the first available translation was searched. As the result, patterns in e.g. English never matched packages which had their descriptions translated into local language. Closes: #490000 --- .../test-bug-490000-search-in-all-translations | 107 +++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100755 test/integration/test-bug-490000-search-in-all-translations (limited to 'test') diff --git a/test/integration/test-bug-490000-search-in-all-translations b/test/integration/test-bug-490000-search-in-all-translations new file mode 100755 index 000000000..3a034bc49 --- /dev/null +++ b/test/integration/test-bug-490000-search-in-all-translations @@ -0,0 +1,107 @@ +#!/bin/sh + +set -e + +TESTDIR="$(readlink -f "$(dirname "$0")")" +. "${TESTDIR}/framework" + +setupenvironment + +ARCH='amd64' +DIST='unstable' + +PKG_NAME='foo' +PKG_VERSION='1.0' + +SHORT_DESCRIPTION_EN='have you fooed today?' +LONG_DESCRIPTION_EN="${SHORT_DESCRIPTION_EN} + Where there's foo, there's fire." + +SHORT_DESCRIPTION_ZZ='bar alter ego' +LONG_DESCRIPTION_ZZ="${SHORT_DESCRIPTION_ZZ} + He who foos last foos best." + +configure_languages() +{ + { + echo '#clear Acquire::Languages;' + echo 'Acquire::Languages {' + for language in "$@" + do + echo " \"${language}\";" + done + echo '};' + } > rootdir/etc/apt/apt.conf.d/languages.conf +} + +new_translation_record() +{ + echo "Package: ${1:?Package name expected}" + echo "Description-md5: ${2:?Description-md5 expected}" + echo "Description-${3:?Language code expected}: ${4:?Package description expected}" + echo +} + +str_md5sum() +{ + echo -n "${1:?String expected}" | md5sum | cut -d ' ' -f 1 +} + +configarchitecture "${ARCH}" + +insertpackage "${DIST}" "${PKG_NAME}" "${ARCH}" "${PKG_VERSION}" '' '' "${LONG_DESCRIPTION_EN}" +# English translation was already added by insertpackage above +new_translation_record "${PKG_NAME}" "$(str_md5sum "${LONG_DESCRIPTION_EN}")" 'zz' "${LONG_DESCRIPTION_ZZ}" > "aptarchive/dists/${DIST}/main/i18n/Translation-zz" + +configure_languages en zz +setupaptarchive + +# =========================== +# +# Tests +# +# =========================== + +# ----------[ apt ]---------- + +# Test that all translations are searched, but the short +# description is in the first configured language + +configure_languages en zz +testequal "${PKG_NAME}/${DIST} ${PKG_VERSION} ${ARCH} + ${SHORT_DESCRIPTION_EN} +" apt -qq search alter ego + +configure_languages zz en +testequal "${PKG_NAME}/${DIST} ${PKG_VERSION} ${ARCH} + ${SHORT_DESCRIPTION_ZZ} +" apt -qq search you today + +# Search in configured languages only +configure_languages zz +testempty apt -qq search where fire + +# Patterns are AND-ed i.e. all must match against a single +# description translation +configure_languages en zz +testempty apt -qq search there best + +# -------[ apt-cache ]------- + +# Test that all translations are searched, but the short +# description is in the first configured language + +configure_languages en zz +testequal "${PKG_NAME} - ${SHORT_DESCRIPTION_EN}" aptcache search alter ego + +configure_languages zz en +testequal "${PKG_NAME} - ${SHORT_DESCRIPTION_ZZ}" aptcache search you today + +# Search in configured languages only +configure_languages zz +testempty aptcache search where fire + +# Patterns are AND-ed i.e. all must match against a single +# description translation +configure_languages en zz +testempty aptcache search there best -- cgit v1.2.3