summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbst-marge-bot <marge-bot@buildstream.build>2019-10-08 10:49:26 +0000
committerbst-marge-bot <marge-bot@buildstream.build>2019-10-08 10:49:26 +0000
commit97cd51d6d018c43d32ca433f0bcad7cf0dd77ca0 (patch)
treee31d0addd07b9f83510692f313bf344bd009f719
parentd913e5cbf8035fac76b90cde3cac71b08ec70a13 (diff)
parent7f00500184d799539980ad5fc4d5ef5ddde16d35 (diff)
downloadbuildstream-97cd51d6d018c43d32ca433f0bcad7cf0dd77ca0.tar.gz
Merge branch 'bschubert/fix-xdg-temppaths' into 'master'
setup.cfg: Fix xdg env vars to not affect the host See merge request BuildStream/buildstream!1627
-rw-r--r--setup.cfg5
-rwxr-xr-xtests/conftest.py18
-rw-r--r--tox.ini8
3 files changed, 23 insertions, 8 deletions
diff --git a/setup.cfg b/setup.cfg
index 7a62f9282..a8919fdca 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -16,10 +16,7 @@ norecursedirs = tests/integration/project integration-cache tmp __pycache__ .egg
python_files = tests/*/*.py
env =
D:BST_TEST_SUITE=True
- D:HOME=./tmp
- D:XDG_CACHE_HOME=./tmp/cache
- D:XDG_CONFIG_HOME=./tmp/config
- D:XDG_DATA_HOME=./tmp/share
+
markers =
integration: run test only if --integration option is specified
remoteexecution: run test only if --remote-execution option is specified
diff --git a/tests/conftest.py b/tests/conftest.py
index 9189d263e..68fdba7fb 100755
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -137,3 +137,21 @@ register_repo_kind('zip', Zip, None)
# buildstream.testing
def pytest_sessionstart(session):
sourcetests_collection_hook(session)
+
+
+#################################################
+# Isolated environment #
+#################################################
+@pytest.fixture(scope="session", autouse=True)
+def set_xdg_paths(pytestconfig):
+ for env_var, default in [
+ ("HOME", "tmp"),
+ ("XDG_CACHE_HOME", "tmp/cache"),
+ ("XDG_CONFIG_HOME", "tmp/config"),
+ ("XDG_DATA_HOME", "tmp/share"),
+ ]:
+ value = os.environ.get("BST_TEST_{}".format(env_var))
+ if value is None:
+ value = os.path.join(pytestconfig.getoption("basetemp"), default)
+
+ os.environ[env_var] = value
diff --git a/tox.ini b/tox.ini
index 50699177e..a00197d13 100644
--- a/tox.ini
+++ b/tox.ini
@@ -55,10 +55,10 @@ passenv =
#
setenv =
py{35,36,37}: COVERAGE_FILE = {envtmpdir}/.coverage
- py{35,36,37}: HOME = {envtmpdir}
- py{35,36,37}: XDG_CACHE_HOME = {envtmpdir}/cache
- py{35,36,37}: XDG_CONFIG_HOME = {envtmpdir}/config
- py{35,36,37}: XDG_DATA_HOME = {envtmpdir}/share
+ py{35,36,37}: BST_TEST_HOME = {envtmpdir}
+ py{35,36,37}: BST_TEST_XDG_CACHE_HOME = {envtmpdir}/cache
+ py{35,36,37}: BST_TEST_XDG_CONFIG_HOME = {envtmpdir}/config
+ py{35,36,37}: BST_TEST_XDG_DATA_HOME = {envtmpdir}/share
# This is required to get coverage for Cython
py{35,36,37}-!nocover: BST_CYTHON_TRACE = 1