mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 10:07:14 +02:00
Ensure that a serial port is ready before running unit tests on a remote target // Resolve #3742
This commit is contained in:
@ -27,6 +27,10 @@ PlatformIO Core 5
|
|||||||
* `Cppcheck <https://docs.platformio.org/page/plus/check-tools/cppcheck.html>`__ v2.4.1 with new checks and MISRA improvements
|
* `Cppcheck <https://docs.platformio.org/page/plus/check-tools/cppcheck.html>`__ v2.4.1 with new checks and MISRA improvements
|
||||||
* `PVS-Studio <https://docs.platformio.org/page/plus/check-tools/pvs-studio.html>`__ v7.12 with new diagnostics and extended capabilities for security and safety standards
|
* `PVS-Studio <https://docs.platformio.org/page/plus/check-tools/pvs-studio.html>`__ v7.12 with new diagnostics and extended capabilities for security and safety standards
|
||||||
|
|
||||||
|
* **Miscellaneous**
|
||||||
|
|
||||||
|
- Ensure that a serial port is ready before running unit tests on a remote target (`issue #3742 <https://github.com/platformio/platformio-core/issues/3742>`_)
|
||||||
|
|
||||||
5.1.1 (2021-03-17)
|
5.1.1 (2021-03-17)
|
||||||
~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
@ -117,13 +117,10 @@ class EmbeddedTestProcessor(TestProcessorBase):
|
|||||||
port = item["port"]
|
port = item["port"]
|
||||||
for hwid in board_hwids:
|
for hwid in board_hwids:
|
||||||
hwid_str = ("%s:%s" % (hwid[0], hwid[1])).replace("0x", "")
|
hwid_str = ("%s:%s" % (hwid[0], hwid[1])).replace("0x", "")
|
||||||
if hwid_str in item["hwid"]:
|
if hwid_str in item["hwid"] and self.is_serial_port_ready(port):
|
||||||
return port
|
return port
|
||||||
|
|
||||||
# check if port is already configured
|
if port and not self.is_serial_port_ready(port):
|
||||||
try:
|
|
||||||
serial.Serial(port, timeout=self.SERIAL_TIMEOUT).close()
|
|
||||||
except serial.SerialException:
|
|
||||||
port = None
|
port = None
|
||||||
|
|
||||||
if not port:
|
if not port:
|
||||||
@ -136,3 +133,18 @@ class EmbeddedTestProcessor(TestProcessorBase):
|
|||||||
"global `--test-port` option."
|
"global `--test-port` option."
|
||||||
)
|
)
|
||||||
return port
|
return port
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def is_serial_port_ready(port, timeout=3):
|
||||||
|
if not port:
|
||||||
|
return False
|
||||||
|
elapsed = 0
|
||||||
|
while elapsed < timeout:
|
||||||
|
try:
|
||||||
|
serial.Serial(port, timeout=1).close()
|
||||||
|
return True
|
||||||
|
except: # pylint: disable=bare-except
|
||||||
|
pass
|
||||||
|
sleep(1)
|
||||||
|
elapsed += 1
|
||||||
|
return False
|
||||||
|
Reference in New Issue
Block a user