예제 #1
0
    def run(self):

        with virtualenv(self._project_name) as env:
            old_dir = os.getcwd()
            os.chdir(self._path)

            packages = self._extract_necessary_packages()
            env.add_packages_for_installation(packages)
            env.add_package_for_installation("nose2")
            env.add_package_for_installation("nose2[coverage_plugin]>=0.6.5")
            env.add_package_for_installation("benchexec")

            if self._time_limit > 0:
                command = "runexec --timelimit={}s -- ".format(
                    self._time_limit)
            else:
                command = "runexec -- "
            command += "nose2 --with-coverage --verbose"
            out, err = env.run_commands([command])
            if os.path.exists(os.path.join(
                    os.getcwd(), "output.log")) and os.path.isfile(
                        os.path.join(os.getcwd(), "output.log")):
                with open(os.path.join(os.getcwd(), "output.log")) as out_file:
                    out += "\n".join(out_file.readlines())

            os.chdir(old_dir)
            return out, err
예제 #2
0
    def run(self) -> Optional[Tuple[str, str]]:
        setup_py = os.path.join(self._path, "setup.py")
        if not os.path.exists(setup_py) and not os.path.isfile(setup_py):
            return None

        with virtualenv(self._project_name) as env:
            old_dir = os.getcwd()
            os.chdir(self._path)
            packages = self._extract_necessary_packages()
            env.add_packages_for_installation(packages)
            env.add_package_for_installation("benchexec")

            if self._time_limit > 0:
                command = "runexec --timelimit={}s -- ".format(
                    self._time_limit)
            else:
                command = "runexec -- "
            command += "python setup.py test"
            out, err = env.run_commands([command])
            if os.path.exists(os.path.join(
                    os.getcwd(), "output.log")) and os.path.isfile(
                        os.path.join(os.getcwd(), "output.log")):
                with open(os.path.join(os.getcwd(), "output.log")) as out_file:
                    out += "\n".join(out_file.readlines())

            os.chdir(old_dir)
            return out, err
예제 #3
0
    def run(self) -> Optional[Tuple[str, str]]:
        # TODO make sure nothing goes wrong here

        with virtualenv(self._project_name, self._venv_path) as env:
            old_dir = os.getcwd()
            os.chdir(self._path)

            if "-" in self._project_name and os.path.exists(
                    os.path.join(os.getcwd(),
                                 self._project_name.replace("-", ""))):
                project_name = self._project_name.replace("-", "")
            elif "_" in self._project_name and os.path.exists(
                    os.path.join(os.getcwd(),
                                 self._project_name.replace("_", ""))):
                project_name = self._project_name.replace("_", "")
            elif "-" in self._project_name and os.path.exists(
                    os.path.join(os.getcwd(),
                                 self._project_name.replace("-", "_"))):
                project_name = self._project_name.replace("-", "_")
            elif os.path.exists(os.path.join(os.getcwd(), self._project_name)):
                project_name = self._project_name
            else:
                directories = find_packages(".", exclude=["test", "tests"])
                if len(directories) == 0 and os.path.exists(
                        os.path.join(os.getcwd(), "src")):
                    directories = find_packages("src",
                                                exclude=["test", "tests"])
                project_name = directories[0] if len(directories) > 1 else "."

            packages = self._extract_necessary_packages()
            env.add_packages_for_installation(packages)
            env.add_package_for_installation("pytest")
            env.add_package_for_installation("pytest-cov")
            env.add_package_for_installation("benchexec")

            if self._time_limit > 0:
                command = "runexec --timelimit={}s -- ".format(
                    self._time_limit)
            else:
                command = "runexec -- "
            command += "pytest --cov={} --cov-report=term-missing".format(
                project_name)
            if self._junit_xml_file is not None:
                command += " --junitxml={}".format(self._junit_xml_file)

            out, err = env.run_commands([command])
            if os.path.exists(os.path.join(
                    os.getcwd(), "output.log")) and os.path.isfile(
                        os.path.join(os.getcwd(), "output.log")):
                with open(os.path.join(os.getcwd(), "output.log")) as f:
                    out += "\n".join(f.readlines())
            os.chdir(old_dir)
            return out, err