From 52099616307e8cde256469c7f7d641bc3ae414db Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Fri, 13 Mar 2015 16:10:35 -0700 Subject: [PATCH] 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 --- taskflow/examples/graph_flow.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/taskflow/examples/graph_flow.py b/taskflow/examples/graph_flow.py index 9f28dc71..862db389 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)