twister: fix main script returns and error handling
Propagate errors to the main routine and do not exit early in case of errors. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
91b2cce64e
commit
76d5543c9b
1 changed files with 15 additions and 10 deletions
|
@ -897,7 +897,7 @@ def main():
|
||||||
hwm = HardwareMap(env)
|
hwm = HardwareMap(env)
|
||||||
ret = hwm.discover()
|
ret = hwm.discover()
|
||||||
if ret == 0:
|
if ret == 0:
|
||||||
return
|
return 0
|
||||||
|
|
||||||
env.hwm = hwm
|
env.hwm = hwm
|
||||||
|
|
||||||
|
@ -906,20 +906,20 @@ def main():
|
||||||
tplan.discover()
|
tplan.discover()
|
||||||
except RuntimeError as e:
|
except RuntimeError as e:
|
||||||
logger.error(f"{e}")
|
logger.error(f"{e}")
|
||||||
sys.exit(1)
|
return 1
|
||||||
|
|
||||||
if tplan.report() == 0:
|
if tplan.report() == 0:
|
||||||
return
|
return 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
tplan.load()
|
tplan.load()
|
||||||
except RuntimeError as e:
|
except RuntimeError as e:
|
||||||
logger.error(f"{e}")
|
logger.error(f"{e}")
|
||||||
sys.exit(1)
|
return 1
|
||||||
|
|
||||||
if options.list_tests and options.platform:
|
if options.list_tests and options.platform:
|
||||||
tplan.report_platform_tests(options.platform)
|
tplan.report_platform_tests(options.platform)
|
||||||
return
|
return 0
|
||||||
|
|
||||||
if VERBOSE > 1:
|
if VERBOSE > 1:
|
||||||
# if we are using command line platform filter, no need to list every
|
# if we are using command line platform filter, no need to list every
|
||||||
|
@ -941,14 +941,14 @@ def main():
|
||||||
|
|
||||||
if options.report_excluded:
|
if options.report_excluded:
|
||||||
tplan.report_excluded_tests()
|
tplan.report_excluded_tests()
|
||||||
return
|
return 0
|
||||||
|
|
||||||
report = Reporting(tplan, env)
|
report = Reporting(tplan, env)
|
||||||
report.json_report(os.path.join(options.outdir, "testplan.json"))
|
report.json_report(os.path.join(options.outdir, "testplan.json"))
|
||||||
|
|
||||||
if options.save_tests:
|
if options.save_tests:
|
||||||
report.json_report(options.save_tests)
|
report.json_report(options.save_tests)
|
||||||
return
|
return 0
|
||||||
|
|
||||||
if options.device_testing and not options.build_only:
|
if options.device_testing and not options.build_only:
|
||||||
print("\nDevice testing on:")
|
print("\nDevice testing on:")
|
||||||
|
@ -958,7 +958,7 @@ def main():
|
||||||
if options.dry_run:
|
if options.dry_run:
|
||||||
duration = time.time() - start_time
|
duration = time.time() - start_time
|
||||||
logger.info("Completed in %d seconds" % (duration))
|
logger.info("Completed in %d seconds" % (duration))
|
||||||
return
|
return 0
|
||||||
|
|
||||||
if options.short_build_path:
|
if options.short_build_path:
|
||||||
tplan.create_build_dir_links()
|
tplan.create_build_dir_links()
|
||||||
|
@ -1001,13 +1001,18 @@ def main():
|
||||||
|
|
||||||
logger.info("Run completed")
|
logger.info("Run completed")
|
||||||
if runner.results.failed or runner.results.error or (tplan.warnings and options.warnings_as_errors):
|
if runner.results.failed or runner.results.error or (tplan.warnings and options.warnings_as_errors):
|
||||||
sys.exit(1)
|
return 1
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
ret = 0
|
||||||
try:
|
try:
|
||||||
main()
|
ret = main()
|
||||||
finally:
|
finally:
|
||||||
if (os.name != "nt") and os.isatty(1):
|
if (os.name != "nt") and os.isatty(1):
|
||||||
# (OS is not Windows) and (stdout is interactive)
|
# (OS is not Windows) and (stdout is interactive)
|
||||||
os.system("stty sane")
|
os.system("stty sane")
|
||||||
|
|
||||||
|
sys.exit(ret)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue