1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-09-17 18:50:11 +02:00

tests/run-tests: use $sed var for all calls that need GNU sed

FreeBSD, macOS, and others come with BSD sed, which does not support all
the things that GNU sed does.  Also, BSD rmdir does not have any extended
options like --ignore-fail-on-non-empty.
This commit is contained in:
Hans-Christoph Steiner 2023-12-13 21:06:24 +01:00
parent bf73477d4c
commit 45d1363a0e

View File

@ -88,7 +88,8 @@ err_handler() {
rm -rf "$WORKSPACE"/.testfiles/test_* rm -rf "$WORKSPACE"/.testfiles/test_*
rm -f "$WORKSPACE"/.testfiles/tmp.* rm -f "$WORKSPACE"/.testfiles/tmp.*
test -d "$WORKSPACE"/.testfiles && \ test -d "$WORKSPACE"/.testfiles && \
rmdir --ignore-fail-on-non-empty "$WORKSPACE"/.testfiles (rmdir "$WORKSPACE"/.testfiles 2> /dev/null || \
rmdir --ignore-fail-on-non-empty "$WORKSPACE"/.testfiles 2> /dev/null)
} }
trap err_handler INT EXIT trap err_handler INT EXIT
@ -299,11 +300,11 @@ test $v0timestamp -eq $v1timestamp
# we can't easily reproduce the timestamps for things, so just hardcode them # we can't easily reproduce the timestamps for things, so just hardcode them
$sed -i.tmp -e 's,timestamp="[0-9]*",timestamp="1676634233",' repo/index.xml $sed -i.tmp -e 's,timestamp="[0-9]*",timestamp="1676634233",' repo/index.xml
diff -uw $WORKSPACE/tests/repo/index.xml repo/index.xml diff -uw $WORKSPACE/tests/repo/index.xml repo/index.xml
sed -i --expression='s,"timestamp": [0-9]*,"timestamp": 1676634233000,' repo/index-v1.json $sed -i --expression='s,"timestamp": [0-9]*,"timestamp": 1676634233000,' repo/index-v1.json
diff -uw $WORKSPACE/tests/repo/index-v1.json repo/index-v1.json diff -uw $WORKSPACE/tests/repo/index-v1.json repo/index-v1.json
sed -z 's/,\s*"ipfsCIDv1": *"[a-z0-9]*"//g' $WORKSPACE/tests/repo/index-v2.json > repo/index-v2.org.json $sed -z 's/,\s*"ipfsCIDv1": *"[a-z0-9]*"//g' $WORKSPACE/tests/repo/index-v2.json > repo/index-v2.org.json
sed -z 's/,\s*"ipfsCIDv1": *"[a-z0-9]*"//g' repo/index-v2.json > repo/index-v2.mod.json $sed -z 's/,\s*"ipfsCIDv1": *"[a-z0-9]*"//g' repo/index-v2.json > repo/index-v2.mod.json
sed -i --expression='s,"timestamp": [0-9]*,"timestamp": 1676634233000,' repo/index-v2.mod.json $sed -i --expression='s,"timestamp": [0-9]*,"timestamp": 1676634233000,' repo/index-v2.mod.json
diff -uw repo/index-v2.org.json repo/index-v2.mod.json diff -uw repo/index-v2.org.json repo/index-v2.mod.json
@ -643,7 +644,7 @@ cp $WORKSPACE/tests/metadata/com.politedroid.yml metadata
echo "com.politedroid_4.apk com.politedroid 2016-01-01" > stats/known_apks.txt echo "com.politedroid_4.apk com.politedroid 2016-01-01" > stats/known_apks.txt
echo "com.politedroid_5.apk com.politedroid 2017-01-01" >> stats/known_apks.txt echo "com.politedroid_5.apk com.politedroid 2017-01-01" >> stats/known_apks.txt
echo "com.politedroid_6.apk com.politedroid 2018-01-01" >> stats/known_apks.txt echo "com.politedroid_6.apk com.politedroid 2018-01-01" >> stats/known_apks.txt
sed -i -e 's/ArchivePolicy:.*/ArchivePolicy: 1 versions/' metadata/com.politedroid.yml $sed -i -e 's/ArchivePolicy:.*/ArchivePolicy: 1 versions/' metadata/com.politedroid.yml
timestamp=1483228800 # $(date -u --date=2017-01-01 +%s)000 timestamp=1483228800 # $(date -u --date=2017-01-01 +%s)000
$fdroid update --pretty --nosign $fdroid update --pretty --nosign
@ -660,7 +661,7 @@ mkdir -p metadata/com.politedroid/en-US/changelogs/
cp $WORKSPACE/tests/repo/com.politedroid_6.apk repo cp $WORKSPACE/tests/repo/com.politedroid_6.apk repo
cp $WORKSPACE/tests/metadata/com.politedroid.yml metadata cp $WORKSPACE/tests/metadata/com.politedroid.yml metadata
echo "whatsnew test" > metadata/com.politedroid/en-US/changelogs/6.txt echo "whatsnew test" > metadata/com.politedroid/en-US/changelogs/6.txt
sed -i -e '/CurrentVersion/d' metadata/com.politedroid.yml $sed -i -e '/CurrentVersion/d' metadata/com.politedroid.yml
$fdroid update --pretty --nosign $fdroid update --pretty --nosign
grep -F 'whatsnew' repo/index-v1.json grep -F 'whatsnew' repo/index-v1.json