def tear_up(self): super(BaseDriver, self).tear_up() self.create_test_workspace() # If requested, skip internal testcases if (self.global_env['options'].skip_internal_tests and self.test_env['test_name'].startswith('internal-tests')): self.result.set_status('DEAD', 'Skipping internal testcase') return discriminants.add_discriminants( self.global_env['options'].discriminants) # If asked to run under Valgrind, prepare a Valgrind instance if self.global_env['options'].valgrind: valgrind_supp = self.test_env.get('valgrind_suppressions', None) if valgrind_supp: valgrind_supp = os.path.join(self.test_dir, valgrind_supp) self.valgrind = Valgrind(self.testsuite_dir, self.working_dir(), valgrind_supp) else: self.valgrind = None self.valgrind_errors = [] self.check_file(self.expected_file) # Load the expected failure matcher for this testcase try: expect_failure_matcher = discriminants.Matcher.from_json( self.test_env.get('expect_failure', [])) except ValueError as exc: raise SetupError('Invalid "expect_failure" entry: {}'.format(exc)) # Determine whether we do have an expected failure self.expect_failure_comment = expect_failure_matcher.matches() if self.expect_failure_comment is None: self.expect_failure = False else: # Because of wrapping in the YAML file, we can get multi-line # strings, which is not valid for comments. self.expect_failure_comment = (self.expect_failure_comment.replace( '\n', ' ').strip()) self.expect_failure = True # Use the specified timeout if any, otherwise fallback to the default # one. try: timeout = self.test_env['timeout'] except KeyError: self.timeout = self.DEFAULT_TIMEOUT else: if (not isinstance(timeout, int) or timeout < 0): raise SetupError( 'Invalid "timeout" entry: expected a positive' ' number of seconds, got {} instead'.format(timeout)) self.timeout = timeout
def tear_up(self): super(BaseDriver, self).tear_up() self.create_test_workspace() # If asked to run under Valgrind, prepare a Valgrind instance if self.global_env['options'].valgrind: valgrind_supp = self.test_env.get('valgrind_suppressions', None) if valgrind_supp: valgrind_supp = os.path.join(self.test_dir, valgrind_supp) self.valgrind = Valgrind(self.testsuite_dir, self.working_dir(), valgrind_supp) else: self.valgrind = None self.valgrind_errors = [] # If this test requires sources from external repositories, make sure # we have them at hand. Otherwise skip it. repos = self.test_env.get('external_sources', []) bad_repos_exc = SetupError('Invalid "external_sources" entry: list of' ' strings expected') if not isinstance(repos, list): raise bad_repos_exc for repo in repos: if not isinstance(repo, str): raise bad_repos_exc if not os.path.exists( os.path.join(self.testsuite_dir, 'ext_src', repo)): self.result.set_status( 'DEAD', 'Missing external source: {}'.format(repo)) self.check_file(self.expected_file) # See if we expect a failure for this testcase try: comment = self.test_env['expect_failure'] except KeyError: self.expect_failure = False self.expect_failure_comment = None else: # Because of wrapping in the YAML file, we can get multi-line # strings, which is not valid for comments. comment = comment.replace('\n', ' ').strip() self.expect_failure = True if not (comment is None or isinstance(comment, basestring)): raise SetupError('Invalid "expect_failure" entry:' ' expected a string but got {}'.format( type(comment))) self.expect_failure_comment = comment # Use the specified timeout if any, otherwise fallback to the default # one. try: timeout = self.test_env['timeout'] except KeyError: self.timeout = self.DEFAULT_TIMEOUT else: if (not isinstance(timeout, int) or timeout < 0): raise SetupError( 'Invalid "timeout" entry: expected a positive' ' number of seconds, got {} instead'.format(timeout)) self.timeout = timeout