From 4a9b94d406b6ba17715f7ac1921081064d0a4c75 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Fri, 16 Apr 2021 11:25:49 +0800 Subject: [PATCH] pass error code back to shell if test fails --- meshtastic/test.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/meshtastic/test.py b/meshtastic/test.py index 1a65e88..34219a8 100644 --- a/meshtastic/test.py +++ b/meshtastic/test.py @@ -4,7 +4,7 @@ from . import SerialInterface, TCPInterface, BROADCAST_NUM from pubsub import pub import time import sys -import threading +import threading, traceback from dotmap import DotMap """The interfaces we are using for our tests""" @@ -167,10 +167,15 @@ def testSimulator(): """ logging.basicConfig(level=logging.DEBUG if False else logging.INFO) logging.info("Connecting to simulator on localhost!") - iface = TCPInterface("localhost") - iface.showInfo() - iface.localNode.showInfo() - iface.localNode.exitSimulator() - iface.close() - logging.info("Integration test successful!") - sys.exit(0) + try: + iface = TCPInterface("localhost") + iface.showInfo() + iface.localNode.showInfo() + iface.localNode.exitSimulator() + iface.close() + logging.info("Integration test successful!") + sys.exit(0) + except: + print("Error while testing simulator:", sys.exc_info()[0]) + traceback.print_exc() + sys.exit(1)