diff --git a/app/xdg-app-main.c b/app/xdg-app-main.c index 9f0a642d..9cf751ea 100644 --- a/app/xdg-app-main.c +++ b/app/xdg-app-main.c @@ -30,9 +30,11 @@ #include "libgsystem.h" #include "xdg-app-builtins.h" +#include "xdg-app-utils.h" static gboolean opt_verbose; static gboolean opt_version; +static gboolean opt_default_arch; static gboolean opt_user; typedef struct { @@ -80,6 +82,7 @@ static XdgAppCommand commands[] = { static GOptionEntry global_entries[] = { { "verbose", 'v', 0, G_OPTION_ARG_NONE, &opt_verbose, "Print debug information during command processing", NULL }, { "version", 0, 0, G_OPTION_ARG_NONE, &opt_version, "Print version information and exit", NULL }, + { "default-arch", 0, 0, G_OPTION_ARG_NONE, &opt_default_arch, "Print default arch and exit", NULL }, { NULL } }; @@ -187,6 +190,12 @@ xdg_app_option_context_parse (GOptionContext *context, exit (EXIT_SUCCESS); } + if (opt_default_arch) + { + g_print ("%s\n", xdg_app_get_arch ()); + exit (EXIT_SUCCESS); + } + if (!(flags & XDG_APP_BUILTIN_FLAG_NO_DIR)) { dir = xdg_app_dir_get (opt_user); diff --git a/tests/libtest.sh b/tests/libtest.sh index a440835e..caae1dd5 100644 --- a/tests/libtest.sh +++ b/tests/libtest.sh @@ -72,6 +72,9 @@ TEST_DATA_DIR=`mktemp -d /var/tmp/test-xdg-app-XXXXXX` export XDG_DATA_HOME=${TEST_DATA_DIR}/share +export USERDIR=${TEST_DATA_DIR}/share/xdg-app +export ARCH=`xdg-app --default-arch` + export XDG_APP="${CMD_PREFIX} xdg-app" assert_streq () { @@ -86,6 +89,10 @@ assert_has_file () { test -f "$1" || (echo 1>&2 "Couldn't find '$1'"; exit 1) } +assert_has_symlink () { + test -L "$1" || (echo 1>&2 "Couldn't find '$1'"; exit 1) +} + assert_has_dir () { test -d "$1" || (echo 1>&2 "Couldn't find '$1'"; exit 1) } @@ -120,6 +127,14 @@ assert_file_has_content () { fi } +assert_symlink_has_content () { + if ! readlink "$1" | grep -q -e "$2"; then + readlink "$1" |sed -e 's/^/# /' >&2 + echo 1>&2 "Symlink '$1' doesn't match regexp '$2'" + exit 1 + fi +} + assert_file_empty() { if test -s "$1"; then sed -e 's/^/# /' < "$1" >&2 @@ -144,6 +159,10 @@ run () { } +run_sh () { + ${CMD_PREFIX} xdg-app run --command=bash org.test.Hello -c "$*" +} + sed s#@testdir@#${test_builddir}# ${test_srcdir}/session.conf.in > session.conf eval `dbus-launch --config-file=session.conf --sh-syntax` diff --git a/tests/make-test-app.sh b/tests/make-test-app.sh index b5bce5a0..20683e46 100755 --- a/tests/make-test-app.sh +++ b/tests/make-test-app.sh @@ -14,6 +14,20 @@ echo "Hello world, from a sandbox" EOF chmod a+x ${DIR}/files/bin/hello.sh +mkdir -p ${DIR}/files/share/applications +cat > ${DIR}/files/share/applications/org.test.Hello.desktop < ${DIR}/files/share/app-info/xmls/org.test.Hello.xml.gz < hello_out assert_file_has_content hello_out '^Hello world, from a sandbox$' echo "ok hello" + +run_sh cat /run/user/`id -u`/xdg-app-info > xai +assert_file_has_content xai '^name=org.test.Hello$' + +echo "ok xdg-app-info"