From d31c536f2414fc3238e9160b6db56fc409386b70 Mon Sep 17 00:00:00 2001 From: Pablo Zmdl <57864086+pabzm@users.noreply.github.com> Date: Thu, 19 Sep 2024 06:53:20 +0200 Subject: [PATCH] Fix test by make sorting independent of locale and case (#9640) * Install requited locale in container image One of the IMAP tests curiuosly ran successfully on Github-runners, but failed locally. This is the pre-condition for a fix. * Explicitly require mandatory locale for test This test works only if executed with LC_COLLATE=en_US * Schedule to rebuild testrunner image each week --- .ci/docker-images/Dockerfile | 4 ++++ .github/workflows/docker_image.yml | 3 +++ tests/Framework/ImapTest.php | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/.ci/docker-images/Dockerfile b/.ci/docker-images/Dockerfile index 5fec3c97d2..6e8947c3dc 100644 --- a/.ci/docker-images/Dockerfile +++ b/.ci/docker-images/Dockerfile @@ -24,8 +24,12 @@ RUN apt-get update \ aspell-de \ hunspell-en-us \ git \ + locales \ && apt-get clean +# Some tests require en_US.UTF-8 as locale. +RUN sed -i 's/^# en_US.UTF-8 /en_US.UTF-8 /' /etc/locale.gen && locale-gen + # TODO: Do we need the multiarch-args? What for? #RUN debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)" \ RUN docker-php-ext-configure gd --with-jpeg --with-freetype \ diff --git a/.github/workflows/docker_image.yml b/.github/workflows/docker_image.yml index a15c7345e5..3a921c79f7 100644 --- a/.github/workflows/docker_image.yml +++ b/.github/workflows/docker_image.yml @@ -5,6 +5,9 @@ on: paths: - '.ci/docker-images/*' - '.github/workflows/docker_image.yml' + schedule: + # Rebuild automatically each monday early morning. + - cron: "42 5 * * 1" jobs: build_and_push: diff --git a/tests/Framework/ImapTest.php b/tests/Framework/ImapTest.php index cd539302f2..cbc2aeb140 100644 --- a/tests/Framework/ImapTest.php +++ b/tests/Framework/ImapTest.php @@ -47,6 +47,11 @@ public function test_convert_criteria() */ public function test_sort_folder_list() { + // The sorting requires this locale. + if (setlocale(\LC_ALL, 'en_US.UTF-8', 'en_US.utf8', 'en_US', 'en-US') === false) { + throw new \Error('This test requires `en_US` to be settable as locale, but those appear to not be present in your environment!'); + } + $_SESSION['imap_delimiter'] = '.'; $_SESSION['imap_namespace'] = [ 'personal' => null,