From a3d4198c85b570be6a00443ad47cf945048b0e78 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Mon, 20 Jan 2025 19:00:09 +0000 Subject: [PATCH] tests: Run timeLimitsManager tests in UTC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In order to keep the test code brief, all expected times and dates are written as ISO 8601 strings in the test code, and use `Z` to specify UTC (again, to keep things brief). If the test is run under a significantly different timezone, the end-of-day timestamp changes significantly, as it’s calculated by the code-under-test using the local timezone. Avoid that issue by requiring the `timeLimitsManager` tests to always be run in UTC. The previous failure could be reproduced by running `TZ=Europe/Madrid meson test -C /opt/gnome/build/gnome-shell timeLimitsManager --verbose` — the test for “tracks a single day’s usage early in the morning” would fail. Signed-off-by: Philip Withnall Part-of: --- tests/meson.build | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/meson.build b/tests/meson.build index 1d2c220c9..5395e03ab 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -35,6 +35,14 @@ unit_tests = [ ] foreach test : unit_tests + local_test_env = unit_testenv + + # The time limits tests hard-code UTC to keep the code brief, so must be run + # in UTC + if test == 'timeLimitsManager' + local_test_env.set('TZ', 'UTC') + endif + test(test, jasmine, args: [ '--module', @@ -44,7 +52,7 @@ foreach test : unit_tests 'unit/@0@.js'.format(test), ], suite: 'unit', - env: unit_testenv, + env: local_test_env, protocol: 'tap', workdir: meson.current_source_dir()) endforeach