Skip to content

Commit

Permalink
Resolved an issue where native tests would fail if a custom program n…
Browse files Browse the repository at this point in the history
…ame was specified // Resolve #4546
  • Loading branch information
ivankravets committed Apr 15, 2023
1 parent 66fe556 commit 0d9ee75
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ PlatformIO Core 6
* Resolved an issue where the `build_cache_dir <https://docs.platformio.org/en/latest/projectconf/sections/platformio/options/directory/build_cache_dir.html>`__ setting was not being recognized consistently across multiple environments (`issue #4574 <https://github.com/platformio/platformio-core/issues/4574>`_)
* Fixed an issue where organization details could not be updated using the `pio org update <https://docs.platformio.org/en/latest/core/userguide/org/cmd_update.html>`__ command
* Resolved an issue where the incorrect debugging environment was generated for VSCode in "Auto" mode (`issue #4597 <https://github.com/platformio/platformio-core/issues/4597>`_)
* Resolved an issue where native tests would fail if a custom program name was specified (`issue #4546 <https://github.com/platformio/platformio-core/issues/4546>`_)

6.1.6 (2023-01-23)
~~~~~~~~~~~~~~~~~~
Expand Down
8 changes: 4 additions & 4 deletions platformio/test/runners/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from platformio.platform.factory import PlatformFactory
from platformio.test.exception import UnitTestSuiteError
from platformio.test.result import TestCase, TestStatus
from platformio.test.runners.readers.program import ProgramTestOutputReader
from platformio.test.runners.readers.native import NativeTestOutputReader
from platformio.test.runners.readers.serial import SerialTestOutputReader

CTX_META_TEST_IS_RUNNING = __name__ + ".test_running"
Expand Down Expand Up @@ -160,16 +160,16 @@ def stage_testing(self):
return None
click.secho("Testing...", bold=True)
test_port = self.get_test_port()
program_conds = [
native_conds = [
not self.platform.is_embedded()
and (not test_port or "://" not in test_port),
self.project_config.get(
f"env:{self.test_suite.env_name}", "test_testing_command"
),
]
reader = (
ProgramTestOutputReader(self)
if any(program_conds)
NativeTestOutputReader(self)
if any(native_conds)
else SerialTestOutputReader(self)
)
return reader.begin()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
get_filesystem_encoding,
get_locale_encoding,
)
from platformio.project.helpers import load_build_metadata
from platformio.test.exception import UnitTestError

EXITING_TIMEOUT = 5 # seconds
Expand Down Expand Up @@ -56,7 +57,7 @@ def _stop_testing(self):
self._exit_timer.cancel()


class ProgramTestOutputReader:
class NativeTestOutputReader:
def __init__(self, test_runner):
self.test_runner = test_runner
self.aio_loop = (
Expand All @@ -78,6 +79,13 @@ def get_testing_command(self):
"program.exe" if IS_WINDOWS else "program",
)
]
# if user changed PROGNAME
if not os.path.exists(cmd[0]):
build_data = load_build_metadata(
os.getcwd(), self.test_runner.test_suite.env_name, cache=True
)
if build_data:
cmd[0] = build_data["prog_path"]
if self.test_runner.options.program_args:
cmd.extend(self.test_runner.options.program_args)
return cmd
Expand Down

0 comments on commit 0d9ee75

Please sign in to comment.