Skip to content
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
17 changes: 17 additions & 0 deletions tests/libtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,23 @@ export U="--user"
export FLATPAK="${CMD_PREFIX} flatpak"
export FLATPAK_BUILDER="${CMD_PREFIX} flatpak-builder"

test_number=0

ok () {
{ { local BASH_XTRACEFD=3; } 2> /dev/null
test_number=$(( test_number + 1 ))
echo "ok $test_number - $*";
echo "================ $(basename ${BASH_SOURCE[1]}):${BASH_LINENO[0]} - $@ ================" >&2;
} 3> /dev/null
}

done_testing () {
{ { local BASH_XTRACEFD=3; } 2> /dev/null
echo "1..$test_number"
echo "# Done testing"
} 3> /dev/null
}

assert_streq () {
test "$1" = "$2" || (echo 1>&2 "$1 != $2"; exit 1)
}
Expand Down
14 changes: 7 additions & 7 deletions tests/test-appstream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ set -euo pipefail

skip_without_fuse

echo "1..3"

setup_repo
install_repo
setup_sdk_repo
Expand All @@ -50,7 +48,7 @@ gzip -cdq builddir_sc/files/share/app-info/xmls/org.flatpak.appstream_media.xml.
> appstream.xml
assert_file_has_content_extended appstream.xml '>org/flatpak/appstream_media/[^/]+/icons/128x128/org.flatpak.appstream_media.png</icon>'

echo "ok compose partial url policy"
ok "compose partial url policy"

# test compose full url policy
if appstream_has_version 0 16 3; then
Expand All @@ -65,9 +63,9 @@ if appstream_has_version 0 16 3; then
> appstream.xml
assert_file_has_content_extended appstream.xml '>https://example.org/media/org/flatpak/appstream_media/[^/]+/icons/128x128/org.flatpak.appstream_media.png</icon>'

echo "ok compose full url policy"
ok "compose full url policy"
else
echo "ok # Skip AppStream < 0.16.3"
ok "# Skip AppStream < 0.16.3"
fi

# test compose jxl image format
Expand All @@ -84,7 +82,9 @@ if appstream_has_version 1 2 0; then
> appstream.xml
assert_file_has_content_extended appstream.xml '>https://example.org/media/org/flatpak/appstream_media/[^/]+/icons/128x128/org.flatpak.appstream_media.jxl</icon>'

echo "ok compose jxl image format"
ok "compose jxl image format"
else
echo "ok # Skip AppStream < 1.2.0"
ok "# Skip AppStream < 1.2.0"
fi

done_testing
22 changes: 11 additions & 11 deletions tests/test-builder-cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ set -euo pipefail

skip_without_fuse

echo "1..9"

setup_repo
install_repo
setup_sdk_repo
Expand Down Expand Up @@ -65,7 +63,7 @@ assert_not_has_file appdir/files/share/doc/file1
assert_not_has_file appdir/files/share/doc/file2
assert_not_has_dir appdir/files/share/doc

echo "ok toplevel cleanup applies to all modules"
ok "toplevel cleanup applies to all modules"

