Пример #1
0
 def test_passes_artifacts_dir(self):
     cmdline = "echo %TAURUS_ARTIFACTS_DIR%" if is_windows() else "echo $TAURUS_ARTIFACTS_DIR"
     self.engine.eval_env()
     self.engine.prepare()
     process = self.obj._execute(cmdline, shell=True)
     stdout, _ = communicate(process)
     self.assertEquals(self.engine.artifacts_dir, stdout.strip())
    def test_communicate(self):
        self.sniff_log()

        out = b'\xf1\xe5\xedoutput'  # on py2 bytes is just str synonym
        err = b'\xf1\xe5\xederror'

        obj = MockPopen(out, err)

        output = communicate(obj)

        self.assertEqual(output, ("output", "error"))
Пример #3
0
 def tool_is_started(self):
     adb_path = os.path.join(get_full_path(self.tool_path, step_up=2), 'platform-tools', 'adb')
     if not os.path.isfile(adb_path):
         self.log.debug('adb is not found in sdk, trying to use an external one..')
         adb_path = 'adb'
     cmd = [adb_path, "shell", "getprop", "sys.boot_completed"]
     self.log.debug("Trying: %s", cmd)
     try:
         proc = shell_exec(cmd)
         out, _ = communicate(proc)
         return out.strip() == '1'
     except BaseException as exc:
         raise ToolError('Checking if android emulator starts is impossible: %s', exc)
Пример #4
0
    def _get_results(self):
        stdout, stderr = communicate(self.process)

        if stdout and (self.out == PIPE):
            self.log.debug("Output for %s:\n%s", self, stdout)

        if stderr and (self.err == PIPE):
            self.log.warning("Errors for %s:\n%s", self, stderr)

        self.log.debug("Task was finished with exit code %s: %s", self.process.returncode, self)
        if not self.ignore_failure and self.process.returncode != 0:
            if self.out != PIPE:
                self.log.warning("Output for %s:\n%s", self, stdout)
            raise CalledProcessError(self.process.returncode, self)
Пример #5
0
    def test_case_of_variables(self):
        env = {'aaa': 333, 'AAA': 666}
        line_tpl = "echo %%%s%%" if is_windows() else "echo $%s"
        cmdlines = [line_tpl % "aaa", line_tpl % "AAA"]
        results = set()

        for cmdline in cmdlines:
            self.obj.env.set(env)
            process = self.obj._execute(cmdline, shell=True)
            stdout, _ = communicate(process)
            results.add(stdout.strip())
        if is_windows():
            self.assertEqual(1, len(results))
        else:
            self.assertEqual(2, len(results))
Пример #6
0
    def test_passes_artifacts_dir_with_envs(self):
        cmdline = "echo %TAURUS_ARTIFACTS_DIR%" if is_windows() else "echo $TAURUS_ARTIFACTS_DIR"
        engine = EngineEmul({
            "settings": {
                "env": {"BZT_ARTIFACTS_DIR_ENV_TEST": "custom_dir_from_env"},
                "artifacts-dir": get_uniq_name(directory=get_full_path(TEST_DIR),
                                               prefix="${BZT_ARTIFACTS_DIR_ENV_TEST}/%Y-%m-%d_%H-%M-%S.%f")
            }})
        engine.eval_env()
        engine.prepare()
        executor = self.obj
        executor.engine = engine
        process = executor._execute(cmdline, shell=True)
        stdout, _ = communicate(process)
        self.assertEqual(engine.artifacts_dir, stdout.strip())

        if "BZT_ARTIFACTS_DIR_ENV_TEST" in os.environ:
            os.environ.pop("BZT_ARTIFACTS_DIR_ENV_TEST")