Beispiel #1
0
    def execute(self, compile_base_path: str, timeout: Optional[int], logger: Logger):
        detector_invocation = ["java"] + self.detector.java_options + ["-jar", _quote(self.detector.jar_path)]
        command = detector_invocation + self._get_detector_arguments(self.version.get_compile(compile_base_path))
        command = " ".join(command)

        start = time.time()
        try:
            Shell.exec(command, logger=logger, timeout=timeout)
            self.result = Result.success
        except CommandFailedError as e:
            logger.error("Detector failed: %s", e)
            self.result = Result.error
            message = str(e)
            message_lines = str.splitlines(message)
            if len(message_lines) > 5000:
                self.message = "\n".join(message_lines[0:500]) + "\n" + "\n".join(message_lines[-4500:])
            else:
                self.message = message
        except TimeoutError:
            logger.error("Detector took longer than the maximum of %s seconds", timeout)
            self.result = Result.timeout
        finally:
            end = time.time()
            runtime = end - start
            self.runtime = runtime
            logger.info("Run took {0:.2f} seconds.".format(runtime))

        self.save()
Beispiel #2
0
def __create_image(dot_graph, working_directory, image_name):
    image_path = join(working_directory, image_name)
    if not exists(image_path):
        makedirs(working_directory, exist_ok=True)
        dot_path = image_path + ".dot"
        safe_write(dot_graph, dot_path, append=False)
        Shell.exec("dot -Tpng -o""{}"" ""{}""".format(image_path, dot_path))
        remove(dot_path)
    def setup(self):
        self.temp_dir = mkdtemp(prefix='mubench-checkout-git_')
        self.git_url = join(self.temp_dir, "remote")

        os.makedirs(self.git_url)
        Shell.exec("git init .", cwd=self.git_url)
        Shell.exec("touch foo", cwd=self.git_url)
        Shell.exec("git add -A", cwd=self.git_url)
        Shell.exec("git commit -a -m \"Initial commit.\"", cwd=self.git_url)

        self.checkouts_dir = join(self.temp_dir, "checkouts")
Beispiel #4
0
def exec_util(main: str, args: str = ""):
    base_path = dirname(__file__)
    utils_jar_path = join(base_path, UTILS_JAR_NAME)

    if exists(utils_jar_path) and not is_valid_file(utils_jar_path, UTILS_MD5):
        remove(utils_jar_path)

    if not exists(utils_jar_path):
        try:
            download_file(UTILS_JAR_URL, utils_jar_path, UTILS_MD5)
        except (URLError, ValueError, FileNotFoundError) as e:
            raise ValueError("utils unavailable: {}".format(e))

    return Shell.exec('java -cp "{}" de.tu_darmstadt.stg.mubench.utils.{} {}'.format(utils_jar_path, main, args))
Beispiel #5
0
 def _compile(commands: List[str], project_dir: str) -> None:
     logger = logging.getLogger("compile.tasks.exec")
     for command in commands:
         Shell.exec(command, cwd=project_dir, logger=logger)
Beispiel #6
0
 def test_command_failure(self):
     with assert_raises(CommandFailedError):
         Shell.exec("unknown command")
Beispiel #7
0
 def create(self) -> None:
     self._logger.debug("Create chackout directory %s", self.checkout_dir)
     makedirs(self.checkout_dir, exist_ok=True)
     self._logger.debug("Checkout from %s", self.url)
     Shell.exec("svn checkout \"{}@{}\" .".format(self.url, self.revision), cwd=self.checkout_dir)
Beispiel #8
0
 def _update(self, url: str, revision: str, path: str):
     Shell.exec("git checkout {} --quiet".format(revision), cwd=path, logger=self._logger)
Beispiel #9
0
 def check(self):
     Shell.exec("java -version")
Beispiel #10
0
 def check(self):
     Shell.exec("svn --version")
Beispiel #11
0
 def check(self):
     Shell.exec("git --version")
Beispiel #12
0
 def test_runs(self):
     Shell.exec("echo 'test'")
Beispiel #13
0
 def test_timeout(self):
     with assert_raises(TimeoutError):
         Shell.exec("sleep 10", timeout=1)
Beispiel #14
0
 def test_command_try_failure(self):
     assert not Shell.try_exec("unknown command")
Beispiel #15
0
 def test_command_try(self):
     assert Shell.try_exec("echo 'test'")
Beispiel #16
0
 def check(self):
     Shell.exec("mvn -v")
Beispiel #17
0
 def _clone(self, url: str, revision: str, path: str):
     Shell.exec("git clone {} . --quiet".format(url), cwd=path, logger=self._logger)
Beispiel #18
0
 def check(self):
     Shell.exec("gradle -version")
Beispiel #19
0
 def _is_repo(self, path: str):
     return exists(path) and Shell.try_exec("git status", cwd=path, logger=self._logger)
Beispiel #20
0
 def check(self):
     Shell.exec("dot -V")
Beispiel #21
0
 def exists(self) -> bool:
     return exists(self.checkout_dir) and Shell.try_exec("svn info", cwd=self.checkout_dir)
Beispiel #22
0
 def test_output(self):
     out = Shell.exec("echo test")
     assert_equals("test" + os.linesep, out)