diff --git a/HISTORY.rst b/HISTORY.rst index d17de658..ff55d09d 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -28,9 +28,11 @@ PlatformIO Core 6 * **Unit Testing** + - Updated "Getting Started" documentation for `GoogleTest `__ 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 `_) - Do not resolve dependencies from the project "src" folder when the `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 `__ was not handled properly (`issue #4299 `_) - Fixed an issue when testing results were wrong in the verbose mode (`issue #4336 `_) diff --git a/docs b/docs index ad5bd94f..be6e3e87 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit ad5bd94f7ca41235fe183c445bb4680cea1e0f63 +Subproject commit be6e3e87ecdac12d6dc869fcac42b5cd481fa982 diff --git a/examples b/examples index b2657021..7fbb0ec1 160000 --- a/examples +++ b/examples @@ -1 +1 @@ -Subproject commit b26570214771dde4db03f04ff37988eef7effbf8 +Subproject commit 7fbb0ec1532e98af213ffd242d725a8cde1061f8 diff --git a/platformio/test/runners/readers/program.py b/platformio/test/runners/readers/program.py index 82cc6a2a..d80d170d 100644 --- a/platformio/test/runners/readers/program.py +++ b/platformio/test/runners/readers/program.py @@ -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) diff --git a/tests/commands/test_test.py b/tests/commands/test_test.py index 26089500..595d5398 100644 --- a/tests/commands/test_test.py +++ b/tests/commands/test_test.py @@ -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(