Пример #1
0
    def get_main_output(self, new_args):
        process = subprocess.Popen(
            [sys.executable, "-m", "cwltool"] + new_args,
            stdout=subprocess.PIPE, stderr=subprocess.PIPE)

        stdout, stderr = process.communicate()
        return process.returncode, stdout.decode(), stderr.decode()
Пример #2
0
    def get_main_output(self, new_args):
        process = subprocess.Popen(
            [sys.executable, "-m", "cwltool"] + new_args,
            stdout=subprocess.PIPE, stderr=subprocess.PIPE)

        stdout, stderr = process.communicate()
        return process.returncode, stdout.decode(), stderr.decode()
Пример #3
0
    def get_main_stderr(self, new_args):
        cwltool_base = path.join(path.dirname(path.abspath(__name__)),
                                 "cwltool")

        process = subprocess.Popen([sys.executable, "-m", "cwltool"] +
                                   new_args,
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE)

        stdout, stderr = process.communicate()
        return process.returncode, stderr.decode()
Пример #4
0
def test_env_filtering(factor):
    test_file = "tests/env.cwl"
    commands = factor.split()
    commands.extend([get_data(test_file)])
    error_code, stdout, stderr = get_main_output(commands)

    process = subprocess.Popen(
        [
            "sh",
            "-c",
            r"""getTrueShellExeName() {
  local trueExe nextTarget 2>/dev/null
  trueExe=$(ps -o comm= $$) || return 1
  [ "${trueExe#-}" = "$trueExe" ] || trueExe=${trueExe#-}
  [ "${trueExe#/}" != "$trueExe" ] || trueExe=$([ -n "$ZSH_VERSION" ] && which -p "$trueExe" || which "$trueExe")
  while nextTarget=$(readlink "$trueExe"); do trueExe=$nextTarget; done
  printf '%s\n' "$(basename "$trueExe")"
} ; getTrueShellExeName""",
        ],
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        env=None,
    )
    sh_name, sh_name_err = process.communicate()
    sh_name = sh_name.decode("utf-8").strip()

    assert "completed success" in stderr, (error_code, stdout, stderr)
    assert error_code == 0, (error_code, stdout, stderr)
    if onWindows():
        target = 5
    elif sh_name == "dash":
        target = 4
    else:  # bash adds "SHLVL" and "_" environment variables
        target = 6
    result = json.loads(stdout)["env_count"]
    details = ""
    if result != target:
        _, details, _ = get_main_output(
            ["--quiet", get_data("tests/env2.cwl")])
        print(sh_name)
        print(sh_name_err)
        print(details)
    assert result == target, (error_code, sh_name, sh_name_err, details,
                              stdout, stderr)