Skip to content

Commit a7fb17f

Browse files
author
Peter Amstutz
committed
Merge branch 'cwltest', removes --conformance-test type tests, only support actual execution tests.
Conflicts: cwltool/cwltest.py
2 parents 5fe90dc + e84b359 commit a7fb17f

File tree

1 file changed

+26
-51
lines changed

1 file changed

+26
-51
lines changed

cwltool/cwltest.py

Lines changed: 26 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def compare(a, b): # type: (Any, Any) -> bool
5151
return True
5252
else:
5353
if a != b:
54-
raise CompareFail(u"%s != %s" % (a, b))
54+
raise CompareFail(u"%s != %s" % (json.dumps(a), json.dumps(b)))
5555
else:
5656
return True
5757
except Exception as e:
@@ -62,35 +62,21 @@ def run_test(args, i, t): # type: (argparse.Namespace, Any, Dict[str,str]) -> i
6262
out = {} # type: Dict[str,Any]
6363
outdir = None
6464
try:
65-
if "output" in t:
66-
test_command = [args.tool]
67-
# Add prefixes if running on MacOSX so that boot2docker writes to /Users
68-
if 'darwin' in sys.platform:
69-
outdir = tempfile.mkdtemp(prefix=os.path.abspath(os.path.curdir))
70-
test_command.extend(["--tmp-outdir-prefix={}".format(outdir), "--tmpdir-prefix={}".format(outdir)])
71-
else:
72-
outdir = tempfile.mkdtemp()
73-
test_command.extend(["--outdir={}".format(outdir),
74-
"--quiet",
75-
t["tool"]])
76-
if t["job"] != None:
77-
test_command.extend([t["job"]])
78-
outstr = subprocess.check_output(test_command)
79-
out = {"output": json.loads(outstr)}
65+
test_command = [args.tool]
66+
# Add prefixes if running on MacOSX so that boot2docker writes to /Users
67+
if 'darwin' in sys.platform:
68+
outdir = tempfile.mkdtemp(prefix=os.path.abspath(os.path.curdir))
69+
test_command.extend(["--tmp-outdir-prefix={}".format(outdir), "--tmpdir-prefix={}".format(outdir)])
8070
else:
81-
test_command = [args.tool,
82-
"--conformance-test",
83-
"--basedir=" + args.basedir,
84-
"--no-container",
85-
"--quiet",
86-
t["tool"]]
87-
if t["job"] != None:
88-
test_command.extend([t["job"]])
89-
90-
outstr = subprocess.check_output(test_command)
91-
out = yaml.load(outstr)
92-
if not isinstance(out, dict):
93-
raise ValueError("Non-dict value parsed from output string.")
71+
outdir = tempfile.mkdtemp()
72+
test_command.extend(["--outdir={}".format(outdir),
73+
"--quiet",
74+
t["tool"]])
75+
if t.get("job"):
76+
test_command.append(t["job"])
77+
78+
outstr = subprocess.check_output(test_command)
79+
out = json.loads(outstr)
9480
except ValueError as v:
9581
_logger.error(str(v))
9682
_logger.error(outstr)
@@ -107,29 +93,18 @@ def run_test(args, i, t): # type: (argparse.Namespace, Any, Dict[str,str]) -> i
10793
_logger.error(outstr)
10894
_logger.error(u"Parse error %s", str(e))
10995

110-
# pwd = os.path.abspath(os.path.dirname(t["job"]))
111-
# t["args"] = map(lambda x: x.replace("$PWD", pwd), t["args"])
112-
# if "stdin" in t:
113-
# t["stdin"] = t["stdin"].replace("$PWD", pwd)
114-
11596
failed = False
116-
if "output" in t:
117-
checkkeys = ["output"]
118-
else:
119-
checkkeys = ["args", "stdin", "stderr", "stdout", "createfiles"]
120-
121-
for key in checkkeys:
122-
try:
123-
if key in t and key in out:
124-
compare(t.get(key), out.get(key))
125-
except CompareFail as ex:
126-
_logger.warn(u"""Test failed: %s""", " ".join([pipes.quote(tc) for tc in test_command]))
127-
_logger.warn(t.get("doc"))
128-
_logger.warn(u"%s expected %s\n got %s", key,
129-
json.dumps(t.get(key), indent=4, sort_keys=True),
130-
json.dumps(out.get(key), indent=4, sort_keys=True))
131-
_logger.warn(u"Compare failure %s", ex)
132-
failed = True
97+
98+
try:
99+
compare(t.get("output"), out)
100+
except CompareFail as ex:
101+
_logger.warn(u"""Test failed: %s""", " ".join([pipes.quote(tc) for tc in test_command]))
102+
_logger.warn(t.get("doc"))
103+
_logger.warn(u"expected output object %s\n got %s",
104+
json.dumps(t.get("output"), indent=4, sort_keys=True),
105+
json.dumps(out, indent=4, sort_keys=True))
106+
_logger.warn(u"Compare failure %s", ex)
107+
failed = True
133108

134109
if outdir:
135110
shutil.rmtree(outdir, True) # type: ignore

0 commit comments

Comments
 (0)