cat > test-cleanup-module-scope.json <<'EOF'
{
Expand Down Expand Up @@ -99,7 +97,7 @@ run_build test-cleanup-module-scope.json
assert_not_has_file appdir/files/share/doc/file1
assert_has_file appdir/files/share/doc/file2

echo "ok module cleanup does not affect other modules"
ok "module cleanup does not affect other modules"

cat > test-cleanup-basename.json <<'EOF'
{
Expand All @@ -124,7 +122,7 @@ run_build test-cleanup-basename.json
assert_not_has_file appdir/files/share/a.txt
assert_has_file appdir/files/share/b.log

echo "ok basename pattern works"
ok "basename pattern works"

cat > test-cleanup-star.json <<'EOF'
{
Expand All @@ -150,7 +148,7 @@ run_build test-cleanup-star.json
assert_not_has_file appdir/files/a/file.txt
assert_has_file appdir/files/b/file.log

echo "ok wildcard matching works"
ok "wildcard matching works"

cat > test-cleanup-module-star-scope.json <<'EOF'
{
Expand Down Expand Up @@ -186,7 +184,7 @@ assert_has_file appdir/files/share/file1.txt
assert_not_has_file appdir/files/share/file2.txt
assert_has_file appdir/files/share/file2.log

echo "ok wildcard matching works and is scoped to module"
ok "wildcard matching works and is scoped to module"

cat > test-cleanup-question.json <<'EOF'
{
Expand Down Expand Up @@ -224,7 +222,7 @@ assert_not_has_file appdir/files/share/a2.txt
assert_has_file appdir/files/share/a22.txt
assert_not_has_file appdir/files/share/ab.txt

echo "ok '?' matches exactly one char and is module-scoped"
ok "'?' matches exactly one char and is module-scoped"

cat > test-cleanup-question-slash.json <<'EOF'
{
Expand All @@ -250,7 +248,7 @@ run_build test-cleanup-question-slash.json
assert_not_has_file appdir/files/a1/file.txt
assert_has_file appdir/files/a/b/file.txt

echo "ok '?' does not match '/'"
ok "'?' does not match '/'"

cat > test-invalid-pattern1.json <<'EOF'
{
Expand All @@ -274,7 +272,7 @@ run_build test-invalid-pattern1.json
# share/doc is not a valid pattern, no cleanup should happen
assert_has_file appdir/files/share/doc/file

echo "ok invalid pattern 1 did not cleanup"
ok "invalid pattern 1 did not cleanup"

cat > test-cleanup-trailing-slash.json <<'EOF'
{
Expand All @@ -298,4 +296,6 @@ run_build test-cleanup-trailing-slash.json
assert_not_has_file appdir/files/share/doc/file
assert_not_has_dir appdir/files/share/doc

echo "ok trailing slash works"
ok "trailing slash works"

done_testing
20 changes: 10 additions & 10 deletions tests/test-builder-deprecated.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ srcdir=$(dirname "$0")

skip_without_fuse

echo "1..8"

setup_repo
install_repo
setup_sdk_repo
Expand All @@ -46,46 +44,48 @@ BUILD_LOG=build-error-log run_build org.test.Deprecated.MD5.archive.json
assert_file_has_content build-error-log 'The "md5" source property is deprecated due to the weakness of MD5 hashes.'
assert_file_has_content build-error-log 'Use the "sha256" property for the more secure SHA256 hash.'

echo "ok deprecated MD5 hash for archive in JSON"
ok "deprecated MD5 hash for archive in JSON"

BUILD_LOG=build-error-log run_build org.test.Deprecated.MD5.archive.yaml
assert_file_has_content build-error-log 'The "md5" source property is deprecated due to the weakness of MD5 hashes.'
assert_file_has_content build-error-log 'Use the "sha256" property for the more secure SHA256 hash.'

echo "ok deprecated MD5 hash for archive in YAML"
ok "deprecated MD5 hash for archive in YAML"

BUILD_LOG=build-error-log run_build org.test.Deprecated.MD5.file.json
assert_file_has_content build-error-log 'The "md5" source property is deprecated due to the weakness of MD5 hashes.'
assert_file_has_content build-error-log 'Use the "sha256" property for the more secure SHA256 hash.'

echo "ok deprecated MD5 hash for file in JSON"
ok "deprecated MD5 hash for file in JSON"

BUILD_LOG=build-error-log run_build org.test.Deprecated.MD5.file.yaml
assert_file_has_content build-error-log 'The "md5" source property is deprecated due to the weakness of MD5 hashes.'
assert_file_has_content build-error-log 'Use the "sha256" property for the more secure SHA256 hash.'

echo "ok deprecated MD5 hash for file in YAML"
ok "deprecated MD5 hash for file in YAML"

BUILD_LOG=build-error-log run_build org.test.Deprecated.SHA1.archive.json
assert_file_has_content build-error-log 'The "sha1" source property is deprecated due to the weakness of SHA1 hashes.'
assert_file_has_content build-error-log 'Use the "sha256" property for the more secure SHA256 hash.'

echo "ok deprecated SHA1 hash for archive in JSON"
ok "deprecated SHA1 hash for archive in JSON"

BUILD_LOG=build-error-log run_build org.test.Deprecated.SHA1.archive.yaml
assert_file_has_content build-error-log 'The "sha1" source property is deprecated due to the weakness of SHA1 hashes.'
assert_file_has_content build-error-log 'Use the "sha256" property for the more secure SHA256 hash.'

echo "ok deprecated SHA1 hash for archive in YAML"
ok "deprecated SHA1 hash for archive in YAML"

BUILD_LOG=build-error-log run_build org.test.Deprecated.SHA1.file.json
assert_file_has_content build-error-log 'The "sha1" source property is deprecated due to the weakness of SHA1 hashes.'
assert_file_has_content build-error-log 'Use the "sha256" property for the more secure SHA256 hash.'

echo "ok deprecated SHA1 hash for file in JSON"
ok "deprecated SHA1 hash for file in JSON"

BUILD_LOG=build-error-log run_build org.test.Deprecated.SHA1.file.yaml
assert_file_has_content build-error-log 'The "sha1" source property is deprecated due to the weakness of SHA1 hashes.'
assert_file_has_content build-error-log 'Use the "sha256" property for the more secure SHA256 hash.'

echo "ok deprecated SHA1 hash for file in YAML"
ok "deprecated SHA1 hash for file in YAML"

done_testing
12 changes: 6 additions & 6 deletions tests/test-builder-licence-paths.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ set -euo pipefail

skip_without_fuse

echo "1..4"

setup_repo
install_repo
setup_sdk_repo
Expand Down Expand Up @@ -61,7 +59,7 @@ run_build_fail test-licence_interm_symlink.json

assert_not_has_file appdir/files/share/licenses/org.test.licence_interm_symlink/test/environ

echo "ok intermediate path symlink is rejected"
ok "intermediate path symlink is rejected"

mkdir -p source_licence_2
ln -s /etc/hostname source_licence_2/LICENSE
Expand Down Expand Up @@ -90,7 +88,7 @@ run_build_fail test-licence_abs_symlink.json

assert_not_has_file appdir/files/share/licenses/org.test.licence_abs_symlink/test/LICENSE

echo "ok absolute path symlink is rejected"
ok "absolute path symlink is rejected"

mkdir -p source_licence_3
echo "MY LICENSE TEXT" > source_licence_3/LICENSE
Expand Down Expand Up @@ -122,7 +120,7 @@ assert_file_has_content \
appdir/files/share/licenses/org.test.licence_working_1/test/LICENSE \
'^MY LICENSE TEXT$'

echo "ok license file is recorded with license-files key"
ok "license file is recorded with license-files key"

mkdir -p source_licence_4
echo "MY DEFAULT LICENSE TEXT" > source_licence_4/LICENSE
Expand Down Expand Up @@ -153,4 +151,6 @@ assert_file_has_content \
appdir/files/share/licenses/org.test.licence_working_2/test/LICENSE \
'^MY DEFAULT LICENSE TEXT$'

echo "ok license file is recorded by default"
ok "license file is recorded by default"

done_testing
12 changes: 6 additions & 6 deletions tests/test-builder-locale-migration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ set -euo pipefail

skip_without_fuse

echo "1..4"

setup_repo
install_repo
setup_sdk_repo
Expand Down Expand Up @@ -136,7 +134,7 @@ assert_has_dir appdir/files/share/runtime/locale/sv
assert_has_file appdir/files/share/locale/plain-file
assert_not_has_symlink appdir/files/share/locale/plain-file

echo "ok locale dirs migrated"
ok "locale dirs migrated"

cat > test-locale-disabled.json <<'EOF'
{
Expand All @@ -162,7 +160,7 @@ assert_has_file appdir/files/share/locale/de/LC_MESSAGES/test.mo
assert_file_has_content appdir/files/share/locale/de/LC_MESSAGES/test.mo 'de translation'
assert_not_has_dir appdir/files/share/runtime/locale

echo "ok locale dirs migration is disabled on separate-locales false"
ok "locale dirs migration is disabled on separate-locales false"

cat > test-locale-migration-runtime.json <<'EOF'
{
Expand Down Expand Up @@ -194,7 +192,7 @@ assert_has_symlink appdir/usr/lib/locale/cs
assert_has_file appdir/usr/share/runtime/locale/cs/lib/cs/LC_MESSAGES/test.mo
assert_file_has_content appdir/usr/share/runtime/locale/cs/lib/cs/LC_MESSAGES/test.mo 'cs translation'

echo "ok locale dirs migration works with runtime"
ok "locale dirs migration works with runtime"

cat > test-locale-no-dirs.json <<'EOF'
{
Expand All @@ -217,4 +215,6 @@ run_build test-locale-no-dirs.json
assert_has_file appdir/files/bin/test
assert_not_has_dir appdir/files/share/runtime/locale

echo "ok locale migration handles missing locale dirs"
ok "locale migration handles missing locale dirs"

done_testing
8 changes: 4 additions & 4 deletions tests/test-builder-python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ set -euo pipefail
skip_without_fuse
skip_without_python2

echo "1..2"

setup_repo
install_repo
setup_python2_repo
Expand All @@ -51,7 +49,7 @@ builder_run_app org.test.Python.json testpython.py > testpython.out

assert_file_has_content testpython.out ^modified$

echo "ok handled pyc rewriting multiple times"
ok "handled pyc rewriting multiple times"

run_build org.test.Python2.json

Expand All @@ -62,4 +60,6 @@ builder_run_app org.test.Python2.json testpython.py > testpython.out

assert_file_has_content testpython.out "^first $"

echo "ok handled .pyc without .py"
ok "handled .pyc without .py"

done_testing
Loading