Skip to content
Snippets Groups Projects
Commit 7c50534c authored by Qinusty's avatar Qinusty
Browse files

Add tests for cyclic variables check

parent 30346a94
No related branches found
No related tags found
Loading
Pipeline #28945063 failed
......@@ -8,3 +8,4 @@ pytest-env
pytest-pep8
pytest-pylint
pytest-xdist
pytest-timeout
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)
kind: manual
variables:
a: "%{prefix}/a"
prefix: "%{a}/some_prefix/"
\ No newline at end of file
name: test
......@@ -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
......
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