Skip to content

Commit

Permalink
coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
mlin committed Feb 27, 2020
1 parent 8d867ce commit f593bc8
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions tests/test_4taskrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,7 @@ def test_plugins(self):
def my_plugin(cfg, logger, task, run_id, run_dir, **recv):
logger = logger.getChild("my_plugin")
logger.critical("hello")
yv = None
try:
xv = recv["inputs"].resolve_binding("x")
xv.value.value += 1
Expand All @@ -932,6 +933,8 @@ def my_plugin(cfg, logger, task, run_id, run_dir, **recv):
raise
finally:
logger.critical("goodbye")
if yv and yv.value.value == 43:
raise RuntimeError("goodbye")
txt = R"""
version 1.0
task inc {
Expand All @@ -947,6 +950,16 @@ def my_plugin(cfg, logger, task, run_id, run_dir, **recv):
outputs = self._test_task(txt, {"x": 1}, _plugins=[my_plugin])
self.assertEqual(outputs["y"], 4)

try:
self._test_task(txt, {"x": 42}, _plugins=[my_plugin])
except RuntimeError as exn:
assert exn.args[0] == "oh no you don't!"

try:
self._test_task(txt, {"x": 40}, _plugins=[my_plugin])
except RuntimeError as exn:
assert exn.args[0] == "goodbye"

txt = R"""
version 1.0
task failer2000 {
Expand All @@ -966,22 +979,6 @@ def my_plugin(cfg, logger, task, run_id, run_dir, **recv):
except WDL.runtime.error.CommandFailed as exn:
self.assertEqual(exn.exit_status, 42)

txt = R"""
version 1.0
task inc {
input {
Int x
}
command {}
output {
Int y = x+1
}
}
"""
try:
self._test_task(txt, {"x": 42}, _plugins=[my_plugin])
except RuntimeError as exn:
assert exn.args[0] == "oh no you don't!"

class TestConfigLoader(unittest.TestCase):
@classmethod
Expand Down

0 comments on commit f593bc8

Please sign in to comment.