spiegel-keyman/linux/debian/tests/test-gnome-cli
Eberhard Beilharz 69513108e3
test(linux): add regression tests for cli tools to autopkgtests
This change adds tests that execute km-package-install,
km-package-list-installed, and km-package-uninstall and verifies the
results. We have two sets of tests, for both gnome-shell and
ibus-proper environments.

Test-bot: skip
2025-10-14 17:54:36 +02:00

104 lines
3.1 KiB
Bash
Executable file

#!/bin/bash
# shellcheck disable=SC1091
. "$(dirname "$0")/test-cli.inc.sh"
#-------------------------------------------------------------------------------
# gnome-shell tests
#-------------------------------------------------------------------------------
km_package_install__user() {
# Setup
gsettings set org.gnome.desktop.input-sources sources "[('xkb', 'us')]"
# Run
km-package-install --file "$(dirname "$0")/data/khmer_angkor.kmp"
# Verify
verify_no_error $?
verify_ibus_restarted
verify_keyboard_file_exists "${HOME}/.local/share/keyman/khmer_angkor/khmer_angkor.kmx"
verify_gnome_input_sources "[('xkb', 'us'), ('ibus', 'km:${HOME}/.local/share/keyman/khmer_angkor/khmer_angkor.kmx')]"
verify_custom_keyboards "@as []"
echo "PASS ${TEST_SCRIPT}/${FUNCNAME[0]}"
}
km_package_install__shared() {
# Setup - continue from previous tests
# Run
sudo km-package-install --shared --bcp47 ady --file "$(dirname "$0")/data/alephwithbeth.kmp"
# Verify
verify_no_error $?
verify_ibus_restarted
verify_keyboard_file_exists "/usr/local/share/keyman/alephwithbeth/alephwithbeth.kmx"
verify_gnome_input_sources "[('xkb', 'us'), ('ibus', 'km:${HOME}/.local/share/keyman/khmer_angkor/khmer_angkor.kmx'), ('ibus', 'ady:/usr/local/share/keyman/alephwithbeth/alephwithbeth.kmx')]"
verify_custom_keyboards "['ady:/usr/local/share/keyman/alephwithbeth/alephwithbeth.kmx']"
echo "PASS ${TEST_SCRIPT}/${FUNCNAME[0]}"
}
km_package_list_installed() {
# Setup - continue from previous tests
local result expected
# Run
result=$(km-package-list-installed)
# Verify
verify_no_error $?
expected="--- Installed user Keyman keyboard packages ---
Khmer Angkor, version: 1.5, id: khmer_angkor
--- Installed shared Keyman keyboard packages ---
Aleph With Beth, version: 1.0.6, id: alephwithbeth
--- Installed OS Keyman keyboard packages ---"
if [[ "${result}" != "${expected}" ]]; then
echo "FAIL ${TEST_SCRIPT}/${FUNCNAME[0]}: result wrong."
echo "EXPECTED:
${expected}"
echo "ACTUAL:
${result}"
exit 1
fi
echo "PASS ${FUNCNAME[0]}"
}
km_package_uninstall__user() {
# Setup - continue from previous tests
# Run
km-package-uninstall khmer_angkor
# Verify
verify_no_error $?
verify_keyboard_file_not_exists "${HOME}/.local/share/keyman/khmer_angkor/khmer_angkor.kmx"
verify_gnome_input_sources "[('xkb', 'us'), ('ibus', 'ady:/usr/local/share/keyman/alephwithbeth/alephwithbeth.kmx')]"
verify_custom_keyboards "['ady:/usr/local/share/keyman/alephwithbeth/alephwithbeth.kmx']"
echo "PASS ${TEST_SCRIPT}/${FUNCNAME[0]}"
}
km_package_uninstall__shared() {
# Setup - continue from previous tests
# Run
sudo km-package-uninstall --shared alephwithbeth
# Verify
verify_no_error $?
verify_keyboard_file_not_exists "/usr/local/share/keyman/alephwithbeth/alephwithbeth.kmx"
verify_gnome_input_sources "[('xkb', 'us')]"
verify_custom_keyboards "@as []"
echo "PASS ${TEST_SCRIPT}/${FUNCNAME[0]}"
}
#-------------------------------------------------------------------------------
# Simulate running gnome-shell
export XDG_CURRENT_DESKTOP=gnome
run_tests