Skip to content
Snippets Groups Projects
Unverified Commit 9dc03069 authored by Ritesh Raj Sarraf's avatar Ritesh Raj Sarraf
Browse files

Add tests/test-export test script

The test-export script tests the `ade export` command.
It creates an install target in moc/Makefile.in and uses it to
simulate ade's export command, which further bundles the installed files
The script then unpacks the created bundle and verified the sample file
that was bundled through `ade export`

Currently, we do it the crude way to extract the file from the bundle
because ostree/flatpak doesn't have a cleaner implementation
For details, see: https://github.com/flatpak/flatpak/issues/126



Signed-off-by: default avatarRitesh Raj Sarraf <ritesh.sarraf@collabora.com>
Reviewed-by: default avatarFrédéric Dalleau <frederic.dalleau@collabora.com>
Differential Revision: https://phabricator.apertis.org/D7914
parent e176ae27
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@ sedrule = 's/@DISTRO@/$(call distro,$(1))/; s/@RELEASE@/$(call release,$(1))/; s
TESTS = \
test-configure \
test-export \
test-installed \
test-latest \
test-download \
......
......@@ -11,3 +11,8 @@ sample.py:
echo "print 'sample.py success'" >> sample.py
chmod a+x sample.py
install: sample.py
# Name org.apertis.Sample is picked from ProjectInfo.json
mkdir -p ${DESTDIR}/Applications/org.apertis.Sample/bin
cp sample.py ${DESTDIR}/Applications/org.apertis.Sample/bin/
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright © 2018 Collabora Ltd.
#
# SPDX-License-Identifier: MPL-2.0
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
import os
import sys
import shutil
import tempfile
import subprocess
from test_util import should_succeed, should_fail, split_elements
from test_util import BASE_TAG, BASE_INSTALL, BASE_MOCK, LATEST_SYSROOTS
# Utility functions
def check_list(path, sysroots):
expected_tags = {BASE_TAG.format(*sysroot) for sysroot in sysroots}
result = should_succeed('sysroot', '--path', path, 'list')
return expected_tags == set(split_elements(result['InstalledSysroots']))
with tempfile.TemporaryDirectory(dir=os.path.expanduser("~")) as tmpdir:
# Copy install directory
os.chdir(os.path.dirname(os.path.realpath(__file__)))
path = os.path.join(tmpdir, 'install')
shutil.copytree(BASE_INSTALL, path)
mock = os.path.join(tmpdir, 'mock')
shutil.copytree(BASE_MOCK, mock)
if not check_list(path, LATEST_SYSROOTS):
exit(1)
os.chdir(mock);
for sysroot in LATEST_SYSROOTS:
tag = '{}-{}-{}'.format(*sysroot)
build = os.path.join(mock, tag)
should_succeed('configure', '--path', path, '--sysroot', tag,
'--build-dir', build)
should_succeed('export', '--dest', path,
'--build-dir', build)
pkg = "org.apertis.Sample-0.1.0.bundle"
TestExportRepo = "repo"
TestExportOutdir = "outdir"
os.chdir(path)
if os.path.exists(pkg):
# See: https://github.com/flatpak/flatpak/issues/126
os.system("ostree init --repo=%s --mode=bare-user" % (TestExportRepo) )
os.system("ostree static-delta apply-offline --repo=%s %s" % (TestExportRepo, pkg) )
os.system("ostree checkout --repo=%s -U $(basename $(echo %s/objects/*/*.commit | cut -d/ -f3- --output-delimiter= ) .commit) %s" % (TestExportRepo, TestExportRepo, TestExportOutdir) )
if not os.path.exists("%s/files/bin/sample.py" % (TestExportOutdir)):
print("sample file does not exist")
sys.exit(1)
shutil.rmtree(TestExportRepo)
shutil.rmtree(TestExportOutdir)
os.chdir(mock)
else:
print("Failed to find bundle package")
sys.exit(1)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment