Skip to content

Commit 836e5e3

Browse files
Merge pull request #114 from bridadan/fix_htrun_version_lookup
Fix mbedhtrun --version number
2 parents bb821d5 + 0157a58 commit 836e5e3

File tree

2 files changed

+29
-25
lines changed

2 files changed

+29
-25
lines changed

packages/mbed-host-tests/mbed_host_tests/mbedhtrun.py

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
Author: Przemyslaw Wirkus <[email protected]>
1818
"""
1919

20+
from __future__ import print_function
2021
from multiprocessing import freeze_support
2122
from mbed_os_tools.test import init_host_test_cli_params
2223
from mbed_os_tools.test.host_tests_runner.host_test_default import DefaultTestSelector
24+
from mbed_os_tools.test.host_tests_toolbox.host_functional import handle_send_break_cmd
2325

2426

2527
def main():
@@ -28,18 +30,33 @@ def main():
2830
2. Call default test execution function run() to start test instrumentation
2931
"""
3032
freeze_support()
31-
result = 1
32-
test_selector = DefaultTestSelector(init_host_test_cli_params())
33-
try:
34-
result = test_selector.execute()
35-
except (KeyboardInterrupt, SystemExit):
36-
test_selector.finish()
37-
raise
33+
result = 0
34+
cli_params = init_host_test_cli_params()
35+
36+
if cli_params.version: # --version
37+
import pkg_resources # part of setuptools
38+
version = pkg_resources.require("mbed-host-tests")[0].version
39+
print(version)
40+
elif cli_params.send_break_cmd: # -b with -p PORT (and optional -r RESET_TYPE)
41+
handle_send_break_cmd(
42+
port=cli_params.port,
43+
disk=cli_params.disk,
44+
reset_type=cli_params.forced_reset_type,
45+
baudrate=cli_params.baud_rate,
46+
verbose=cli_params.verbose
47+
)
3848
else:
39-
test_selector.finish()
40-
41-
# Ensure we don't return a negative value
42-
if result < 0 or result > 255:
43-
result = 1
49+
test_selector = DefaultTestSelector(cli_params)
50+
try:
51+
result = test_selector.execute()
52+
# Ensure we don't return a negative value
53+
if result < 0 or result > 255:
54+
result = 1
55+
except (KeyboardInterrupt, SystemExit):
56+
test_selector.finish()
57+
result = 1
58+
raise
59+
else:
60+
test_selector.finish()
4461

4562
return result

src/mbed_os_tools/test/host_tests_runner/host_test_default.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
from ..host_tests_logger import HtrunLogger
3838
from ..host_tests_conn_proxy import conn_process
3939
from ..host_tests_toolbox.host_functional import handle_send_break_cmd
40-
from ... import __version__
4140
if (sys.version_info > (3, 0)):
4241
from queue import Empty as QueueEmpty
4342
else:
@@ -82,18 +81,6 @@ def __init__(self, options):
8281
host_tests_plugins.print_plugin_info()
8382
sys.exit(0)
8483

85-
if options.version: # --version
86-
print(__version__)
87-
sys.exit(0)
88-
89-
if options.send_break_cmd: # -b with -p PORT (and optional -r RESET_TYPE)
90-
handle_send_break_cmd(port=options.port,
91-
disk=options.disk,
92-
reset_type=options.forced_reset_type,
93-
baudrate=options.baud_rate,
94-
verbose=options.verbose)
95-
sys.exit(0)
96-
9784
if options.global_resource_mgr or options.fast_model_connection:
9885
# If Global/Simulator Resource Mgr is working it will handle reset/flashing workflow
9986
# So local plugins are offline

0 commit comments

Comments
 (0)