summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2016-05-02 15:49:18 +0200
committerAlexander Larsson <alexl@redhat.com>2016-05-02 15:49:18 +0200
commitd680da8d5906de1bfd8f4ed047e6d8a29660a656 (patch)
tree5ef23a9c61ed2de79f1801bcf67047bff6673d54 /tests
parentdcfb950c3175fa613b368bb442e2934956c90649 (diff)
downloadxdg-app-d680da8d5906de1bfd8f4ed047e6d8a29660a656.tar.gz
Added xdg-app-builder test
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am.inc2
-rw-r--r--tests/libtest.sh9
-rwxr-xr-xtests/test-builder.sh67
-rw-r--r--tests/test.json53
4 files changed, 131 insertions, 0 deletions
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 <walters@verbum.org>
+#
+# 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"
+ ]
+ }
+ ]
+ }
+ ]
+}