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 @@ -103,6 +103,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
10 changes: 5 additions & 5 deletions tests/test-build-subj.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 Down Expand Up @@ -99,7 +97,7 @@ BODY="$(ostree_get_body "$REPO"_1 "$REF")"
assert_streq "$SUBJECT" "$EXPECTED_SUBJECT"
assert_streq "$BODY" "$EXPECTED_BODY"

echo "ok default subject and body are set from git"
ok "default subject and body are set from git"

${FLATPAK_BUILDER} --force-clean --repo="$REPO"_2 \
--subject="Custom subject" --body="Custom body" appdir "$MANIFEST_NAME" >&2
Expand All @@ -111,7 +109,7 @@ BODY="$(ostree_get_body "$REPO"_2 "$REF")"
assert_streq "$SUBJECT" "Custom subject"
assert_streq "$BODY" "Custom body"

echo "ok explicit subject and body override defaults"
ok "explicit subject and body override defaults"

rm -rf "$TEST_GIT_DIR/.git"

Expand All @@ -124,4 +122,6 @@ BODY="$(ostree_get_body "$REPO"_3 "$REF")"
assert_streq "$SUBJECT" "Export $APP_ID"
assert_streq "$BODY" "$EXPECTED_BODY"

echo "ok default export subject is used outside git dir"
ok "default export subject is used outside git dir"

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
20 changes: 10 additions & 10 deletions tests/test-builder-flags.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..8"

setup_repo
install_repo
setup_sdk_repo
Expand Down Expand Up @@ -59,7 +57,7 @@ run_build test-cgo-default.json
assert_file_has_content appdir/files/cflags_out '\-O2 \-g'
assert_file_has_content appdir/files/cgo_cflags_out '\-O2 \-g'

echo "ok cgo-cflags defaults to cflags"
ok "cgo-cflags defaults to cflags"

# Explicit cgo-cflags set and no cgo-cflags-override: CGO_CFLAGS=$CFLAGS+explicit
cat > test-cgo-set.json <<'EOF'
Expand All @@ -85,7 +83,7 @@ run_build test-cgo-set.json

assert_file_has_content appdir/files/cgo_cflags_out '\-O2 \-g \-O0'

echo "ok explicit cgo-cflags is additive to cflags"
ok "explicit cgo-cflags is additive to cflags"

# Explicit cgo-cflags set and `cgo-cflags-override: true`: CGO_CFLAGS=explicit
cat > test-cgo-set-with-override.json <<'EOF'
Expand Down Expand Up @@ -113,7 +111,7 @@ run_build test-cgo-set-with-override.json

assert_file_has_content appdir/files/cgo_cflags_out '\-O0'

echo "ok cgo-cflags with override has only explicit flags"
ok "cgo-cflags with override has only explicit flags"

# Only `cgo-cflags-override: true`: CGO_CFLAGS is unset
cat > test-cgo-only-override.json <<'EOF'
Expand All @@ -139,7 +137,7 @@ run_build test-cgo-only-override.json

assert_file_has_content appdir/files/cgo_cflags_out '^unset$'

echo "ok only cgo-cflags-override clears CGO_CFLAGS"
ok "only cgo-cflags-override clears CGO_CFLAGS"

# Default: RUSTFLAGS should be passed. The test SDK does not ship with
# defaults so it is set here via rustflags explicitly.
Expand All @@ -165,7 +163,7 @@ run_build test-rustflags-set.json

assert_file_has_content appdir/files/rustflags_out '\-C opt\-level=2'

echo "ok rustflags is passed by default"
ok "rustflags is passed by default"

# rustflags-override at module level clears manifest-level rustflags
# or equivalently clears SDK rustflags
Expand Down Expand Up @@ -196,7 +194,7 @@ run_build test-rustflags-override.json
assert_file_has_content appdir/files/rustflags_out '\-C opt\-level=3'
assert_not_file_has_content appdir/files/rustflags_out 'debuginfo'

echo "ok rustflags-override at module level clears manifest-level rustflags"
ok "rustflags-override at module level clears manifest-level rustflags"

# Only rustflags-override is set, rustflags should be cleared
cat > test-rustflags-only-override.json <<'EOF'
Expand Down Expand Up @@ -224,7 +222,7 @@ run_build test-rustflags-only-override.json

assert_file_has_content appdir/files/rustflags_out '^unset$'

echo "ok only rustflags-override clears rustflags"
ok "only rustflags-override clears rustflags"

CREATE_SDK_CONFIG=1
setup_repo testconfig
Expand Down Expand Up @@ -265,4 +263,6 @@ assert_file_has_content appdir/files/cgo_cflags '^\-O2 \-g \-fstack-protector-st
assert_file_has_content appdir/files/cgo_cxxflags '^\-O2 \-g \-fstack-protector-strong$'
assert_file_has_content appdir/files/cgo_ldflags '^\-Wl,-z,relro,-z,now$'

echo "ok sdk flags config from is loaded and flags are set correctly"
ok "sdk flags config from is loaded and flags are set correctly"

done_testing
Loading