From d680da8d5906de1bfd8f4ed047e6d8a29660a656 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Mon, 2 May 2016 15:49:18 +0200 Subject: Added xdg-app-builder test --- tests/Makefile.am.inc | 2 ++ tests/libtest.sh | 9 +++++++ tests/test-builder.sh | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/test.json | 53 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 131 insertions(+) create mode 100755 tests/test-builder.sh create mode 100644 tests/test.json (limited to 'tests') diff --git a/tests/Makefile.am.inc b/tests/Makefile.am.inc index 413798f..7692bea 100644 --- a/tests/Makefile.am.inc +++ b/tests/Makefile.am.inc @@ -59,12 +59,14 @@ installed_test_SCRIPTS += \ installed_test_data = \ tests/org.test.Hello.png \ + tests/configure.test \ tests/session.conf.in \ $(NULL) test_scripts = \ tests/test-basic.sh \ tests/test-run.sh \ + tests/test-builder.sh \ $(NULL) test_programs = testdb test-doc-portal diff --git a/tests/libtest.sh b/tests/libtest.sh index 060a934..63800ff 100644 --- a/tests/libtest.sh +++ b/tests/libtest.sh @@ -149,11 +149,20 @@ setup_repo () { xdg-app remote-add --user --no-gpg-verify test-repo repo } +setup_sdk_repo () { + . $(dirname $0)/make-test-runtime.sh org.test.Sdk bash ls cat echo readlink make mkdir cp touch > /dev/null +} + + install_repo () { ${XDG_APP} --user install test-repo org.test.Platform master ${XDG_APP} --user install test-repo org.test.Hello master } +install_sdk_repo () { + ${XDG_APP} --user install test-repo org.test.Sdk master +} + run () { ${CMD_PREFIX} xdg-app run "$@" diff --git a/tests/test-builder.sh b/tests/test-builder.sh new file mode 100755 index 0000000..a7d9d02 --- /dev/null +++ b/tests/test-builder.sh @@ -0,0 +1,67 @@ +#!/bin/bash +# +# Copyright (C) 2011 Colin Walters +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +set -euo pipefail + +. $(dirname $0)/libtest.sh + +echo "1..3" + +setup_repo +install_repo +setup_sdk_repo +install_sdk_repo + +cp -a $(dirname $0)/configure.test . +echo "version1" > app-data +xdg-app-builder --repo=repo --force-clean appdir $(dirname $0)/test.json + +assert_file_has_content appdir/files/share/app-data version1 +assert_file_has_content appdir/metadata shared=network; +assert_file_has_content appdir/metadata tags=test; + +assert_not_has_file appdir/files/cleanup/a_filee +assert_not_has_file appdir/files/bin/file.cleanup + +assert_has_file appdir/files/cleaned_up > out + +${XDG_APP} build appdir /app/bin/hello2.sh > hello_out2 +assert_file_has_content hello_out2 '^Hello world2, from a sandbox$' + +echo "ok build" + +${XDG_APP} --user install test-repo org.test.Hello2 master +run org.test.Hello2 > hello_out3 +assert_file_has_content hello_out3 '^Hello world2, from a sandbox$' + +run --command=cat org.test.Hello2 /app/share/app-data > app_data_1 +assert_file_has_content app_data_1 version1 + +echo "ok install+run" + +echo "version2" > app-data +xdg-app-builder --repo=repo --force-clean appdir $(dirname $0)/test.json +assert_file_has_content appdir/files/share/app-data version2 + +${XDG_APP} --user update org.test.Hello2 master + +run --command=cat org.test.Hello2 /app/share/app-data > app_data_2 +assert_file_has_content app_data_2 version2 + +echo "ok update" diff --git a/tests/test.json b/tests/test.json new file mode 100644 index 0000000..fdab276 --- /dev/null +++ b/tests/test.json @@ -0,0 +1,53 @@ +{ + "app-id": "org.test.Hello2", + "runtime": "org.test.Platform", + "sdk": "org.test.Sdk", + "command": "hello2.sh", + "tags": ["test"], + "finish-args": [ + "--share=network" + ], + "build-options" : { + "cflags": "-O2 -g", + "cxxflags": "-O2 -g", + "env": { + "FOO": "bar", + "V": "1" + } + }, + "cleanup": ["/cleanup", "*.cleanup"], + "cleanup-commands": [ "touch /app/cleaned_up" ], + "modules": [ + { + "name": "test", + "config-opts": ["--some-arg"], + "post-install": [ "touch /app/bin/file.cleanup" ], + "make-args": ["BAR=2" ], + "make-install-args": ["BAR=3" ], + "sources": [ + { + "type": "file", + "path": "configure.test", + "dest-filename": "configure", + "sha256": "fb62c2826dbd2fda27e878490e3f1f9081b1b69a2211e125ae79cf552a7a2254" + }, + { + "type": "file", + "path": "app-data" + }, + { + "type": "script", + "dest-filename": "hello2.sh", + "commands": [ "echo \"Hello world2, from a sandbox\"" ] + }, + { + "type": "shell", + "commands": [ + "mkdir /app/cleanup/", + "touch /app/cleanup/a_file" + ] + } + ] + } + ] +} -- cgit v1.2.1