[Notes] [Git][BuildStream/buildstream][Qinusty/600-recursive-variables] Add tests for cyclic variables check



Title: GitLab

Qinusty pushed to branch Qinusty/600-recursive-variables at BuildStream / buildstream

Commits:

6 changed files:

Changes:

  • .gitlab-ci.yml
    ... ... @@ -84,25 +84,25 @@ source_dist:
    84 84
         - coverage-linux/
    
    85 85
     
    
    86 86
     tests-debian-9:
    
    87
    -  image: buildstream/testsuite-debian:9-master-114-4cab18e3
    
    87
    +  image: buildstream/testsuite-debian:9-master-117-aa3a33b3
    
    88 88
       <<: *linux-tests
    
    89 89
     
    
    90 90
     tests-fedora-27:
    
    91
    -  image: buildstream/testsuite-fedora:27-master-114-4cab18e3
    
    91
    +  image: buildstream/testsuite-fedora:27-master-117-aa3a33b3
    
    92 92
       <<: *linux-tests
    
    93 93
     
    
    94 94
     tests-fedora-28:
    
    95
    -  image: buildstream/testsuite-fedora:28-master-114-4cab18e3
    
    95
    +  image: buildstream/testsuite-fedora:28-master-117-aa3a33b3
    
    96 96
       <<: *linux-tests
    
    97 97
     
    
    98 98
     tests-ubuntu-18.04:
    
    99
    -  image: buildstream/testsuite-ubuntu:18.04-master-114-4cab18e3
    
    99
    +  image: buildstream/testsuite-ubuntu:18.04-master-117-aa3a33b3
    
    100 100
       <<: *linux-tests
    
    101 101
     
    
    102 102
     tests-unix:
    
    103 103
       # Use fedora here, to a) run a test on fedora and b) ensure that we
    
    104 104
       # can get rid of ostree - this is not possible with debian-8
    
    105
    -  image: buildstream/testsuite-fedora:27-master-114-4cab18e3
    
    105
    +  image: buildstream/testsuite-fedora:27-master-117-aa3a33b3
    
    106 106
       stage: test
    
    107 107
       variables:
    
    108 108
         BST_FORCE_BACKEND: "unix"
    

  • dev-requirements.txt
    ... ... @@ -8,3 +8,4 @@ pytest-env
    8 8
     pytest-pep8
    
    9 9
     pytest-pylint
    
    10 10
     pytest-xdist
    
    11
    +pytest-timeout

  • tests/format/variables.py
    1 1
     import os
    
    2 2
     import pytest
    
    3
    +import sys
    
    3 4
     from buildstream import _yaml
    
    4 5
     from buildstream._exceptions import ErrorDomain, LoadErrorReason
    
    5 6
     from tests.testutils.runcli import cli
    
    ... ... @@ -72,3 +73,20 @@ def test_missing_variable(cli, datafiles, tmpdir):
    72 73
         ])
    
    73 74
         result.assert_main_error(ErrorDomain.LOAD,
    
    74 75
                                  LoadErrorReason.UNRESOLVED_VARIABLE)
    
    76
    +
    
    77
    +
    
    78
    +@pytest.mark.timeout(3, method="signal")
    
    79
    +@pytest.mark.datafiles(os.path.join(DATA_DIR, 'cyclic_variables'))
    
    80
    +def test_cyclic_variables(cli, datafiles):
    
    81
    +    print_warning("Performing cyclic test, if this test times out it will " +
    
    82
    +                  "exit the test sequence")
    
    83
    +    project = os.path.join(datafiles.dirname, datafiles.basename)
    
    84
    +    result = cli.run(project=project, silent=True, args=[
    
    85
    +        "build", "cyclic.bst"
    
    86
    +    ])
    
    87
    +    result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.RECURSIVE_VARIABLE)
    
    88
    +
    
    89
    +
    
    90
    +def print_warning(msg):
    
    91
    +    RED, END = "\033[91m", "\033[0m"
    
    92
    +    print(("\n{}{}{}").format(RED, msg, END), file=sys.stderr)

  • tests/format/variables/cyclic_variables/cyclic.bst
    1
    +kind: manual
    
    2
    +
    
    3
    +variables:
    
    4
    +  a: "%{prefix}/a"
    
    5
    +  prefix: "%{a}/some_prefix/"
    \ No newline at end of file

  • tests/format/variables/cyclic_variables/project.conf
    1
    +name: test

  • tests/testutils/runcli.py
    ... ... @@ -94,14 +94,28 @@ class Result():
    94 94
         #    error_reason (any): The reason field of the error which occurred
    
    95 95
         #    fail_message (str): An optional message to override the automatic
    
    96 96
         #                        assertion error messages
    
    97
    +    #    debug (bool): If true, prints information regarding the exit state of the result()
    
    97 98
         # Raises:
    
    98 99
         #    (AssertionError): If any of the assertions fail
    
    99 100
         #
    
    100 101
         def assert_main_error(self,
    
    101 102
                               error_domain,
    
    102 103
                               error_reason,
    
    103
    -                          fail_message=''):
    
    104
    -
    
    104
    +                          fail_message='',
    
    105
    +                          *, debug=False):
    
    106
    +        if debug:
    
    107
    +            print(
    
    108
    +                """
    
    109
    +                Exit code: {}
    
    110
    +                Exception: {}
    
    111
    +                Domain:    {}
    
    112
    +                Reason:    {}
    
    113
    +                """.format(
    
    114
    +                    self.exit_code,
    
    115
    +                    self.exception,
    
    116
    +                    self.exception.domain,
    
    117
    +                    self.exception.reason
    
    118
    +                ))
    
    105 119
             assert self.exit_code == -1, fail_message
    
    106 120
             assert self.exc is not None, fail_message
    
    107 121
             assert self.exception is not None, fail_message
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]