Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@pytest.mark.skipif(onWindows(), reason="udocker is Linux/macOS only") # type: ignore
@pytest.mark.parametrize("factor", test_factors) # type: ignore
def test_bad_userspace_runtime(factor: str) -> None:
test_file = "tests/wf/wc-tool.cwl"
job_file = "tests/wf/wc-job.json"
commands = factor.split()
commands.extend(
[
"--user-space-docker-cmd=quaquioN",
"--default-container=debian",
get_data(test_file),
get_data(job_file),
]
)
error_code, stdout, stderr = get_main_output(commands)
assert "or quaquioN is missing or broken" in stderr, stderr
assert error_code == 1
def test_argparse(name, script_contents, params, tmpdir):
script = None
try:
script = NamedTemporaryFile(mode="w", delete=False)
script.write(script_contents)
script.close()
my_params = ["--outdir", str(tmpdir)]
my_params.extend(params(script.name))
assert main(my_params) == 0, name
except SystemExit as err:
assert err.code == 0, name
finally:
if script and script.name and os.path.exists(script.name):
os.unlink(script.name)
def test_require_prefix_networkaccess() -> None:
assert main(["--enable-ext", get_data("tests/wf/networkaccess.cwl")]) == 0
assert main([get_data("tests/wf/networkaccess.cwl")]) != 0
assert main(["--enable-ext", get_data("tests/wf/networkaccess-fail.cwl")]) != 0
"file://{cwl_posix_path}#reverse_sort" -> "file://{cwl_posix_path}#sorted";
}}
""".format(cwl_posix_path=cwl_posix_path))[0]
stdout = StringIO()
assert main(["--print-dot", cwl_path], stdout=stdout) == 0
computed_dot = pydot.graph_from_dot_data(stdout.getvalue())[0]
computed_edges = sorted(
[(urlparse(source).fragment, urlparse(target).fragment) for source, target in computed_dot.obj_dict['edges']])
expected_edges = sorted(
[(urlparse(source).fragment, urlparse(target).fragment) for source, target in expected_dot.obj_dict['edges']])
assert computed_edges == expected_edges
# print CommandLineTool
cwl_path = get_data("tests/wf/echo.cwl")
stdout = StringIO()
assert main(["--debug", "--print-dot", cwl_path], stdout=stdout) == 1
def test_input_deps() -> None:
stream = StringIO()
main(
[
"--print-input-deps",
get_data("tests/wf/count-lines1-wf.cwl"),
get_data("tests/wf/wc-job.json"),
],
stdout=stream,
)
expected = {
"class": "File",
"location": "wc-job.json",
"format": CWL_IANA,
"secondaryFiles": [
{
"class": "File",
"location": "whale.txt",
def test_directory_dest2():
with temp_dir("out") as out_dir:
assert main(["--enable-ext", "--outdir="+out_dir, get_data('tests/destination/directory-dest2.cwl')]) == 0
assert os.path.isfile(os.path.join(out_dir, "bar/baz/foo"))
def test_target_packed() -> None:
"""Test --target option with packed workflow schema."""
test_file = "tests/wf/scatter-wf4.json"
exit_code = main(
["--target", "out", get_data(test_file), "--inp1", "INP1", "--inp2", "INP2"]
)
assert exit_code == 0
def test_dont_require_inputs():
if sys.version_info[0] < 3:
stream = BytesIO()
else:
stream = StringIO()
script = None
try:
script = NamedTemporaryFile(mode="w", delete=False)
script.write(script_a)
script.close()
assert (
main(
argsl=["--debug", script.name, "--input", script.name],
executor=NoopJobExecutor(),
stdout=stream,
)
== 0
)
assert (
main(
argsl=["--debug", script.name],
executor=NoopJobExecutor(),
stdout=stream,
)
== 2
)
assert (
main(
def test_overrides_fails(parameters: List[str], expected_error: str) -> None:
sio = StringIO()
assert main(parameters, stderr=sio) == 1
stderr = sio.getvalue()
assert expected_error in stderr, stderr
[ "${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_b, sh_name_err = process.communicate()
sh_name = sh_name_b.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)