Commit 9640d0fe authored by Kirill Smelkov's avatar Kirill Smelkov

Fix status to be always defined

Previously, if --master_url was not provided, the program would crash
with UnboundLocalError for status, since for that case list of tests was
empty. Fix it by moving status initialization higher by one level.

See next patch where we'll add meaning for nxdtest run with no
--master_url set.
parent f9a78f97
...@@ -140,6 +140,15 @@ def main(): ...@@ -140,6 +140,15 @@ def main():
t = tenv.byname[test_result_line.name] t = tenv.byname[test_result_line.name]
tstart = time() tstart = time()
# default status dict
status = {
'test_count': 1,
'error_count': 0,
'failure_count': 0,
'skip_count': 0,
#html_test_result
}
try: try:
# Run t.argv in t.kw['env'] environment. # Run t.argv in t.kw['env'] environment.
# In addition to kw['env'], kw['envadj'] allows users to define # In addition to kw['env'], kw['envadj'] allows users to define
...@@ -155,7 +164,7 @@ def main(): ...@@ -155,7 +164,7 @@ def main():
except: except:
stdout, stderr = '', traceback.format_exc() stdout, stderr = '', traceback.format_exc()
sys.stderr.write(stderr) sys.stderr.write(stderr)
ok = False status['error_count'] += 1
else: else:
# tee >stdout,stderr so we can also see in testnode logs # tee >stdout,stderr so we can also see in testnode logs
# (explicit teeing instead of p.communicate() to be able to see incremental progress) # (explicit teeing instead of p.communicate() to be able to see incremental progress)
...@@ -169,16 +178,9 @@ def main(): ...@@ -169,16 +178,9 @@ def main():
tout.join(); stdout = ''.join(buf_out) tout.join(); stdout = ''.join(buf_out)
terr.join(); stderr = ''.join(buf_err) terr.join(); stderr = ''.join(buf_err)
p.wait() p.wait()
ok = (p.returncode == 0)
if p.returncode != 0:
# default status dict just by exit code status['error_count'] += 1
status = {
'test_count': 1,
'error_count': (0 if ok else 1),
'failure_count': 0,
'skip_count': 0,
#html_test_result
}
# postprocess output, if we can # postprocess output, if we can
if t.summaryf is not None: if t.summaryf is not None:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment