def test_no_dependencies(self, isdir_mock):
        isdir_mock.return_value = False
        pc = ProjectCompile("/base/", [])

        cp = pc.get_dependency_classpath()

        assert_equals(cp, "")
    def test_builds_classpath(self, listdir_mock, isdir_mock):
        isdir_mock.return_value = True
        listdir_mock.return_value = ["foo.jar", "bar.jar"]
        pc = ProjectCompile("/base/", [])

        cp = pc.get_dependency_classpath()

        assert_equals(cp,
                      "/base/dependencies/foo.jar:/base/dependencies/bar.jar")
예제 #3
0
 def _get_detector_arguments(self, project_compile: ProjectCompile):
     return [
         self.key_findings_file, _quote(self._findings_file_path),
         self.key_run_file, _quote(self._run_file_path),
         self.key_detector_mode, _quote(self._run_mode_detector_argument),
         self.key_training_src_path, _quote(project_compile.get_pattern_source_path(self.misuse)),
         self.key_training_classpath, _quote(project_compile.get_pattern_classes_path(self.misuse)),
         self.key_target_src_path, _quote(project_compile.misuse_source_path),
         self.key_target_classpath, _quote(project_compile.misuse_classes_path)
     ]
예제 #4
0
 def __copy_pattern_sources(misuses: List[Misuse],
                            project_compile: ProjectCompile):
     for misuse in misuses:
         pattern_source_path = project_compile.get_pattern_source_path(
             misuse)
         for pattern in misuse.patterns:
             pattern.copy(pattern_source_path)
예제 #5
0
 def _get_detector_arguments(self, project_compile: ProjectCompile):
     return {
         self.key_findings_file:
         self._findings_file_path,
         self.key_run_file:
         self._run_file_path,
         self.key_detector_mode:
         self._run_mode_detector_argument,
         self.key_training_src_path:
         project_compile.get_pattern_source_path(self.misuse),
         self.key_training_classpath:
         project_compile.get_pattern_classes_path(self.misuse),
         self.key_target_src_path:
         project_compile.misuse_source_path,
         self.key_target_classpath:
         project_compile.misuse_classes_path,
         self.key_dependency_classpath:
         project_compile.get_full_classpath()
     }
예제 #6
0
 def _get_detector_arguments(self, project_compile: ProjectCompile):
     return {
         self.key_findings_file: self._findings_file_path,
         self.key_run_file: self._run_file_path,
         self.key_detector_mode: self._run_mode_detector_argument,
         self.key_target_src_path: project_compile.original_sources_path,
         self.key_target_classpath: project_compile.original_classes_path,
         self.key_dependency_classpath:
         project_compile.get_full_classpath()
     }
예제 #7
0
 def __copy_pattern_classes(misuses: List[Misuse], classes_path: str,
                            project_compile: ProjectCompile):
     for misuse in misuses:
         pattern_classes_path = project_compile.get_pattern_classes_path(
             misuse)
         for pattern in misuse.patterns:
             pattern_class_file_name = pattern.relative_path_without_extension + ".class"
             new_name = join(pattern_classes_path, pattern_class_file_name)
             makedirs(dirname(new_name), exist_ok=True)
             shutil.copy(join(classes_path, pattern_class_file_name),
                         new_name)
 def _get_detector_arguments(self, project_compile: ProjectCompile):
     return [
         self.key_findings_file,
         _quote(self._findings_file_path), self.key_run_file,
         _quote(self._run_file_path), self.key_detector_mode,
         _quote(self._run_mode_detector_argument), self.key_target_src_path,
         _quote(project_compile.original_sources_path),
         self.key_target_classpath,
         _quote(project_compile.original_classes_path),
         self.key_dependency_classpath,
         _quote(project_compile.get_dependency_classpath())
     ]
예제 #9
0
 def get_compile(self, base_path: str) -> ProjectCompile:
     return ProjectCompile(
         join(base_path, self.project_id, self.version_id), self.misuses)