Exemplo n.º 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()
Exemplo n.º 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)
Exemplo n.º 3
0
    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")
Exemplo n.º 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))
Exemplo n.º 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)
Exemplo n.º 6
0
 def test_command_failure(self):
     with assert_raises(CommandFailedError):
         Shell.exec("unknown command")
Exemplo n.º 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)
Exemplo n.º 8
0
 def _update(self, url: str, revision: str, path: str):
     Shell.exec("git checkout {} --quiet".format(revision), cwd=path, logger=self._logger)
Exemplo n.º 9
0
 def check(self):
     Shell.exec("java -version")
Exemplo n.º 10
0
 def check(self):
     Shell.exec("svn --version")
Exemplo n.º 11
0
 def check(self):
     Shell.exec("git --version")
Exemplo n.º 12
0
 def test_runs(self):
     Shell.exec("echo 'test'")
Exemplo n.º 13
0
 def test_timeout(self):
     with assert_raises(TimeoutError):
         Shell.exec("sleep 10", timeout=1)
Exemplo n.º 14
0
 def test_command_try_failure(self):
     assert not Shell.try_exec("unknown command")
Exemplo n.º 15
0
 def test_command_try(self):
     assert Shell.try_exec("echo 'test'")
Exemplo n.º 16
0
 def check(self):
     Shell.exec("mvn -v")
Exemplo n.º 17
0
 def _clone(self, url: str, revision: str, path: str):
     Shell.exec("git clone {} . --quiet".format(url), cwd=path, logger=self._logger)
Exemplo n.º 18
0
 def check(self):
     Shell.exec("gradle -version")
Exemplo n.º 19
0
 def _is_repo(self, path: str):
     return exists(path) and Shell.try_exec("git status", cwd=path, logger=self._logger)
Exemplo n.º 20
0
 def check(self):
     Shell.exec("dot -V")
Exemplo n.º 21
0
 def exists(self) -> bool:
     return exists(self.checkout_dir) and Shell.try_exec("svn info", cwd=self.checkout_dir)
Exemplo n.º 22
0
 def test_output(self):
     out = Shell.exec("echo test")
     assert_equals("test" + os.linesep, out)