tests: Factor out additional env vars mechanism

Make the mechanism more general, so that other tests can now specify
overrides for various defaults, if needed.

This replicates what GLib does:
https://gitlab.gnome.org/GNOME/glib/-/blob/main/glib/tests/meson.build#L475.

It introduces no functional changes in how the current set of tests run.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3605>
This commit is contained in:
Philip Withnall 2025-01-21 13:52:08 +00:00 committed by Marge Bot
parent a3d4198c85
commit bba85e1fcd

View File

@ -19,29 +19,30 @@ unit_testenv.append('GI_TYPELIB_PATH', gvc_typelib_path, separator: ':')
unit_testenv.append('GI_TYPELIB_PATH', shell_typelib_path, separator: ':') unit_testenv.append('GI_TYPELIB_PATH', shell_typelib_path, separator: ':')
unit_testenv.append('GI_TYPELIB_PATH', st_typelib_path, separator: ':') unit_testenv.append('GI_TYPELIB_PATH', st_typelib_path, separator: ':')
unit_tests = [ unit_tests = {
'breakManager', 'breakManager': {},
'extensionUtils', 'extensionUtils': {},
'highlighter', 'highlighter': {},
'injectionManager', 'injectionManager': {},
'insertSorted', 'insertSorted': {},
'jsParse', 'jsParse': {},
'markup', 'markup': {},
'params', 'params': {},
'signalTracker', 'signalTracker': {},
'timeLimitsManager', 'timeLimitsManager': {
'url', # The time limits tests hard-code UTC to keep the code brief, so must be
'versionCompare', # run in UTC
] 'env': { 'TZ': 'UTC' },
},
'url': {},
'versionCompare': {},
}
foreach test : unit_tests foreach test, extra_args : unit_tests
local_test_env = unit_testenv local_test_env = unit_testenv
foreach var, value : extra_args.get('env', {})
# The time limits tests hard-code UTC to keep the code brief, so must be run local_test_env.append(var, value)
# in UTC endforeach
if test == 'timeLimitsManager'
local_test_env.set('TZ', 'UTC')
endif
test(test, jasmine, test(test, jasmine,
args: [ args: [