From 4a852c9522b60becca122856372a08b0352b732c Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Tue, 26 Nov 2024 17:56:04 +0100 Subject: [PATCH 1/2] chore(linux): rename test files This change rename the test files for Linux according to the discussion at the Keyman conference in November 2024. Python is pretty opinionated about the naming of files, so we have to use `*_tests.py` as test filename instead of the usual `*.tests.py`. --- linux/.gitignore | 2 +- .../test/{bcp47util_tests.c => bcp47util.tests.c} | 0 .../test/{keymanutil_tests.c => keymanutil.tests.c} | 0 linux/ibus-keyman/src/test/meson.build | 4 ++-- linux/keyman-config/run-tests.sh | 12 ++++++------ .../tests/{test_bcp47tag.py => bcp47tag_tests.py} | 0 ...ils.py => canonical_language_code_utils_tests.py} | 0 ...custom_keyboards.py => custom_keyboards_tests.py} | 0 .../{test_dconf_util.py => dconf_util_tests.py} | 0 .../tests/{test_get_kmp.py => get_kmp_tests.py} | 0 ...yboards_util.py => gnome_keyboards_util_tests.py} | 0 .../tests/{test_gsettings.py => gsettings_tests.py} | 0 ...est_handle_install.py => handle_install_tests.py} | 0 .../tests/{test_ibus_util.py => ibus_util_tests.py} | 0 .../{test_install_kmp.py => install_kmp_tests.py} | 0 .../tests/{test_kvk2ldml.py => kvk2ldml_tests.py} | 0 ...{test_lang_tags_map.py => lang_tags_map_tests.py} | 0 ...letion.py => package_install_completion_tests.py} | 0 ...{test_uninstall_kmp.py => uninstall_kmp_tests.py} | 0 19 files changed, 9 insertions(+), 9 deletions(-) rename linux/ibus-keyman/src/test/{bcp47util_tests.c => bcp47util.tests.c} (100%) rename linux/ibus-keyman/src/test/{keymanutil_tests.c => keymanutil.tests.c} (100%) rename linux/keyman-config/tests/{test_bcp47tag.py => bcp47tag_tests.py} (100%) rename linux/keyman-config/tests/{test_canonical_language_code_utils.py => canonical_language_code_utils_tests.py} (100%) rename linux/keyman-config/tests/{test_custom_keyboards.py => custom_keyboards_tests.py} (100%) rename linux/keyman-config/tests/{test_dconf_util.py => dconf_util_tests.py} (100%) rename linux/keyman-config/tests/{test_get_kmp.py => get_kmp_tests.py} (100%) rename linux/keyman-config/tests/{test_gnome_keyboards_util.py => gnome_keyboards_util_tests.py} (100%) rename linux/keyman-config/tests/{test_gsettings.py => gsettings_tests.py} (100%) rename linux/keyman-config/tests/{test_handle_install.py => handle_install_tests.py} (100%) rename linux/keyman-config/tests/{test_ibus_util.py => ibus_util_tests.py} (100%) rename linux/keyman-config/tests/{test_install_kmp.py => install_kmp_tests.py} (100%) rename linux/keyman-config/tests/{test_kvk2ldml.py => kvk2ldml_tests.py} (100%) rename linux/keyman-config/tests/{test_lang_tags_map.py => lang_tags_map_tests.py} (100%) rename linux/keyman-config/tests/{test_package_install_completion.py => package_install_completion_tests.py} (100%) rename linux/keyman-config/tests/{test_uninstall_kmp.py => uninstall_kmp_tests.py} (100%) diff --git a/linux/.gitignore b/linux/.gitignore index f85acc0f35d..a67e991b302 100644 --- a/linux/.gitignore +++ b/linux/.gitignore @@ -31,7 +31,7 @@ debianpackage/ *.tar.xz *.tar.gz *.dsc -help/reference/ +docs/help/reference/ # Cached/auto-compiled Python bytecode *.pyc diff --git a/linux/ibus-keyman/src/test/bcp47util_tests.c b/linux/ibus-keyman/src/test/bcp47util.tests.c similarity index 100% rename from linux/ibus-keyman/src/test/bcp47util_tests.c rename to linux/ibus-keyman/src/test/bcp47util.tests.c diff --git a/linux/ibus-keyman/src/test/keymanutil_tests.c b/linux/ibus-keyman/src/test/keymanutil.tests.c similarity index 100% rename from linux/ibus-keyman/src/test/keymanutil_tests.c rename to linux/ibus-keyman/src/test/keymanutil.tests.c diff --git a/linux/ibus-keyman/src/test/meson.build b/linux/ibus-keyman/src/test/meson.build index 333f05c212a..f1f34a63c5b 100644 --- a/linux/ibus-keyman/src/test/meson.build +++ b/linux/ibus-keyman/src/test/meson.build @@ -1,5 +1,5 @@ keymanutil_sources = [ - 'keymanutil_tests.c', + 'keymanutil.tests.c', util_files, ] @@ -55,7 +55,7 @@ print_kmp_test = executable( bcp47_util_tests = executable( 'bcp47-util-tests', sources: [ - 'bcp47util_tests.c', + 'bcp47util.tests.c', '../bcp47util.c' ], dependencies: [ gtk, icu ], diff --git a/linux/keyman-config/run-tests.sh b/linux/keyman-config/run-tests.sh index de99c55e8f2..41904e4cf31 100755 --- a/linux/keyman-config/run-tests.sh +++ b/linux/keyman-config/run-tests.sh @@ -1,18 +1,18 @@ #!/bin/bash -PYTHONPATH=.:$PYTHONPATH +PYTHONPATH=.:${PYTHONPATH} XDG_CONFIG_HOME=$(mktemp --directory) export XDG_CONFIG_HOME -if [ -f /usr/libexec/ibus-memconf ]; then +if [[ -f /usr/libexec/ibus-memconf ]]; then export GSETTINGS_BACKEND=keyfile fi -if [ "$1" == "--coverage" ]; then +if [[ "$1" == "--coverage" ]]; then coverage="-m coverage run --source=. --data-file=build/.coverage" fi -if [ -n "$TEAMCITY_VERSION" ]; then +if [[ -n "${TEAMCITY_VERSION}" ]]; then if ! pip3 list --format=columns | grep -q teamcity-messages; then pip3 install teamcity-messages fi @@ -23,6 +23,6 @@ else fi # shellcheck disable=SC2086 -python3 ${coverage:-} -m ${test_module:-} discover ${extra_opts:-} -s tests -p test_*.py +python3 ${coverage:-} -m "${test_module:-}" discover ${extra_opts:-} -s tests/ -p "*_tests.py" -rm -rf "$XDG_CONFIG_HOME" +rm -rf "${XDG_CONFIG_HOME}" diff --git a/linux/keyman-config/tests/test_bcp47tag.py b/linux/keyman-config/tests/bcp47tag_tests.py similarity index 100% rename from linux/keyman-config/tests/test_bcp47tag.py rename to linux/keyman-config/tests/bcp47tag_tests.py diff --git a/linux/keyman-config/tests/test_canonical_language_code_utils.py b/linux/keyman-config/tests/canonical_language_code_utils_tests.py similarity index 100% rename from linux/keyman-config/tests/test_canonical_language_code_utils.py rename to linux/keyman-config/tests/canonical_language_code_utils_tests.py diff --git a/linux/keyman-config/tests/test_custom_keyboards.py b/linux/keyman-config/tests/custom_keyboards_tests.py similarity index 100% rename from linux/keyman-config/tests/test_custom_keyboards.py rename to linux/keyman-config/tests/custom_keyboards_tests.py diff --git a/linux/keyman-config/tests/test_dconf_util.py b/linux/keyman-config/tests/dconf_util_tests.py similarity index 100% rename from linux/keyman-config/tests/test_dconf_util.py rename to linux/keyman-config/tests/dconf_util_tests.py diff --git a/linux/keyman-config/tests/test_get_kmp.py b/linux/keyman-config/tests/get_kmp_tests.py similarity index 100% rename from linux/keyman-config/tests/test_get_kmp.py rename to linux/keyman-config/tests/get_kmp_tests.py diff --git a/linux/keyman-config/tests/test_gnome_keyboards_util.py b/linux/keyman-config/tests/gnome_keyboards_util_tests.py similarity index 100% rename from linux/keyman-config/tests/test_gnome_keyboards_util.py rename to linux/keyman-config/tests/gnome_keyboards_util_tests.py diff --git a/linux/keyman-config/tests/test_gsettings.py b/linux/keyman-config/tests/gsettings_tests.py similarity index 100% rename from linux/keyman-config/tests/test_gsettings.py rename to linux/keyman-config/tests/gsettings_tests.py diff --git a/linux/keyman-config/tests/test_handle_install.py b/linux/keyman-config/tests/handle_install_tests.py similarity index 100% rename from linux/keyman-config/tests/test_handle_install.py rename to linux/keyman-config/tests/handle_install_tests.py diff --git a/linux/keyman-config/tests/test_ibus_util.py b/linux/keyman-config/tests/ibus_util_tests.py similarity index 100% rename from linux/keyman-config/tests/test_ibus_util.py rename to linux/keyman-config/tests/ibus_util_tests.py diff --git a/linux/keyman-config/tests/test_install_kmp.py b/linux/keyman-config/tests/install_kmp_tests.py similarity index 100% rename from linux/keyman-config/tests/test_install_kmp.py rename to linux/keyman-config/tests/install_kmp_tests.py diff --git a/linux/keyman-config/tests/test_kvk2ldml.py b/linux/keyman-config/tests/kvk2ldml_tests.py similarity index 100% rename from linux/keyman-config/tests/test_kvk2ldml.py rename to linux/keyman-config/tests/kvk2ldml_tests.py diff --git a/linux/keyman-config/tests/test_lang_tags_map.py b/linux/keyman-config/tests/lang_tags_map_tests.py similarity index 100% rename from linux/keyman-config/tests/test_lang_tags_map.py rename to linux/keyman-config/tests/lang_tags_map_tests.py diff --git a/linux/keyman-config/tests/test_package_install_completion.py b/linux/keyman-config/tests/package_install_completion_tests.py similarity index 100% rename from linux/keyman-config/tests/test_package_install_completion.py rename to linux/keyman-config/tests/package_install_completion_tests.py diff --git a/linux/keyman-config/tests/test_uninstall_kmp.py b/linux/keyman-config/tests/uninstall_kmp_tests.py similarity index 100% rename from linux/keyman-config/tests/test_uninstall_kmp.py rename to linux/keyman-config/tests/uninstall_kmp_tests.py From 7edda3becaa1153c60ee8a93870a3711322d40fa Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Wed, 27 Nov 2024 10:16:58 +0100 Subject: [PATCH 2/2] chore(linux): address code review comments --- docs/linux/README.md | 4 ++++ docs/linux/keyman-config.md | 2 +- docs/settings/linux/launch.json | 2 +- docs/settings/linux/settings.json | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/linux/README.md b/docs/linux/README.md index fe29b0d623a..80c1a78434c 100644 --- a/docs/linux/README.md +++ b/docs/linux/README.md @@ -64,6 +64,10 @@ To just run the unit tests without integration tests, add the It's also possible to only run the tests for one of the subprojects. You can use `build.sh` in the subdirectory for that. +Unit tests should be named after the file/class they are testing and +follow the pattern `*.tests.` (e.g. `keymanutil.tests.c`) or +for Python `*_tests.py`. + ### ibus-keyman If you want to run the ibus-keyman tests with Wayland, you'll have to diff --git a/docs/linux/keyman-config.md b/docs/linux/keyman-config.md index 93ed3ffd8bf..1a039d0f5e0 100644 --- a/docs/linux/keyman-config.md +++ b/docs/linux/keyman-config.md @@ -200,7 +200,7 @@ LANGUAGE=de ./km-config "python.testing.unittestArgs": [ "-v", "-s", "linux/keyman-config/tests", - "-p", "test_*.py" + "-p", "*_tests.py" ], "python.testing.unittestEnabled": true, ``` diff --git a/docs/settings/linux/launch.json b/docs/settings/linux/launch.json index e29c16fa451..fec5afe0ade 100644 --- a/docs/settings/linux/launch.json +++ b/docs/settings/linux/launch.json @@ -62,7 +62,7 @@ "request": "launch", "name": "Launch ibus-keyman unit tests", "target": "./keymanutil_tests", - "cwd": "${workspaceFolder}/linux/build/x86_64/debug/src/test", + "cwd": "${workspaceFolder}/linux/build/x86_64/debug/src/tests", "valuesFormatting": "parseText", "internalConsoleOptions": "openOnSessionStart", "env": { diff --git a/docs/settings/linux/settings.json b/docs/settings/linux/settings.json index 482630bdec7..3fd13430d1b 100644 --- a/docs/settings/linux/settings.json +++ b/docs/settings/linux/settings.json @@ -5,7 +5,7 @@ "python.testing.unittestArgs": [ "-v", "-s", "linux/keyman-config/tests", - "-p", "test_*.py" + "-p", "*_tests.py" ], "python.testing.unittestEnabled": true, "python.testing.pytestEnabled": false,