Skip to content

Commit

Permalink
Error propagation test.
Browse files Browse the repository at this point in the history
  • Loading branch information
severb committed Feb 12, 2015
1 parent 2361f4b commit eb80fb6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
3 changes: 3 additions & 0 deletions flowy/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ def __call__(self, key, input_data, decision, *args, **kwargs):
result = impl(*iargs, **ikwargs)
except SuspendTask:
decision.flush()
except Exception as e:
logger.exception('Error while running the task:')
decision.fail(e)
else:
if isinstance(result, _restart):
serialize_restart = getattr(
Expand Down
13 changes: 13 additions & 0 deletions flowy/tests/swf_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,19 @@
},
],
},
}, {
'name': 'Dependency',
'version': 1,
'input_args': [5],
'results': {
'inc-0-0': 1,
},
'errors': {
'inc-1-0': 'err!',
},
'expected': {
'fail': 'err!',
},
}, {
'name': 'Parallel',
'version': 1,
Expand Down
9 changes: 7 additions & 2 deletions flowy/tests/test_swf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self):
def fail(self, reason):
if self.result is not None:
return
self.result = {'fail': reason}
self.result = {'fail': str(reason)}

def flush(self):
if self.result is not None:
Expand Down Expand Up @@ -139,12 +139,17 @@ def t(self):
decision = DummyDecision()
results = case.get('results', {})
results = dict((k, str(v)) for k, v in results.items())
order = (
list(case.get('results', {}).keys())
+ list(case.get('errors', {}).keys())
+ list(case.get('timedout', []))
)
execution_history = SWFExecutionHistory(
case.get('running', []),
case.get('timedout', []),
results,
case.get('errors', {}),
list(case.get('results', {}).keys()),
order,
)
worker(key, input_data, decision, execution_history)
decision.assert_equals(case.get('expected'))
Expand Down

0 comments on commit eb80fb6

Please sign in to comment.