def _acceptance_include(options):
    return robot_run(
        env.ACCEPTANCE_TEST_DIR,
        outputdir=env.RESULTS_DIR,
        suite=options,
        loglevel='trace'
    )
Esempio n. 2
0
    def _run_task(self):
        self.options["vars"].append("org:{}".format(self.org_config.name))
        options = self.options["options"].copy()
        for option in ("test", "include", "exclude", "xunit", "name"):
            if option in self.options:
                options[option] = self.options[option]
        options["variable"] = self.options.get("vars") or []
        options["outputdir"] = os.path.relpath(
            os.path.join(self.working_path, options.get("outputdir", ".")), os.getcwd()
        )

        num_failed = robot_run(self.options["suites"], **options)

        # These numbers are from the robot framework user guide:
        # http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#return-codes
        if 0 < num_failed < 250:
            raise RobotTestFailure(
                f"{num_failed} test{'' if num_failed == 1 else 's'} failed."
            )
        elif num_failed == 250:
            raise RobotTestFailure("250 or more tests failed.")
        elif num_failed == 251:
            raise RobotTestFailure("Help or version information printed.")
        elif num_failed == 252:
            raise RobotTestFailure("Invalid test data or command line options.")
        elif num_failed == 253:
            raise RobotTestFailure("Test execution stopped by user.")
        elif num_failed >= 255:
            raise RobotTestFailure("Unexpected internal error")
Esempio n. 3
0
    def _run_task(self):
        options = self.options["options"].copy()
        for option in ("tests", "include", "exclude", "xunit"):
            if option in self.options:
                options[option] = self.options[option]
        options["variable"] = self.options.get("vars") or []

        num_failed = robot_run(self.options["suites"], **options)
        if num_failed:
            raise RobotTestFailure("{} tests failed".format(num_failed))
    def _run_task(self):
        self.options["vars"].append("org:{}".format(self.org_config.name))
        options = self.options["options"].copy()
        for option in ("test", "include", "exclude", "xunit", "name"):
            if option in self.options:
                options[option] = self.options[option]
        options["variable"] = self.options.get("vars") or []

        num_failed = robot_run(self.options["suites"], **options)
        if num_failed:
            raise RobotTestFailure("{} tests failed".format(num_failed))
Esempio n. 5
0
    def _run_task(self):
        self.options["vars"].append("org:{}".format(self.org_config.name))
        options = self.options["options"].copy()
        for option in ("test", "include", "exclude", "xunit", "name"):
            if option in self.options:
                options[option] = self.options[option]
        options["variable"] = self.options.get("vars") or []
        options["outputdir"] = os.path.relpath(
            os.path.join(self.working_path, options.get("outputdir", ".")),
            os.getcwd())

        if self.options["processes"] > 1:
            cmd = [
                sys.executable,
                "-m",
                "pabot.pabot",
                "--pabotlib",
                "--processes",
                str(self.options["processes"]),
            ]
            # We need to convert options to their commandline equivalent
            for option, value in options.items():
                if isinstance(value, list):
                    for item in value:
                        cmd.extend([f"--{option}", str(item)])
                else:
                    cmd.extend([f"--{option}", str(value)])

            cmd.append(self.options["suites"])
            result = subprocess.run(cmd)
            num_failed = result.returncode

        else:
            num_failed = robot_run(self.options["suites"], **options)

        # These numbers are from the robot framework user guide:
        # http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#return-codes
        if 0 < num_failed < 250:
            raise RobotTestFailure(
                f"{num_failed} test{'' if num_failed == 1 else 's'} failed.")
        elif num_failed == 250:
            raise RobotTestFailure("250 or more tests failed.")
        elif num_failed == 251:
            raise RobotTestFailure("Help or version information printed.")
        elif num_failed == 252:
            raise RobotTestFailure(
                "Invalid test data or command line options.")
        elif num_failed == 253:
            raise RobotTestFailure("Test execution stopped by user.")
        elif num_failed >= 255:
            raise RobotTestFailure("Unexpected internal error")
Esempio n. 6
0
    def _run_task(self):
        self.options["vars"].append("org:{}".format(self.org_config.name))
        options = self.options["options"].copy()
        for option in ("test", "include", "exclude", "xunit", "name"):
            if option in self.options:
                options[option] = self.options[option]
        options["variable"] = self.options.get("vars") or []
        options["outputdir"] = os.path.relpath(
            os.path.join(self.working_path, options.get("outputdir", ".")),
            os.getcwd())

        num_failed = robot_run(self.options["suites"], **options)
        if num_failed:
            raise RobotTestFailure("{} tests failed".format(num_failed))
Esempio n. 7
0
    def _run_task(self):
        options = self.options["options"].copy()

        if "tests" in self.options:
            options["test"] = self.options["tests"]
        if "include" in self.options:
            options["include"] = self.options["include"]
        if "exclude" in self.options:
            options["exclude"] = self.options["exclude"]
        if "vars" in self.options:
            options["variable"] = self.options["vars"]

        # Inject CumulusCIRobotListener to build the CumulusCI library instance
        # from self.project_config instead of reinitializing CumulusCI's config
        # listener = CumulusCIRobotListener(self.project_config, self.org_config.name)
        # if 'listener' not in options:
        #    options['listener'] = []
        # options['listener'].append(listener)

        num_failed = robot_run(self.options["suites"], **options)
        if num_failed:
            raise RobotTestFailure("{} tests failed".format(num_failed))
Esempio n. 8
0
    def _run_task(self):
        self.options["vars"].append("org:{}".format(self.org_config.name))
        options = self.options["options"].copy()
        for option in ("test", "include", "exclude", "xunit", "name"):
            if option in self.options:
                options[option] = self.options[option]
        options["variable"] = self.options.get("vars") or []
        options["outputdir"] = os.path.relpath(
            os.path.join(self.working_path, options.get("outputdir", ".")), os.getcwd()
        )

        # get_namespace will potentially download sources that have
        # yet to be downloaded. For these downloaded sources we'll add
        # the cached directories to PYTHONPATH before running.
        source_paths = {}
        for source in self.options["sources"]:
            try:
                source_config = self.project_config.get_namespace(source)
                source_paths[source] = source_config.repo_root
            except NamespaceNotFoundError:
                raise TaskOptionsError(f"robot source '{source}' could not be found")

        # replace namespace prefixes with path to cached folder
        for i, path in enumerate(self.options["suites"]):
            prefix, _, path = path.rpartition(":")
            if prefix in source_paths:
                self.options["suites"][i] = os.path.join(source_paths[prefix], path)

        if self.options["processes"] > 1:
            # Since pabot runs multiple robot processes, and because
            # those processes aren't cci tasks, we have to set up the
            # environment to match what we do with a cci task. Specifically,
            # we need to add the repo root to PYTHONPATH (via the --pythonpath
            # option). Otherwise robot won't be able to find libraries and
            # resource files referenced as relative to the repo root
            cmd = [
                sys.executable,
                "-m",
                "pabot.pabot",
                "--pabotlib",
                "--processes",
                str(self.options["processes"]),
                "--pythonpath",
                str(self.project_config.repo_root),
            ]
            # We need to convert options to their commandline equivalent
            for option, value in options.items():
                if isinstance(value, list):
                    for item in value:
                        cmd.extend([f"--{option}", str(item)])
                else:
                    cmd.extend([f"--{option}", str(value)])

            # Add each source to pythonpath. Use --pythonpath since
            # pybot will need to use that option for each process that
            # it spawns.
            for path in source_paths.values():
                cmd.extend(["--pythonpath", path])

            cmd.extend(self.options["suites"])
            self.logger.info(
                f"pabot command: {' '.join([shlex.quote(x) for x in cmd])}"
            )
            result = subprocess.run(cmd)
            num_failed = result.returncode

        else:
            # Add each source to PYTHONPATH. Robot recommends that we
            # use pythonpathsetter instead of directly setting
            # sys.path. <shrug>
            for path in source_paths.values():
                pythonpathsetter.add_path(path, end=True)

            num_failed = robot_run(*self.options["suites"], **options)

        # These numbers are from the robot framework user guide:
        # http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#return-codes
        if 0 < num_failed < 250:
            raise RobotTestFailure(
                f"{num_failed} test{'' if num_failed == 1 else 's'} failed."
            )
        elif num_failed == 250:
            raise RobotTestFailure("250 or more tests failed.")
        elif num_failed == 251:
            raise RobotTestFailure("Help or version information printed.")
        elif num_failed == 252:
            raise RobotTestFailure("Invalid test data or command line options.")
        elif num_failed == 253:
            raise RobotTestFailure("Test execution stopped by user.")
        elif num_failed >= 255:
            raise RobotTestFailure("Unexpected internal error")
Esempio n. 9
0
def _acceptance_all():
    return robot_run(env.ACCEPTANCE_TEST_DIR,
                     outputdir=env.RESULTS_DIR,
                     loglevel='trace')
def _acceptance_all():
    return robot_run(
        env.ACCEPTANCE_TEST_DIR,
        outputdir=env.RESULTS_DIR,
        loglevel='trace'
    )