mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 01:13:24 +00:00
desktop: Port test-appdata.sh to Python
This works on Windows too so let's make it cross platform.
This commit is contained in:
parent
941fc0000b
commit
8ef7bf3553
3 changed files with 25 additions and 15 deletions
|
@ -46,7 +46,7 @@ endif
|
|||
|
||||
if appstreamcli.found()
|
||||
test('appdata_file',
|
||||
find_program('test-appdata.sh', required: true, dirs: [meson.current_source_dir()]),
|
||||
find_program('test-appdata.py', required: true, dirs: [meson.current_source_dir()]),
|
||||
env: [
|
||||
'GIMP_TESTING_BUILDDIR=' + meson.current_build_dir(),
|
||||
'GIMP_RELEASE=' + (release and not gimp_rc_git ? '1' : '0'),
|
||||
|
|
24
desktop/test-appdata.py
Normal file
24
desktop/test-appdata.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import tempfile
|
||||
from datetime import date
|
||||
|
||||
os.chdir(os.environ['GIMP_TESTING_BUILDDIR'])
|
||||
if int(os.environ.get('GIMP_RELEASE', '0')) == 1:
|
||||
result = subprocess.run(['appstreamcli', 'validate', 'org.gimp.GIMP.appdata.xml'])
|
||||
sys.exit(result.returncode)
|
||||
else:
|
||||
temp_fd, APPDATA = tempfile.mkstemp(prefix='org.gimp.GIMP.appdata.',suffix='.xml',dir='.')
|
||||
with open('org.gimp.GIMP.appdata.xml', 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
new_content = content.replace(
|
||||
'date="TODO"',
|
||||
f'date="{date.today().isoformat()}"'
|
||||
)
|
||||
with os.fdopen(temp_fd, 'w', encoding='utf-8') as f:
|
||||
f.write(new_content)
|
||||
result = subprocess.run(['appstreamcli', 'validate', APPDATA])
|
||||
os.remove(APPDATA)
|
||||
sys.exit(result.returncode)
|
|
@ -1,14 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
cd $GIMP_TESTING_BUILDDIR
|
||||
if [ $GIMP_RELEASE -eq 1 ]; then
|
||||
appstreamcli validate org.gimp.GIMP.appdata.xml
|
||||
exit $?
|
||||
else
|
||||
APPDATA=`mktemp org.gimp.GIMP.appdata.XXX.xml`
|
||||
sed "s/date=\"TODO\"/date=\"`date --iso-8601`\"/" org.gimp.GIMP.appdata.xml > $APPDATA
|
||||
appstreamcli validate $APPDATA
|
||||
success=$?
|
||||
rm $APPDATA
|
||||
exit $success
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue