| 1 |
# Pylint doesn't play well with fixtures and dependency injection from pytest |
| 2 |
# pylint: disable=redefined-outer-name |
| 3 |
|
| 4 |
import os |
| 5 |
import pytest |
| 6 |
|
| 7 |
from buildstream._testing._cachekeys import check_cache_key_stability |
| 8 |
from buildstream._testing.runcli import cli # pylint: disable=unused-import |
| 9 |
from buildstream._testing._utils.site import HAVE_BZR, HAVE_GIT, IS_LINUX, MACHINE_ARCH |
| 10 |
|
| 11 |
|
| 12 |
# Project directory |
| 13 |
DATA_DIR = os.path.join( |
| 14 |
os.path.dirname(os.path.realpath(__file__)), |
| 15 |
"project", |
| 16 |
) |
| 17 |
|
| 18 |
|
| 19 |
# The cache key test uses a project which exercises all plugins, |
| 20 |
# so we cant run it at all if we dont have them installed. |
| 21 |
# |
| 22 |
@pytest.mark.skipif(MACHINE_ARCH != "x86-64", reason="Cache keys depend on architecture") |
| 23 |
@pytest.mark.skipif(not IS_LINUX, reason="Only available on linux") |
| 24 |
@pytest.mark.skipif(HAVE_BZR is False, reason="bzr is not available") |
| 25 |
@pytest.mark.skipif(HAVE_GIT is False, reason="git is not available") |
| 26 |
@pytest.mark.datafiles(DATA_DIR) |
| 27 |
def test_cache_key(datafiles, cli): |
| 28 |
project = str(datafiles) |
| 29 |
|
| 30 |
# Workaround bug in recent versions of setuptools: newer |
| 31 |
# versions of setuptools fail to preserve symbolic links |
| 32 |
# when creating a source distribution, causing this test |
| 33 |
# to fail from a dist tarball. |
| 34 |
goodbye_link = os.path.join(project, "files", "local", "usr", "bin", "goodbye") |
| 35 |
os.unlink(goodbye_link) |
| 36 |
os.symlink("hello", goodbye_link) |
| 37 |
# pytest-datafiles does not copy mode bits |
| 38 |
# https://github.com/omarkohl/pytest-datafiles/issues/11 |
| 39 |
os.chmod(goodbye_link, 0o755) |
| 40 |
|
| 41 |
check_cache_key_stability(project, cli) |