Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added more testing #566

Merged
merged 2 commits into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/Makefile.am.inc
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ dist_installed_test_extra_scripts += \
dist_installed_test_data = \
tests/libtest.sh \
tests/org.test.Hello.png \
tests/org.test.Hello.desktop \
tests/source1.json \
tests/source2.json \
tests/test.json \
tests/test.yaml \
tests/test-rename.json \
tests/test-runtime.json \
tests/module1.json \
tests/module1.yaml \
Expand Down
2 changes: 2 additions & 0 deletions tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,13 @@ if get_option('installed_tests')
'org.test.Deprecated.SHA1.file.json',
'org.test.Deprecated.SHA1.file.yaml',
'org.test.Hello.png',
'org.test.Hello.desktop',
'org.test.Python.json',
'org.test.Python2.json',
'session.conf.in',
'source1.json',
'source2.json',
'test-rename.json',
'test-runtime.json',
'test.json',
'test.yaml',
Expand Down
7 changes: 7 additions & 0 deletions tests/org.test.Hello.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[Desktop Entry]
Version=1.0
Type=Application
Name=Hello
Exec=hello2.sh
Icon=org.test.Hello
MimeType=x-test/Hello;
44 changes: 25 additions & 19 deletions tests/test-builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set -euo pipefail

skip_without_fuse

echo "1..4"
echo "1..6"

setup_repo
install_repo
Expand All @@ -36,10 +36,12 @@ cd $TEST_DATA_DIR/

cp -a $(dirname $0)/test-configure .
echo "version1" > app-data
cp $(dirname $0)/test-rename.json .
cp $(dirname $0)/test.json .
cp $(dirname $0)/test.yaml .
cp $(dirname $0)/test-runtime.json .
cp $(dirname $0)/0001-Add-test-logo.patch .
cp $(dirname $0)/org.test.Hello.desktop .
mkdir include1
cp $(dirname $0)/module1.json include1/
cp $(dirname $0)/module1.yaml include1/
Expand All @@ -52,31 +54,35 @@ cp $(dirname $0)/module2.yaml include1/include2/
cp $(dirname $0)/source2.json include1/include2/
cp $(dirname $0)/data2 include1/include2/
cp $(dirname $0)/data2.patch include1/include2/
${FLATPAK_BUILDER} --repo=$REPO $FL_GPGARGS --force-clean appdir test.json >&2
${FLATPAK_BUILDER} --repo=$REPO $FL_GPGARGS --force-clean appdir test.yaml >&2

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_file_has_content appdir/files/ran_module1 module1
assert_file_has_content appdir/files/ran_module2 module2
for MANIFEST in test.json test.yaml test-rename.json ; do
echo "building manifest $MANIFEST" >&2
${FLATPAK_BUILDER} --repo=$REPO $FL_GPGARGS --force-clean appdir $MANIFEST >&2

assert_not_has_file appdir/files/cleanup/a_filee
assert_not_has_file appdir/files/bin/file.cleanup
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_file_has_content appdir/files/ran_module1 module1
assert_file_has_content appdir/files/ran_module2 module2

assert_has_file appdir/files/cleaned_up > out
assert_has_file appdir/files/share/icons/org.test.Hello.png
assert_not_has_file appdir/files/cleanup/a_filee
assert_not_has_file appdir/files/bin/file.cleanup

assert_file_has_content appdir/files/out '^foo$'
assert_file_has_content appdir/files/out2 '^foo2$'
assert_has_file appdir/files/cleaned_up > out
assert_has_file appdir/files/share/icons/hicolor/64x64/apps/org.test.Hello2.png
assert_has_file appdir/files/share/applications/org.test.Hello2.desktop

assert_file_has_content appdir/files/source1 'Hello, from source 1'
assert_file_has_content appdir/files/source2 'Hello, from source 2'
assert_file_has_content appdir/files/out '^foo$'
assert_file_has_content appdir/files/out2 '^foo2$'

${FLATPAK} build appdir /app/bin/hello2.sh > hello_out2
assert_file_has_content hello_out2 '^Hello world2, from a sandbox$'
assert_file_has_content appdir/files/source1 'Hello, from source 1'
assert_file_has_content appdir/files/source2 'Hello, from source 2'

echo "ok build"
${FLATPAK} build appdir /app/bin/hello2.sh > hello_out2
assert_file_has_content hello_out2 '^Hello world2, from a sandbox$'

echo "ok build"
done

${FLATPAK} ${U} install -y test-repo org.test.Hello2 master >&2
run org.test.Hello2 > hello_out3
Expand Down
97 changes: 97 additions & 0 deletions tests/test-rename.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"app-id": "org.test.Hello2",
"runtime": "org.test.Platform",
"sdk": "org.test.Sdk",
"command": "hello2.sh",
"tags": ["test"],
"token-type": 0,
"finish-args": [
"--share=network"
],
"rename-icon": "Hello",
"rename-desktop-file": "Hello.desktop",
"build-options" : {
"cflags": "-O2 -g",
"cxxflags": "-O2 -g",
"env": {
"FOO": "bar",
"V": "1"
}
},
"cleanup": ["/cleanup", "*.cleanup"],
"cleanup-commands": [ "touch /app/cleaned_up" ],
"modules": [
"include1/module1.json",
{
"name": "root",
"modules": [
{
"name": "test",
"config-opts": ["--some-arg"],
"post-install": [
"touch /app/bin/file.cleanup",
"mkdir -p /app/share/icons/hicolor/64x64/apps/",
"cp org.test.Hello.png /app/share/icons/hicolor/64x64/apps/Hello.png",
"mkdir -p /app/share/applications",
"cp org.test.Hello.desktop /app/share/applications/Hello.desktop"
],
"make-args": ["BAR=2" ],
"make-install-args": ["BAR=3" ],
"build-commands": [ "echo foo > /app/out" ],
"sources": [
{
"type": "file",
"path": "test-configure",
"dest-filename": "configure",
"sha256": "675a1ac2feec4d4f54e581b4b01bc3cfd2c1cf31aa5963574d31228c8a11b7e7"
},
{
"type": "file",
"path": "app-data"
},
{
"type": "file",
"path": "org.test.Hello.desktop"
},
{
"type": "script",
"dest-filename": "hello2.sh",
"commands": [ "echo \"Hello world2, from a sandbox\"" ]
},
{
"type": "shell",
"commands": [
"mkdir /app/cleanup/",
"touch /app/cleanup/a_file"
]
},
{
"type": "patch",
"path": "0001-Add-test-logo.patch",
"use-git": true
}
]
},
{
"name": "test2",
"build-commands": [
"echo foo2 > /app/out2",
"cp source[12] /app"
],
"buildsystem": "simple",
"sources": [
{
"type": "file",
"path": "app-data"
},
"include1/source1.json",
"include1/include2/source2.json"
]
},
{
"name": "empty"
}
]
}
]
}
12 changes: 11 additions & 1 deletion tests/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@
{
"name": "test",
"config-opts": ["--some-arg"],
"post-install": [ "touch /app/bin/file.cleanup", "mkdir -p /app/share/icons/", "cp org.test.Hello.png /app/share/icons/" ],
"post-install": [
"touch /app/bin/file.cleanup",
"mkdir -p /app/share/icons/hicolor/64x64/apps/",
"cp org.test.Hello.png /app/share/icons/hicolor/64x64/apps/$FLATPAK_ID.png",
"mkdir -p /app/share/applications",
"cp org.test.Hello.desktop /app/share/applications/$FLATPAK_ID.desktop"
],
"make-args": ["BAR=2" ],
"make-install-args": ["BAR=3" ],
"build-commands": [ "echo foo > /app/out" ],
Expand All @@ -46,6 +52,10 @@
"dest-filename": "hello2.sh",
"commands": [ "echo \"Hello world2, from a sandbox\"" ]
},
{
"type": "file",
"path": "org.test.Hello.desktop"
},
{
"type": "shell",
"commands": [
Expand Down
8 changes: 6 additions & 2 deletions tests/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ modules:
config-opts: [--some-arg]
post-install:
- touch /app/bin/file.cleanup
- mkdir -p /app/share/icons/
- cp org.test.Hello.png /app/share/icons/
- mkdir -p /app/share/icons/hicolor/64x64/apps/
- cp org.test.Hello.png /app/share/icons/hicolor/64x64/apps/$FLATPAK_ID.png
- mkdir -p /app/share/applications
- cp org.test.Hello.desktop /app/share/applications/$FLATPAK_ID.desktop
make-args: [BAR=2]
make-install-args: [BAR=3]
build-commands: ['echo foo > /app/out']
Expand All @@ -37,6 +39,8 @@ modules:
- type: script
dest-filename: hello2.sh
commands: ['echo "Hello world2, from a sandbox"']
- type: file
path: org.test.Hello.desktop
- type: shell
commands:
- mkdir /app/cleanup/
Expand Down