def test_benchmark_run(self): experiment = Experiment(Experiment.BENCHMARK, self.detector, "-findings_path-") run = experiment.get_run(self.version) assert_is_instance(run, Run) assert_equals(1, len(run.executions)) assert_is_instance(run.executions[0], MineAndDetectExecution)
def test_top_findings_run(self): experiment = Experiment(Experiment.TOP_FINDINGS, self.detector, "-findings_path-", 42) run = experiment.get_run(self.version) assert_is_instance(run, Run) assert_equals(1, len(run.executions)) assert_is_instance(run.executions[0], MineAndDetectExecution) assert_is_instance(run.executions[0].findings_filter, AllFindings) assert_equals(42, run.executions[0].findings_filter.limit)
def test_provided_patterns_run_no_patterns(self): self.version._MISUSES = [ create_misuse("-1-", project=self.project, patterns=[]) ] experiment = Experiment(Experiment.PROVIDED_PATTERNS, self.detector, "-findings_path-") run = experiment.get_run(self.version) assert_is_instance(run, Run) assert_equals(0, len(run.executions))
def setup(self): self.temp_dir = mkdtemp(prefix='mubench-detect-test_') self.compiles_path = join(self.temp_dir, "checkout") self.findings_path = join(self.temp_dir, "findings") os.chdir(self.temp_dir) self.project = create_project("-project-") self.version = create_version("-version-", project=self.project) self.detector = StubDetector() self.test_run_execution = MineAndDetectExecution( self.detector, self.version, self.findings_path, AllFindings(self.detector)) self.test_run = Run([self.test_run_execution]) self.test_run.execute = MagicMock( return_value="test execution successful") self.experiment = Experiment(Experiment.TOP_FINDINGS, self.detector, self.findings_path) self.experiment.get_run = lambda v: self.test_run self.uut = Detect(self.compiles_path, self.experiment, None, False) self.last_invoke = None # mock command-line invocation def mock_invoke_detector(detect, absolute_misuse_detector_path: str, detector_args: str): self.last_invoke = absolute_misuse_detector_path, detector_args
def setup(self): self.temp_dir = mkdtemp(prefix='mubench-detect-test_') self.compiles_path = join(self.temp_dir, "checkout") self.findings_path = join(self.temp_dir, "findings") detector = StubDetector() experiment = Experiment(Experiment.PROVIDED_PATTERNS, detector, self.findings_path) self.uut = Detect(self.compiles_path, experiment, None, False) self.uut._download = MagicMock(return_value=True)
def __get_experiment(self): ex_ids = { 1: Experiment.PROVIDED_PATTERNS, 2: Experiment.TOP_FINDINGS, 3: Experiment.BENCHMARK } try: limit = self.config.limit except AttributeError: limit = 0 return Experiment(ex_ids.get(self.config.experiment), self.__get_detector(), Benchmark.FINDINGS_PATH, limit)