Skip to content

Commit 20f3a57

Browse files
committed
more flexibility in some tests
1 parent 59f1675 commit 20f3a57

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

build-cwltool-docker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ docker run -it -v /var/run/docker.sock:/var/run/docker.sock \
77
-v /tmp:/tmp \
88
-v "$PWD":/tmp/cwltool \
99
quay.io/commonwl/cwltool_module /bin/sh -c \
10-
"apk add gcc bash && pip install -r/tmp/cwltool/test-requirements.txt ; pytest -k 'not test_bioconda and not test_double_overwrite and not test_env_filtering' -n auto --dist=loadfile --pyargs cwltool"
10+
"apk add gcc bash && pip install -r/tmp/cwltool/test-requirements.txt ; pytest -k 'not test_bioconda and not test_double_overwrite and not test_env_filtering' -n auto -v -rs --pyargs cwltool"
1111

1212
version=$(git describe --tags)
1313
if echo "$version" | grep -vq '\-' >& /dev/null ; then

tests/test_examples.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
import logging
33
import os
44
import re
5+
import shutil
56
import stat
67
import subprocess
78
import sys
8-
import shutil
99
from io import StringIO
1010
from pathlib import Path
1111
from typing import Any, Dict, List, Union, cast
@@ -1066,6 +1066,7 @@ def test_js_console_cmd_line_tool(factor: str) -> None:
10661066
)
10671067
error_code, _, stderr = get_main_output(commands)
10681068

1069+
stderr = re.sub(r"\s\s+", " ", stderr)
10691070
assert "[log] Log message" in stderr
10701071
assert "[err] Error message" in stderr
10711072

@@ -1079,6 +1080,7 @@ def test_no_js_console(factor: str) -> None:
10791080
commands.extend(["--no-container", get_data("tests/wf/" + test_file)])
10801081
_, _, stderr = get_main_output(commands)
10811082

1083+
stderr = re.sub(r"\s\s+", " ", stderr)
10821084
assert "[log] Log message" not in stderr
10831085
assert "[err] Error message" not in stderr
10841086

@@ -1094,6 +1096,7 @@ def test_cid_file_dir(tmp_path: Path, factor: str) -> None:
10941096
["--cidfile-dir", str(tmp_path), get_data("tests/wf/" + test_file)]
10951097
)
10961098
error_code, stdout, stderr = get_main_output(commands)
1099+
stderr = re.sub(r"\s\s+", " ", stderr)
10971100
assert "completed success" in stderr
10981101
assert error_code == 0
10991102
cidfiles_count = sum(1 for _ in tmp_path.glob("**/*"))
@@ -1112,6 +1115,7 @@ def test_cid_file_dir_arg_is_file_instead_of_dir(tmp_path: Path, factor: str) ->
11121115
["--cidfile-dir", str(bad_cidfile_dir), get_data("tests/wf/" + test_file)]
11131116
)
11141117
error_code, _, stderr = get_main_output(commands)
1118+
stderr = re.sub(r"\s\s+", " ", stderr)
11151119
assert "is not a directory, please check it first" in stderr, stderr
11161120
assert error_code == 2 or error_code == 1, stderr
11171121

@@ -1132,6 +1136,7 @@ def test_cid_file_non_existing_dir(tmp_path: Path, factor: str) -> None:
11321136
]
11331137
)
11341138
error_code, _, stderr = get_main_output(commands)
1139+
stderr = re.sub(r"\s\s+", " ", stderr)
11351140
assert "directory doesn't exist, please create it first" in stderr, stderr
11361141
assert error_code == 2 or error_code == 1, stderr
11371142

@@ -1155,6 +1160,7 @@ def test_cid_file_w_prefix(tmp_path: Path, factor: str) -> None:
11551160
finally:
11561161
listing = tmp_path.iterdir()
11571162
cidfiles_count = sum(1 for _ in tmp_path.glob("**/pytestcid*"))
1163+
stderr = re.sub(r"\s\s+", " ", stderr)
11581164
assert "completed success" in stderr
11591165
assert error_code == 0
11601166
assert cidfiles_count == 2, f"{list(listing)}/n{stderr}"
@@ -1180,6 +1186,7 @@ def test_secondary_files_v1_1(factor: str) -> None:
11801186
# 664 in octal, '-rw-rw-r--'
11811187
assert stat.S_IMODE(os.stat("lsout").st_mode) == 436
11821188
os.umask(old_umask) # revert back to original umask
1189+
stderr = re.sub(r"\s\s+", " ", stderr)
11831190
assert "completed success" in stderr
11841191
assert error_code == 0
11851192

@@ -1222,6 +1229,7 @@ def test_secondary_files_v1_0(tmp_path: Path, factor: str) -> None:
12221229
]
12231230
)
12241231
error_code, _, stderr = get_main_output(commands)
1232+
stderr = re.sub(r"\s\s+", " ", stderr)
12251233
assert "completed success" in stderr
12261234
assert error_code == 0
12271235

@@ -1246,6 +1254,7 @@ def test_wf_without_container(tmp_path: Path, factor: str) -> None:
12461254
)
12471255
error_code, _, stderr = get_main_output(commands)
12481256

1257+
stderr = re.sub(r"\s\s+", " ", stderr)
12491258
assert "completed success" in stderr
12501259
assert error_code == 0
12511260

