summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Smith <qinusty@gmail.com>2018-08-29 11:54:47 +0100
committerJosh Smith <qinusty@gmail.com>2018-08-29 17:13:35 +0100
commit26b7c50c860489c1852d5c8dc82a448b1d9aeb97 (patch)
tree1d3ab51e55dc3ae1e151c2ae82a3e85683f71222
parent2992a6755270939cd5fedaf92493ae4b4884dc09 (diff)
downloadbuildstream-Qinusty/600-recursive-variables.tar.gz
Add tests for cyclic variables checkQinusty/600-recursive-variables
Note: This modifies the docker containers used for testing to supply the pytest-timeout package.
-rw-r--r--.gitlab-ci.yml10
-rw-r--r--dev-requirements.txt1
-rw-r--r--tests/format/variables.py18
-rw-r--r--tests/format/variables/cyclic_variables/cyclic.bst5
-rw-r--r--tests/format/variables/cyclic_variables/project.conf1
-rw-r--r--tests/testutils/runcli.py18
6 files changed, 46 insertions, 7 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 16f7d04a9..d57d33f83 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -84,25 +84,25 @@ source_dist:
- coverage-linux/
tests-debian-9:
- image: buildstream/testsuite-debian:9-master-114-4cab18e3
+ image: buildstream/testsuite-debian:9-master-117-aa3a33b3
<<: *linux-tests
tests-fedora-27:
- image: buildstream/testsuite-fedora:27-master-114-4cab18e3
+ image: buildstream/testsuite-fedora:27-master-117-aa3a33b3
<<: *linux-tests
tests-fedora-28:
- image: buildstream/testsuite-fedora:28-master-114-4cab18e3
+ image: buildstream/testsuite-fedora:28-master-117-aa3a33b3
<<: *linux-tests
tests-ubuntu-18.04:
- image: buildstream/testsuite-ubuntu:18.04-master-114-4cab18e3
+ image: buildstream/testsuite-ubuntu:18.04-master-117-aa3a33b3
<<: *linux-tests
tests-unix:
# Use fedora here, to a) run a test on fedora and b) ensure that we
# can get rid of ostree - this is not possible with debian-8
- image: buildstream/testsuite-fedora:27-master-114-4cab18e3
+ image: buildstream/testsuite-fedora:27-master-117-aa3a33b3
stage: test
variables:
BST_FORCE_BACKEND: "unix"
diff --git a/dev-requirements.txt b/dev-requirements.txt
index ee2db0351..c88b4c723 100644
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -8,3 +8,4 @@ pytest-env
pytest-pep8
pytest-pylint
pytest-xdist
+pytest-timeout
diff --git a/tests/format/variables.py b/tests/format/variables.py
index d570bf01d..d01d87e5b 100644
--- a/tests/format/variables.py
+++ b/tests/format/variables.py
@@ -1,5 +1,6 @@
import os
import pytest
+import sys
from buildstream import _yaml
from buildstream._exceptions import ErrorDomain, LoadErrorReason
from tests.testutils.runcli import cli
@@ -72,3 +73,20 @@ def test_missing_variable(cli, datafiles, tmpdir):
])
result.assert_main_error(ErrorDomain.LOAD,
LoadErrorReason.UNRESOLVED_VARIABLE)
+
+
+@pytest.mark.timeout(3, method="signal")
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'cyclic_variables'))
+def test_cyclic_variables(cli, datafiles):
+ print_warning("Performing cyclic test, if this test times out it will " +
+ "exit the test sequence")
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ result = cli.run(project=project, silent=True, args=[
+ "build", "cyclic.bst"
+ ])
+ result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.RECURSIVE_VARIABLE)
+
+
+def print_warning(msg):
+ RED, END = "\033[91m", "\033[0m"
+ print(("\n{}{}{}").format(RED, msg, END), file=sys.stderr)
diff --git a/tests/format/variables/cyclic_variables/cyclic.bst b/tests/format/variables/cyclic_variables/cyclic.bst
new file mode 100644
index 000000000..a05a40b27
--- /dev/null
+++ b/tests/format/variables/cyclic_variables/cyclic.bst
@@ -0,0 +1,5 @@
+kind: manual
+
+variables:
+ a: "%{prefix}/a"
+ prefix: "%{a}/some_prefix/" \ No newline at end of file
diff --git a/tests/format/variables/cyclic_variables/project.conf b/tests/format/variables/cyclic_variables/project.conf
new file mode 100644
index 000000000..b32753625
--- /dev/null
+++ b/tests/format/variables/cyclic_variables/project.conf
@@ -0,0 +1 @@
+name: test
diff --git a/tests/testutils/runcli.py b/tests/testutils/runcli.py
index ee4eb957e..8cd5bcb75 100644
--- a/tests/testutils/runcli.py
+++ b/tests/testutils/runcli.py
@@ -94,14 +94,28 @@ class Result():
# error_reason (any): The reason field of the error which occurred
# fail_message (str): An optional message to override the automatic
# assertion error messages
+ # debug (bool): If true, prints information regarding the exit state of the result()
# Raises:
# (AssertionError): If any of the assertions fail
#
def assert_main_error(self,
error_domain,
error_reason,
- fail_message=''):
-
+ fail_message='',
+ *, debug=False):
+ if debug:
+ print(
+ """
+ Exit code: {}
+ Exception: {}
+ Domain: {}
+ Reason: {}
+ """.format(
+ self.exit_code,
+ self.exception,
+ self.exception.domain,
+ self.exception.reason
+ ))
assert self.exit_code == -1, fail_message
assert self.exc is not None, fail_message
assert self.exception is not None, fail_message