Minor cleanup in test_examples
- check process exit code instead of stderr emptiness; - in case of failure include stderr and stdout of example into exception message. Change-Id: I3957810c8ac0621bafa4eda85e089071d96c794e
This commit is contained in:
@@ -52,10 +52,18 @@ def run_example(name):
|
|||||||
obj = subprocess.Popen([sys.executable, path],
|
obj = subprocess.Popen([sys.executable, path],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
output = obj.communicate()
|
output = obj.communicate()
|
||||||
if output[1]:
|
stdout = output[0].decode()
|
||||||
raise RuntimeError('Example wrote to stderr:\n%s'
|
stderr = output[1].decode()
|
||||||
% output[1].decode())
|
|
||||||
return output[0].decode()
|
rc = obj.wait()
|
||||||
|
if rc != 0:
|
||||||
|
raise RuntimeError('Example %s failed, return code=%s\n'
|
||||||
|
'<<<Begin captured STDOUT>>>\n%s'
|
||||||
|
'<<<End captured STDOUT>>>\n'
|
||||||
|
'<<<Begin captured STDERR>>>\n%s'
|
||||||
|
'<<<End captured STDERR>>>'
|
||||||
|
% (name, rc, stdout, stderr))
|
||||||
|
return stdout
|
||||||
|
|
||||||
|
|
||||||
def expected_output_path(name):
|
def expected_output_path(name):
|
||||||
@@ -67,7 +75,7 @@ def list_examples():
|
|||||||
for filename in os.listdir(examples_dir):
|
for filename in os.listdir(examples_dir):
|
||||||
name, ext = os.path.splitext(filename)
|
name, ext = os.path.splitext(filename)
|
||||||
if ext == ".py" and 'utils' not in name.lower():
|
if ext == ".py" and 'utils' not in name.lower():
|
||||||
yield filename[:-len(ext)]
|
yield name
|
||||||
|
|
||||||
|
|
||||||
class ExamplesTestCase(taskflow.test.TestCase):
|
class ExamplesTestCase(taskflow.test.TestCase):
|
||||||
|
|||||||
Reference in New Issue
Block a user