@@ -1260,13 +1269,15 @@ def test_issue_740_fixed(tmp_path: Path, factor: str) -> None:
12601269
commands.extend(["--cachedir", cache_dir, get_data("tests/wf/" + test_file)])
12611270
error_code, _, stderr = get_main_output(commands)
12621271

1272+
stderr = re.sub(r"\s\s+", " ", stderr)
12631273
assert "completed success" in stderr
12641274
assert error_code == 0
12651275

12661276
commands = factor.split()
12671277
commands.extend(["--cachedir", cache_dir, get_data("tests/wf/" + test_file)])
12681278
error_code, _, stderr = get_main_output(commands)
12691279

1280+
stderr = re.sub(r"\s\s+", " ", stderr)
12701281
assert "Output of job will be cached in" not in stderr
12711282
assert error_code == 0, stderr
12721283

@@ -1355,6 +1366,7 @@ def test_no_compute_chcksum(tmp_path: Path, factor: str) -> None:
13551366
]
13561367
)
13571368
error_code, stdout, stderr = get_main_output(commands)
1369+
stderr = re.sub(r"\s\s+", " ", stderr)
13581370
assert "completed success" in stderr
13591371
assert error_code == 0
13601372
assert "checksum" not in stdout
@@ -1374,6 +1386,7 @@ def test_bad_userspace_runtime(factor: str) -> None:
13741386
]
13751387
)
13761388
error_code, stdout, stderr = get_main_output(commands)
1389+
stderr = re.sub(r"\s\s+", " ", stderr)
13771390
assert "or quaquioN is missing or broken" in stderr, stderr
13781391
assert error_code == 1
13791392

@@ -1384,6 +1397,7 @@ def test_bad_basecommand(factor: str) -> None:
13841397
commands = factor.split()
13851398
commands.extend([get_data(test_file)])
13861399
error_code, stdout, stderr = get_main_output(commands)
1400+
stderr = re.sub(r"\s\s+", " ", stderr)
13871401
assert "'neenooGo' not found" in stderr, stderr
13881402
assert error_code == 1
13891403

@@ -1406,6 +1420,7 @@ def test_v1_0_position_expression(factor: str) -> None:
14061420
commands = factor.split()
14071421
commands.extend(["--debug", get_data(test_file), get_data(test_job)])
14081422
error_code, stdout, stderr = get_main_output(commands)
1423+
stderr = re.sub(r"\s\s+", " ", stderr)
14091424
assert "is not int" in stderr, stderr
14101425
assert error_code == 1
14111426

@@ -1430,6 +1445,7 @@ def test_optional_numeric_output_0(factor: str) -> None:
14301445
commands.extend([get_data(test_file)])
14311446
error_code, stdout, stderr = get_main_output(commands)
14321447

1448+
stderr = re.sub(r"\s\s+", " ", stderr)
14331449
assert "completed success" in stderr
14341450
assert error_code == 0
14351451
assert json.loads(stdout)["out"] == 0
@@ -1463,6 +1479,7 @@ def test_env_filtering(factor: str) -> None:
14631479
assert sh_name_b
14641480
sh_name = sh_name_b.decode("utf-8").strip()
14651481

1482+
stderr = re.sub(r"\s\s+", " ", stderr)
14661483
assert "completed success" in stderr, (error_code, stdout, stderr)
14671484
assert error_code == 0, (error_code, stdout, stderr)
14681485
if sh_name == "dash":
@@ -1484,6 +1501,7 @@ def test_v1_0_arg_empty_prefix_separate_false() -> None:
14841501
error_code, stdout, stderr = get_main_output(
14851502
["--debug", get_data(test_file), "--echo"]
14861503
)
1504+
stderr = re.sub(r"\s\s+", " ", stderr)
14871505
assert "completed success" in stderr
14881506
assert error_code == 0
14891507

@@ -1515,7 +1533,7 @@ def test_malformed_hints() -> None:
15151533
factory = cwltool.factory.Factory()
15161534
with pytest.raises(
15171535
ValidationException,
1518-
match=r".*wc-tool-bad-hints\.cwl:6:1: If 'hints' is\s*present\s*then\s*it\s*must\s*be\s*a\s*list.*",
1536+
match=r".*wc-tool-bad-hints\.cwl:6:1:\s*If\s*'hints'\s*is\s*present\s*then\s*it\s*must\s*be\s*a\s*list.*",
15191537
):
15201538
factory.make(get_data("tests/wc-tool-bad-hints.cwl"))
15211539

tests/test_path_checks.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import pytest
21
import urllib.parse
3-
42
from pathlib import Path
53
from typing import cast
4+
5+
import pytest
66
from ruamel.yaml.comments import CommentedMap
77
from schema_salad.sourceline import cmap
88

9-
from cwltool.main import main
109
from cwltool.command_line_tool import CommandLineTool
1110
from cwltool.context import LoadingContext, RuntimeContext
11+
from cwltool.main import main
1212
from cwltool.update import INTERNAL_VERSION
1313
from cwltool.utils import CWLObjectType
14-
from .util import needs_docker
1514

15+
from .util import needs_docker
1616

1717
script = """
1818
#!/usr/bin/env cwl-runner

0 commit comments

Comments
 (0)