Commit eeed9f62 authored by Tristan Maat's avatar Tristan Maat Committed by Tristan Maat

Merge integration tests into general tests

parent 11c8f386
image: buildstream/buildstream-fedora:master-42-571406d
cache:
key: "$CI_JOB_NAME-"
paths:
- cache/buildstream/sources/
- cache/
stages:
- prepare
......@@ -14,9 +15,9 @@ before_script:
- mount
- df -h
# Store cache in the project directory
- if [ -d "$(pwd)/cache" ]; then chmod -R a+rw "$(pwd)/cache"; fi
- export XDG_CACHE_HOME="$(pwd)/cache"
- mkdir -p "$(pwd)/cache"
- chmod -R a+rw "$(pwd)/cache"
- adduser -m buildstream
- chown -R buildstream:buildstream .
......@@ -66,10 +67,11 @@ source_dist:
# Run premerge commits
#
pytest_linux:
linux-tests:
stage: test
variables:
PYTEST_ADDOPTS: "--color=yes"
INTEGRATION_CACHE: "/builds/BuildStream/cache/"
script:
# Unpack and get into dist/buildstream
......@@ -79,46 +81,24 @@ pytest_linux:
# Run the tests from the source distribution, We run as a simple
# user to test for permission issues
- su buildstream -c 'python3 setup.py test --index-url invalid://uri'
- su buildstream -c 'python3 setup.py test --index-url invalid://uri --addopts --integration'
# Go back to the toplevel and collect our reports
- cd ../..
- mkdir -p coverage-pytest-linux/
- cp dist/buildstream/.coverage.* coverage-pytest-linux/coverage.pytest-linux
artifacts:
paths:
- coverage-pytest-linux/
# Run integration tests
#
integration_linux:
stage: test
script:
- cd dist && ./install.sh && cd ..
- cd integration-tests
# We run as a simple user to test for permission issues
- su buildstream -c './run-test.sh --arg --colors --cov ../.coveragerc --sources ${XDG_CACHE_HOME}/buildstream/sources test'
- cd ..
- mkdir -p coverage-linux/
- cp integration-tests/.coverage coverage-linux/coverage.linux
- cp -a integration-tests/tmp/logs logs-linux
- mkdir -p coverage-linux/
- cp dist/buildstream/.coverage.* coverage-linux/coverage.linux
artifacts:
paths:
- coverage-linux/
- logs-linux/
dependencies:
- source_dist
pytest_unix:
unix-tests:
stage: test
variables:
BST_FORCE_BACKEND: "unix"
PYTEST_ADDOPTS: "--color=yes"
INTEGRATION_CACHE: "/builds/BuildStream/cache/"
script:
# We remove the Bubblewrap and OSTree packages here so that we catch any
# codepaths that try to use them. Removing OSTree causes fuse-libs to
......@@ -130,32 +110,12 @@ pytest_unix:
- cd dist && ./unpack.sh && cd buildstream
# Since the unix platform is required to run as root, no user change required
- python3 setup.py test --index-url invalid://uri
- python3 setup.py test --index-url invalid://uri --addopts --integration
# Go back to the toplevel and collect our reports
- cd ../..
- mkdir -p coverage-pytest-unix
- cp dist/buildstream/.coverage.* coverage-pytest-unix/coverage.pytest-unix
artifacts:
paths:
- coverage-pytest-unix/
integration_unix:
stage: test
variables:
BST_FORCE_BACKEND: "unix"
script:
- cd dist && ./install.sh && cd ..
- cd integration-tests
# Since the unix platform is required to run as root, no user change required
- ./run-test.sh --arg --colors --cov ../.coveragerc --sources ${XDG_CACHE_HOME}/buildstream/sources test
- cd ..
- mkdir -p coverage-unix/
- cp integration-tests/.coverage coverage-unix/coverage.unix
- cp -a integration-tests/tmp/logs logs-unix
- cp dist/buildstream/.coverage.* coverage-unix/coverage.unix
artifacts:
paths:
- coverage-unix/
......@@ -197,22 +157,19 @@ docs:
coverage:
stage: post
script:
- cd dist && ./unpack.sh && cd buildstream
- pip3 install --no-index .
- mkdir report
- cd report
- cp ../coverage-linux/coverage.linux .coverage
- cp ../coverage-unix/coverage.unix .
- coverage combine --rcfile=../.coveragerc -a ../coverage-unix/coverage.unix
- cp ../coverage-pytest-linux/coverage.pytest-linux .
- coverage combine --rcfile=../.coveragerc -a coverage.pytest-linux
- cp ../coverage-pytest-unix/coverage.pytest-unix .
- coverage combine --rcfile=../.coveragerc -a coverage.pytest-unix
- cp ../../../coverage-linux/coverage.linux .
- cp ../../../coverage-unix/coverage.unix .
- coverage combine --rcfile=../.coveragerc -a coverage.linux
- coverage combine --rcfile=../.coveragerc -a coverage.unix
- coverage report --rcfile=../.coveragerc -m
dependencies:
- pytest_linux
- integration_linux
- pytest_unix
- integration_unix
- linux-tests
- unix-tests
- source_dist
# Deploy, only for merges which land on master branch.
#
......
#!/usr/bin/env python3
#
# Copyright (C) 2018 Codethink Limited
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library. If not, see <http://www.gnu.org/licenses/>.
#
# Authors:
# Tristan Maat <tristan.maat@codethink.co.uk>
import os
import pytest
import shutil
import tempfile
def pytest_addoption(parser):
parser.addoption('--integration', action='store_true', default=False,
help='Run integration tests')
def pytest_runtest_setup(item):
if item.get_marker('integration') and not item.config.getvalue('integration'):
pytest.skip('skipping integration test')
@pytest.fixture(scope='session')
def integration_cache(request):
# Set the tempdir to the INTEGRATION_CACHE variable, or the
# default if that is not set.
cache_dir = os.environ.get('INTEGRATION_CACHE', tempfile.gettempdir())
# We use a separate tempdir to cache sources and artifacts to
# increase test speed
cache = os.path.join(cache_dir, 'integration-cache')
yield cache
# Clean up the artifacts after each test run - we only want to
# cache sources
try:
shutil.rmtree(os.path.join(cache, 'artifacts'))
except FileNotFoundError:
pass
......@@ -3,7 +3,7 @@ test=pytest
[tool:pytest]
addopts = --verbose --basetemp ./tmp --pep8 --cov=buildstream --cov-config .coveragerc
norecursedirs = integration-tests*
norecursedirs = integration-cache tmp __pycache__
python_files = tests/*/*.py
pep8maxlinelength = 119
pep8ignore =
......
......@@ -5,6 +5,9 @@ from tests.testutils import cli_integration as cli
from tests.testutils.integration import format_files, assert_contains
pytestmark = pytest.mark.integration
DATA_DIR = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"project"
......@@ -13,6 +16,7 @@ DATA_DIR = os.path.join(
# Test that an autotools build 'works' - we use the autotools sample
# amhello project for this.
@pytest.mark.integration
@pytest.mark.datafiles(DATA_DIR)
def test_autotools_build(cli, tmpdir, datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename)
......
......@@ -5,6 +5,9 @@ from tests.testutils import cli_integration as cli
from tests.testutils.integration import format_files, assert_contains
pytestmark = pytest.mark.integration
DATA_DIR = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"project"
......
......@@ -9,6 +9,9 @@ from tests.testutils import cli_integration as cli
from tests.testutils.integration import format_files, walk_dir
pytestmark = pytest.mark.integration
DATA_DIR = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"project"
......
......@@ -7,6 +7,9 @@ from tests.testutils import cli_integration as cli
from tests.testutils.integration import format_files, walk_dir
pytestmark = pytest.mark.integration
DATA_DIR = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"project"
......
......@@ -7,6 +7,9 @@ from tests.testutils import cli_integration as cli
from tests.testutils.integration import format_files, walk_dir
pytestmark = pytest.mark.integration
DATA_DIR = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"project"
......
......@@ -8,6 +8,9 @@ from tests.testutils import cli_integration as cli
from tests.testutils.integration import assert_contains
pytestmark = pytest.mark.integration
DATA_DIR = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"project"
......
......@@ -3,4 +3,4 @@ description: Some symlinks for the flatpak runtime environment
sources:
- kind: tar
url: project_dir:/files/usrmerge.tar.xz
ref: 14dd149ad8b177b0d8e42f1a4e522cb99a00ed666e2d70777e031a1ee6348265
ref: 96e4458fafb85c10fe6271ad8839754b6eabeceac8523f8f602dea6470db5961
......@@ -7,6 +7,9 @@ from tests.testutils import cli_integration as cli
from tests.testutils.integration import format_files, walk_dir
pytestmark = pytest.mark.integration
DATA_DIR = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"project"
......
......@@ -7,6 +7,9 @@ from buildstream import _yaml
from tests.testutils import cli_integration as cli
pytestmark = pytest.mark.integration
DATA_DIR = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"project"
......
......@@ -7,6 +7,9 @@ from tests.testutils import cli_integration as cli
from tests.testutils.integration import format_files, walk_dir
pytestmark = pytest.mark.integration
DATA_DIR = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"project"
......
......@@ -402,7 +402,7 @@ def cli(tmpdir):
# when running `bst shell`, but unfortunately cannot produce nice
# stacktraces.
@pytest.fixture()
def cli_integration(tmpdir):
def cli_integration(tmpdir, integration_cache):
directory = os.path.join(str(tmpdir), 'cache')
os.makedirs(directory)
......@@ -414,7 +414,8 @@ def cli_integration(tmpdir):
# We want to cache sources for integration tests more permanently,
# to avoid downloading the huge base-sdk repeatedly
fixture.configure({
'sourcedir': os.path.join(os.getcwd(), 'integration-cache', 'sources')
'sourcedir': os.path.join(integration_cache, 'sources'),
'artifactdir': os.path.join(integration_cache, 'artifacts')
})
return fixture
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment