def checkForExpectedTests(self): """Assert that all tests provided through --test-name were found.""" missing_expected_tests = Test.missingExpectedTests() if not missing_expected_tests: return # Some tests were not found! msg_pair = (toolkit.plural(len(missing_expected_tests)), ','.join(missing_expected_tests)) logging.warning('\nSome test%s (%s) were not found!!!' % msg_pair) if hasattr(self.options, 'all') and self.options.all: raise PyTestUsageError( "Asked for test%s named %s which can't be found." % msg_pair) # Try to "fast-locate" missing tests logging.warning('Trying to "fast-locate" missing tests...') cached_test_map = core.getCachedTestMap() while missing_expected_tests: test_name = missing_expected_tests.pop() if test_name in cached_test_map: target = cached_test_map[test_name] self.build_tests((self.options, []), target, os.listdir(target)) # If you can't fast locate, use brute force else: logging.warning( 'Must use brute force since %s was not in cache...' % test_name) self.options.all = True Test._instances_map = {} # To avoid DuplicateName errors for target in plbranches: os.path.walk(target, self.build_tests, (self.options, [])) # Can't enter an infinite loop since we now have 'self.options.all == True' return self.checkForExpectedTests()
def checkForExpectedTests(self): """Assert that all tests provided through --test-name were found.""" missing_expected_tests = Test.missingExpectedTests() if not missing_expected_tests: return # Some tests were not found! msg_pair = (toolkit.plural(len(missing_expected_tests)), ','.join(missing_expected_tests)) logging.warning('\nSome test%s (%s) were not found!!!'%msg_pair) if hasattr(self.options, 'all') and self.options.all: raise PyTestUsageError( "Asked for test%s named %s which can't be found." % msg_pair) # Try to "fast-locate" missing tests logging.warning('Trying to "fast-locate" missing tests...') cached_test_map = core.getCachedTestMap() while missing_expected_tests: test_name = missing_expected_tests.pop() if test_name in cached_test_map: target = cached_test_map[test_name] self.build_tests( (self.options, []), target, os.listdir(target) ) # If you can't fast locate, use brute force else: logging.warning('Must use brute force since %s was not in cache...'%test_name) self.options.all = True Test._instances_map = {} # To avoid DuplicateName errors for target in plbranches: os.path.walk( target, self.build_tests, (self.options, []) ) # Can't enter an infinite loop since we now have 'self.options.all == True' return self.checkForExpectedTests()
def __init__(self, targets, options): cached_test_map = core.getCachedTestMap() for target in targets: if target in cached_test_map: test_dir = cached_test_map[target] self._listed = test_dir, target logging.warning("In %s\n %s"%self._listed) else: options.all = True options.test_name = target try: super(locate, self).__init__([target], options) except KeyError: logging.critical("No test named %s found."%options.test_name)
def __init__(self, targets, options): cached_test_map = core.getCachedTestMap() for target in targets: if target in cached_test_map: test_dir = cached_test_map[target] self._listed = test_dir, target logging.warning("In %s\n %s" % self._listed) else: options.all = True options.test_name = target try: super(locate, self).__init__([target], options) except KeyError: logging.critical("No test named %s found." % options.test_name)