Fix PIO Unit Testing issue when `UNIT_TEST` macro was not set in a build environment

This commit is contained in:
Ivan Kravets
2018-07-19 15:27:00 +03:00
parent ff59dcefe0
commit ff3ce2d69e
4 changed files with 19 additions and 11 deletions

View File

@ -4,6 +4,13 @@ Release Notes
PlatformIO 3.0
--------------
3.5.5 (2018-??-??)
~~~~~~~~~~~~~~~~~~
* Fixed `PIO Unit Testing <http://docs.platformio.org/page/plus/unit-testing.html>`__
issue with a shared code between main and test programs when ``UNIT_TEST``
macro was not set in a build environment
3.5.4 (2018-07-03)
~~~~~~~~~~~~~~~~~~

2
docs

Submodule docs updated: 9d8e84d527...a77ecd1295

View File

@ -54,21 +54,20 @@ def _build_project_deps(env):
if project_lib_builder.env.get(key)
})
if "__test" in COMMAND_LINE_TARGETS:
env.ProcessTest()
projenv = env.Clone()
projenv.BuildSources("$BUILDTEST_DIR", "$PROJECTTEST_DIR",
"$PIOTEST_SRC_FILTER")
else:
projenv = env.Clone()
projenv.BuildSources("$BUILDSRC_DIR", "$PROJECTSRC_DIR",
env.get("SRC_FILTER"))
projenv = env.Clone()
# CPPPATH from dependencies
projenv.PrependUnique(CPPPATH=project_lib_builder.env.get("CPPPATH"))
# extra build flags from `platformio.ini`
projenv.ProcessFlags(env.get("SRC_BUILD_FLAGS"))
if "__test" in COMMAND_LINE_TARGETS:
projenv.BuildSources("$BUILDTEST_DIR", "$PROJECTTEST_DIR",
"$PIOTEST_SRC_FILTER")
else:
projenv.BuildSources("$BUILDSRC_DIR", "$PROJECTSRC_DIR",
env.get("SRC_FILTER"))
if not env.get("PIOBUILDFILES") and not COMMAND_LINE_TARGETS:
sys.stderr.write(
"Error: Nothing to build. Please put your source code files "
@ -95,6 +94,8 @@ def BuildProgram(env):
if "__debug" in COMMAND_LINE_TARGETS:
env.ProcessDebug()
if "__test" in COMMAND_LINE_TARGETS:
env.ProcessTest()
# process extra flags from board
if "BOARD" in env and "build.extra_flags" in env.BoardConfig():