diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2015-03-13 16:10:35 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2015-03-13 16:14:34 -0700 |
commit | 52099616307e8cde256469c7f7d641bc3ae414db (patch) | |
tree | 3aa1ca7e3836d20a79f8d89aa4a4653666b437f0 /taskflow/examples | |
parent | dbb71b8471c459b4631da7a40ed5987b28ec2ab5 (diff) | |
download | taskflow-52099616307e8cde256469c7f7d641bc3ae414db.tar.gz |
Have this example exit non-zero if incorrect results
When this examples engine does not produce the expected
results have it exit with a non-zero error code so that
the users knows (and so that the example testing system
fails when this happens).
Change-Id: I8c3b80a7dc1c7ef47d7804526346883b24caabc4
Diffstat (limited to 'taskflow/examples')
-rw-r--r-- | taskflow/examples/graph_flow.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/taskflow/examples/graph_flow.py b/taskflow/examples/graph_flow.py index 9f28dc7..862db38 100644 --- a/taskflow/examples/graph_flow.py +++ b/taskflow/examples/graph_flow.py @@ -80,12 +80,37 @@ store = { "y5": 9, } +# This is the expected values that should be created. +unexpected = 0 +expected = [ + ('x1', 4), + ('x2', 12), + ('x3', 16), + ('x4', 21), + ('x5', 20), + ('x6', 41), + ('x7', 82), +] + result = taskflow.engines.run( flow, engine='serial', store=store) print("Single threaded engine result %s" % result) +for (name, value) in expected: + actual = result.get(name) + if actual != value: + sys.stderr.write("%s != %s\n" % (actual, value)) + unexpected += 1 result = taskflow.engines.run( flow, engine='parallel', store=store) print("Multi threaded engine result %s" % result) +for (name, value) in expected: + actual = result.get(name) + if actual != value: + sys.stderr.write("%s != %s\n" % (actual, value)) + unexpected += 1 + +if unexpected: + sys.exit(1) |