Esempio n. 1
0
 def testCrashedGroupFactoryReturnsNoneWhenComponentIsBlacklisted(self):
     """Tests that ``CrashGroupFactory`` returns None when comp blacklisted."""
     components = [Component('bad_comp', 'bad_dir', '', 'team')]
     # Only construct the classifier once, rather than making a new one every
     # time we call a method on it.
     classifier = ComponentClassifier(components, 3, _MOCK_REPO_TO_DEP_PATH)
     feature = TouchCrashedComponentFeature(
         classifier, options={'blacklist': ['bad_comp']})
     frame = StackFrame(0, 'src/', 'func', 'bad_dir/f.cc',
                        'src/bad_dir/f.cc', [2, 3], 'h://repo')
     self.assertIsNone(feature.CrashedGroupFactory(frame))
Esempio n. 2
0
    def testReplacePath(self):
        """Tests feature can still match components with files after file move."""
        components = [Component('new_comp', ['src/dep/b/new_dir'], '', 'team')]
        # Only construct the classifier once, rather than making a new one every
        # time we call a method on it.
        classifier = ComponentClassifier(components, 3, _MOCK_REPO_TO_DEP_PATH)
        feature = TouchCrashedComponentFeature(
            classifier, options={'replace_path': {
                'a/old_dir': 'b/new_dir'
            }})

        match_func = feature.GetMatchFunction('src/dep')
        self.assertTrue(
            match_func(
                CrashedComponent('new_comp'),
                FileChangeInfo(ChangeType.MODIFY, 'a/old_dir/f.cc',
                               'a/old_dir/f.cc')))
 def setUp(self):
     super(TouchCrashedComponentFeatureTest, self).setUp()
     components = [
         Component(info['component'], info['dirs'], info.get('function'),
                   info.get('team'))
         for info in COMPONENT_CONFIG['component_info']
     ]
     # Only construct the classifier once, rather than making a new one every
     # time we call a method on it.
     self.classifier = ComponentClassifier(components,
                                           COMPONENT_CONFIG['top_n'])
     self.feature = TouchCrashedComponentFeature(self.classifier)
Esempio n. 4
0
    def __init__(self, get_repository, config):
        super(PredatorForClusterfuzz, self).__init__(get_repository, config)
        meta_weight = MetaWeight({
            'TouchCrashedFileMeta':
            MetaWeight({
                'MinDistance': Weight(2.),
                'TopFrameIndex': Weight(1.),
                'TouchCrashedFile': Weight(1.),
            }),
            'TouchCrashedDirectory':
            Weight(1.),
            'TouchCrashedComponent':
            Weight(1.),
            'NumberOfTouchedFiles':
            Weight(0.5),
        })

        min_distance_feature = MinDistanceFeature(get_repository)
        top_frame_index_feature = TopFrameIndexFeature()
        touch_crashed_file_feature = TouchCrashedFileFeature()

        meta_feature = WrapperMetaFeature([
            TouchCrashedFileMetaFeature([
                min_distance_feature, top_frame_index_feature,
                touch_crashed_file_feature
            ],
                                        options=config.feature_options.get(
                                            'TouchCrashedFileMetaFeature')),
            TouchCrashedDirectoryFeature(
                options=config.feature_options['TouchCrashedDirectory']),
            TouchCrashedComponentFeature(
                self._component_classifier,
                options=config.feature_options['TouchCrashedComponent']),
            NumberOfTouchedFilesFeature()
        ])

        self._predator = Predator(
            ChangelistClassifier(get_repository, meta_feature, meta_weight),
            self._component_classifier, self._project_classifier)
    def __init__(self, get_repository, config):
        super(FinditForClusterfuzz, self).__init__(get_repository, config)
        meta_weight = MetaWeight({
            'TouchCrashedFileMeta':
            MetaWeight({
                'MinDistance': Weight(1.),
                'TopFrameIndex': Weight(1.),
                'TouchCrashedFile': Weight(1.),
            }),
            'TouchCrashedDirectory':
            Weight(1.),
            'TouchCrashedComponent':
            Weight(1.)
        })
        meta_feature = WrapperMetaFeature([
            TouchCrashedFileMetaFeature(get_repository),
            TouchCrashedDirectoryFeature(),
            TouchCrashedComponentFeature(self._component_classifier)
        ])

        self._predator = Predator(
            ChangelistClassifier(get_repository, meta_feature, meta_weight),
            self._component_classifier, self._project_classifier)