mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-29 17:47:14 +02:00
Do not immediately terminate a testing program when results are received
This commit is contained in:
@ -28,9 +28,11 @@ PlatformIO Core 6
|
||||
|
||||
* **Unit Testing**
|
||||
|
||||
- Updated "Getting Started" documentation for `GoogleTest <https://docs.platformio.org/en/latest/advanced/unit-testing/frameworks/googletest.html>`__ testing and mocking framework
|
||||
- Export |UNITTESTING| flags only to the project build environment (``projenv``, files in "src" folder)
|
||||
- Merged the "building" stage with "uploading" for the embedded target (`issue #4307 <https://github.com/platformio/platformio-core/issues/4307>`_)
|
||||
- Do not resolve dependencies from the project "src" folder when the `test_build_src <https://docs.platformio.org/en/latest//projectconf/section_env_test.html#test-build-src>`__ option is not enabled
|
||||
- Do not immediately terminate a testing program when results are received
|
||||
- Fixed an issue when a custom `pio test --project-config <https://docs.platformio.org/en/latest/core/userguide/cmd_test.html#cmdoption-pio-test-c>`__ was not handled properly (`issue #4299 <https://github.com/platformio/platformio-core/issues/4299>`_)
|
||||
- Fixed an issue when testing results were wrong in the verbose mode (`issue #4336 <https://github.com/platformio/platformio-core/issues/4336>`_)
|
||||
|
||||
|
2
docs
2
docs
Submodule docs updated: ad5bd94f7c...be6e3e87ec
2
examples
2
examples
Submodule examples updated: b265702147...7fbb0ec153
@ -18,14 +18,22 @@ import signal
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
from platformio.compat import IS_WINDOWS, get_filesystem_encoding, get_locale_encoding
|
||||
from platformio.compat import (
|
||||
IS_WINDOWS,
|
||||
aio_get_running_loop,
|
||||
get_filesystem_encoding,
|
||||
get_locale_encoding,
|
||||
)
|
||||
from platformio.test.exception import UnitTestError
|
||||
|
||||
EXITING_TIMEOUT = 5 # seconds
|
||||
|
||||
|
||||
class ProgramProcessProtocol(asyncio.SubprocessProtocol):
|
||||
def __init__(self, test_runner, exit_future):
|
||||
self.test_runner = test_runner
|
||||
self.exit_future = exit_future
|
||||
self._exit_timer = None
|
||||
|
||||
def pipe_data_received(self, _, data):
|
||||
try:
|
||||
@ -34,7 +42,9 @@ class ProgramProcessProtocol(asyncio.SubprocessProtocol):
|
||||
data = data.decode("latin-1")
|
||||
self.test_runner.on_testing_data_output(data)
|
||||
if self.test_runner.test_suite.is_finished():
|
||||
self._stop_testing()
|
||||
self._exit_timer = aio_get_running_loop().call_later(
|
||||
EXITING_TIMEOUT, self._stop_testing
|
||||
)
|
||||
|
||||
def process_exited(self):
|
||||
self._stop_testing()
|
||||
@ -42,12 +52,11 @@ class ProgramProcessProtocol(asyncio.SubprocessProtocol):
|
||||
def _stop_testing(self):
|
||||
if not self.exit_future.done():
|
||||
self.exit_future.set_result(True)
|
||||
if self._exit_timer:
|
||||
self._exit_timer.cancel()
|
||||
|
||||
|
||||
class ProgramTestOutputReader:
|
||||
|
||||
KILLING_TIMEOUT = 5 # seconds
|
||||
|
||||
def __init__(self, test_runner):
|
||||
self.test_runner = test_runner
|
||||
self.aio_loop = (
|
||||
@ -89,7 +98,7 @@ class ProgramTestOutputReader:
|
||||
# wait until subprocess will be killed
|
||||
start = time.time()
|
||||
while (
|
||||
start > (time.time() - self.KILLING_TIMEOUT)
|
||||
start > (time.time() - EXITING_TIMEOUT)
|
||||
and transport.get_returncode() is None
|
||||
):
|
||||
await asyncio.sleep(0.5)
|
||||
|
@ -471,10 +471,6 @@ void unittest_uart_end(){}
|
||||
validate_cliresult(result)
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
sys.platform == "win32" and os.environ.get("GITHUB_ACTIONS") == "true",
|
||||
reason="skip Github Actions on Windows (MinGW issue)",
|
||||
)
|
||||
def test_doctest_framework(clirunner, tmp_path: Path):
|
||||
project_dir = tmp_path / "project"
|
||||
project_dir.mkdir()
|
||||
@ -601,10 +597,6 @@ int main(int argc, char **argv)
|
||||
assert json_report["failure_nums"] == 1
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
sys.platform == "win32" and os.environ.get("GITHUB_ACTIONS") == "true",
|
||||
reason="skip Github Actions on Windows (MinGW issue)",
|
||||
)
|
||||
def test_googletest_framework(clirunner, tmp_path: Path):
|
||||
project_dir = tmp_path / "project"
|
||||
shutil.copytree(
|
||||
|
Reference in New Issue
Block a user