Export a "PIO_UNIT_TESTING" macro to the project source files and dependent libraries in the Unit Testing mode

This commit is contained in:
Ivan Kravets
2022-07-14 14:45:31 +03:00
parent 10ff4ae77a
commit 842679c32b
3 changed files with 6 additions and 1 deletions

View File

@ -16,6 +16,7 @@ PlatformIO Core 6
6.1.2 (2022-07-??)
~~~~~~~~~~~~~~~~~~
* Export a ``PIO_UNIT_TESTING`` macro to the project source files and dependent libraries in the |UNITTESTING| mode
* Improved detection of Windows architecture (`issue #4353 <https://github.com/platformio/platformio-core/issues/4353>`_)
* Fixed a regression bug when `libArchive <https://docs.platformio.org/en/latest/manifests/library-json/fields/build/libarchive.html>`__ option declared in the `library.json <https://docs.platformio.org/en/latest/manifests/library-json/index.html>`__ manifest was ignored (`issue #4351 <https://github.com/platformio/platformio-core/issues/4351>`_)
* Fixed an issue when the `pio pkg publish <https://docs.platformio.org/en/latest/core/userguide/pkg/cmd_publish.html>`__ command didn't work with Python 3.6 (`issue #4352 <https://github.com/platformio/platformio-core/issues/4352>`_)

View File

@ -145,6 +145,10 @@ class LibBuilderBase:
self._circular_deps = []
self._processed_search_files = []
# pass a macro to the projenv + libs
if "test" in env.GetBuildType():
self.env.Append(CPPDEFINES=["PIO_UNIT_TESTING"])
# reset source filter, could be overridden with extra script
self.env["SRC_FILTER"] = ""

View File

@ -23,7 +23,7 @@ from platformio.test.runners.factory import TestRunnerFactory
def ConfigureTestTarget(env):
env.Append(
CPPDEFINES=["UNIT_TEST", "PIO_UNIT_TESTING"],
CPPDEFINES=["UNIT_TEST"], # deprecated, use PIO_UNIT_TESTING
PIOTEST_SRC_FILTER=[f"+<*.{ext}>" for ext in piotool.SRC_BUILD_EXT],
)
env.Prepend(CPPPATH=["$PROJECT_TEST_DIR"])