[Notes] [Git][BuildStream/buildstream][bschubert/cleanup-local-state] Don't register exceptions when not running the testsuite



Title: GitLab

Benjamin Schubert pushed to branch bschubert/cleanup-local-state at BuildStream / buildstream

Commits:

1 changed file:

Changes:

  • buildstream/_exceptions.py
    ... ... @@ -19,6 +19,7 @@
    19 19
     #        Tiago Gomes <tiago gomes codethink co uk>
    
    20 20
     
    
    21 21
     from enum import Enum
    
    22
    +import os
    
    22 23
     
    
    23 24
     # Disable pylint warnings for whole file here:
    
    24 25
     # pylint: disable=global-statement
    
    ... ... @@ -50,6 +51,9 @@ def get_last_exception():
    50 51
     # Used by regression tests
    
    51 52
     #
    
    52 53
     def get_last_task_error():
    
    54
    +    if 'BST_TEST_SUITE' not in os.environ:
    
    55
    +        raise BstError("Getting the last task error is only supported when running tests")
    
    56
    +
    
    53 57
         global _last_task_error_domain
    
    54 58
         global _last_task_error_reason
    
    55 59
     
    
    ... ... @@ -67,11 +71,12 @@ def get_last_task_error():
    67 71
     # tests about how things failed in a machine readable way
    
    68 72
     #
    
    69 73
     def set_last_task_error(domain, reason):
    
    70
    -    global _last_task_error_domain
    
    71
    -    global _last_task_error_reason
    
    74
    +    if 'BST_TEST_SUITE' in os.environ:
    
    75
    +        global _last_task_error_domain
    
    76
    +        global _last_task_error_reason
    
    72 77
     
    
    73
    -    _last_task_error_domain = domain
    
    74
    -    _last_task_error_reason = reason
    
    78
    +        _last_task_error_domain = domain
    
    79
    +        _last_task_error_reason = reason
    
    75 80
     
    
    76 81
     
    
    77 82
     class ErrorDomain(Enum):
    
    ... ... @@ -126,7 +131,8 @@ class BstError(Exception):
    126 131
             self.reason = reason
    
    127 132
     
    
    128 133
             # Hold on to the last raised exception for testing purposes
    
    129
    -        _last_exception = self
    
    134
    +        if 'BST_TEST_SUITE' in os.environ:
    
    135
    +            _last_exception = self
    
    130 136
     
    
    131 137
     
    
    132 138
     # PluginError
    



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