xhost + # Workaround for: QXcbConnection: Could not connect to display :0
[appimagekit.git] / test-appimagetool.sh
blob9d4b0fc4df13a30c4ea93564b196438e51103086
1 #! /bin/bash
3 set -xe
5 # this script attempts to package appimagetool as an AppImage with... surprise, appimagetool
7 tempdir=$(mktemp -d /tmp/appimage-test.XXXXXXXX)
8 thisdir=$(dirname $(readlink -f "$0"))
10 export PATH="$thisdir/squashfs-tools/squashfs-tools:$PATH"
12 appimagetool=$(readlink -f "$1")
14 if [ ! -x "$appimagetool" ]; then
15 echo "Usage: $0 <path to appimagetool>"
16 exit 1
19 cleanup() { rm -r "$tempdir"; }
20 trap cleanup EXIT
22 cd "$tempdir"
24 if [ "$TRAVIS" == true ]; then
25 # TODO: find way to get colored log on Travis
26 log() { echo "$*"; }
27 else
28 log() { echo "$(tput setaf 2)$(tput bold)$*$(tput sgr0)"; }
31 log "create a sample AppDir"
32 mkdir -p appimagetool.AppDir/usr/share/metainfo/
33 cp "$thisdir"/resources/{appimagetool.*,AppRun} appimagetool.AppDir/
34 cp "$thisdir"/resources/usr/share/metainfo/appimagetool.appdata.xml appimagetool.AppDir/usr/share/metainfo/
35 cp "$appimagetool" appimagetool.AppDir/
36 mkdir -p appimagetool.AppDir/usr/share/applications
37 cp appimagetool.AppDir/appimagetool.desktop appimagetool.AppDir/usr/share/applications
39 log "create a file that should be ignored"
40 touch appimagetool.AppDir/to-be-ignored
42 log "create an AppImage without an ignore file to make sure it is bundled"
43 $appimagetool appimagetool.AppDir appimagetool.AppImage || exit $?
44 $appimagetool -l appimagetool.AppImage | grep -q to-be-ignored || exit 1
46 log "now set up the ignore file, and check that the file is properly ignored"
47 echo "to-be-ignored" > .appimageignore
48 $appimagetool appimagetool.AppDir appimagetool.AppImage
49 $appimagetool -l appimagetool.AppImage | grep -q to-be-ignored && exit 1 || true
51 log "remove the default ignore file, and check if an explicitly passed one works, too"
52 rm .appimageignore
53 log "to-be-ignored" > ignore
54 $appimagetool appimagetool.AppDir appimagetool.AppImage --exclude-file ignore || exit $?
55 $appimagetool -l appimagetool.AppImage | grep -q to-be-ignored && exit 1 || true
57 log "check whether files in both .appimageignore and the explicitly passed file work"
58 touch appimagetool.AppDir/to-be-ignored-too
59 echo "to-be-ignored-too" > .appimageignore
60 $appimagetool appimagetool.AppDir appimagetool.AppImage --exclude-file ignore || exit $?
61 $appimagetool -l appimagetool.AppImage | grep -q to-be-ignored && exit 1 || true
62 $appimagetool -l appimagetool.AppImage | grep -q to-be-ignored-too && exit 1 || true