From 1302746049a2fc833c410e9d704416b9cefde195 Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Sun, 23 Feb 2025 16:45:15 +0100 Subject: [PATCH 1/2] test-translations: display all hotkey conflicts at once ... instead of erroring out at the first conflict. Also display all options involved in a hotkey conflict to make fixing it easier. (cherry picked from commit 3e7e9bf01f5bbc950ed31f684e279d2979d5c9f0) Signed-off-by: John Johansen --- utils/test/test-translations.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/utils/test/test-translations.py b/utils/test/test-translations.py index a8c86f277..4b74d5c8b 100644 --- a/utils/test/test-translations.py +++ b/utils/test/test-translations.py @@ -59,6 +59,8 @@ class TestHotkeyConflicts(AATest): # we also want to detect hotkey conflicts in the untranslated english strings self.languages.append('C') + conflicts = [] + for language in self.languages: with self.subTest(language=language): t = gettext.translation( @@ -67,15 +69,25 @@ class TestHotkeyConflicts(AATest): ) keys = {} + all_keys = [] + found_conflict = '' + for key in params: text = t.gettext(CMDS[key]) + all_keys.append(text) hotkey = get_translated_hotkey(text) if keys.get(hotkey): - raise Exception("Hotkey conflict: '{}' and '{}'".format(keys[hotkey], text)) + found_conflict = "Hotkey conflict for {}: '{}' and '{}'".format(language, keys[hotkey], text) else: keys[hotkey] = text + if found_conflict: + conflicts.append("{}\n {}'".format(found_conflict, ' '.join(all_keys))) + + if conflicts: + raise Exception('\n'.join(conflicts)) + setup_all_loops(__name__) if __name__ == '__main__': From 662d3dd610bbd307d2d1dde91b586520545f9580 Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Thu, 20 Feb 2025 19:34:34 +0100 Subject: [PATCH 2/2] test-translations: include "ignore" in exec prompts This is a follow-up of adding the "ignore" option to exec prompts in https://gitlab.com/apparmor/apparmor/-/merge_requests/1543 (cherry picked from commit db7e3109cc8c0659fc5eab91fc73564f40ed5f1f) Signed-off-by: John Johansen --- utils/test/test-translations.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/test/test-translations.py b/utils/test/test-translations.py index 4b74d5c8b..95a186d71 100644 --- a/utils/test/test-translations.py +++ b/utils/test/test-translations.py @@ -29,8 +29,8 @@ class TestHotkeyConflicts(AATest): (('CMD_ALLOW', 'CMD_DENY', 'CMD_IGNORE_ENTRY', 'CMD_GLOB', 'CMD_GLOBEXT', 'CMD_NEW', 'CMD_AUDIT_NEW', 'CMD_USER_OFF', 'CMD_ABORT', 'CMD_FINISHED'), True), # aa.py available_buttons() with CMD_AUDIT_NEW and CMD_USER_OFF (('CMD_SAVE_CHANGES', 'CMD_SAVE_SELECTED', 'CMD_VIEW_CHANGES', 'CMD_VIEW_CHANGES_CLEAN', 'CMD_ABORT'), True), # aa.py save_profiles() (('CMD_VIEW_PROFILE', 'CMD_USE_PROFILE', 'CMD_CREATE_PROFILE', 'CMD_ABORT'), True), # aa.py get_profile() - (('CMD_ix', 'CMD_pix', 'CMD_cix', 'CMD_nix', 'CMD_EXEC_IX_OFF', 'CMD_ux', 'CMD_DENY', 'CMD_ABORT', 'CMD_FINISHED'), True), # aa.py build_x_functions() with exec_toggle - (('CMD_ix', 'CMD_cx', 'CMD_px', 'CMD_nx', 'CMD_ux', 'CMD_EXEC_IX_ON', 'CMD_DENY', 'CMD_ABORT', 'CMD_FINISHED'), True), # aa.py build_x_functions() without exec_toggle + (('CMD_ix', 'CMD_pix', 'CMD_cix', 'CMD_nix', 'CMD_EXEC_IX_OFF', 'CMD_ux', 'CMD_DENY', 'CMD_ABORT', 'CMD_FINISHED', 'CMD_IGNORE_ENTRY'), True), # aa.py build_x_functions() with exec_toggle + (('CMD_ix', 'CMD_cx', 'CMD_px', 'CMD_nx', 'CMD_ux', 'CMD_EXEC_IX_ON', 'CMD_DENY', 'CMD_ABORT', 'CMD_FINISHED', 'CMD_IGNORE_ENTRY'), True), # aa.py build_x_functions() without exec_toggle (('CMD_ADDHAT', 'CMD_USEDEFAULT', 'CMD_DENY', 'CMD_ABORT', 'CMD_FINISHED'), True), # aa.py ask_addhat() (('CMD_YES', 'CMD_NO', 'CMD_CANCEL'), True), # ui.py UI_YesNo() and UI_YesNoCancel (('CMD_SAVE_CHANGES', 'CMD_VIEW_CHANGES', 'CMD_ABORT', 'CMD_IGNORE_ENTRY'), True), # aa-mergeprof act()