From 19003ea51b9ea9f0418d818621f3265b29ceac4c Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 14 May 2018 22:13:42 -0700 Subject: [PATCH] Simplify configuration for PIO Unit Testing --- HISTORY.rst | 2 ++ docs | 2 +- examples | 2 +- platformio/builder/main.py | 1 + platformio/builder/tools/piomisc.py | 7 ++----- platformio/builder/tools/platformio.py | 21 ++++++++------------- platformio/managers/core.py | 2 +- 7 files changed, 16 insertions(+), 21 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index f6c48fdd..c821888e 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -13,6 +13,8 @@ PlatformIO 3.0 - "Recent News" block on "Welcome" page - Direct import of development platform's example +* Simplify configuration for `PIO Unit Testing `__: separate main program from a test build process, drop + requirement for ``#ifdef UNIT_TEST`` guard * Configure a custom path to SVD file using `debug_svd_path `__ option * Custom project `description `_ diff --git a/docs b/docs index b7168a2b..0889b198 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit b7168a2b1af5f6a08d20592d1cda727f6a379469 +Subproject commit 0889b198d3b0e6490aca6bf02b66d2a3e5f0c9c7 diff --git a/examples b/examples index e3b80fb1..41f3396c 160000 --- a/examples +++ b/examples @@ -1 +1 @@ -Subproject commit e3b80fb1fcbd1011fbb814a84d9b364aaadb2853 +Subproject commit 41f3396c5883d54e6cc5603d380400ca46df8876 diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 84fabc65..cdd7d5d1 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -99,6 +99,7 @@ DEFAULT_ENV_OPTIONS = dict( BUILD_DIR=join("$PROJECTBUILD_DIR", "$PIOENV"), BUILDSRC_DIR=join("$BUILD_DIR", "src"), BUILDTEST_DIR=join("$BUILD_DIR", "test"), + LIBPATH=["$BUILD_DIR"], LIBSOURCE_DIRS=[ util.get_projectlib_dir(), util.get_projectlibdeps_dir(), diff --git a/platformio/builder/tools/piomisc.py b/platformio/builder/tools/piomisc.py index bff38d6e..b01ea1a2 100644 --- a/platformio/builder/tools/piomisc.py +++ b/platformio/builder/tools/piomisc.py @@ -295,11 +295,8 @@ def ProcessTest(env): src_filter.append("+<%s%s>" % (env['PIOTEST'], sep)) env.Replace(PIOTEST_SRC_FILTER=src_filter) - return env.CollectBuildFiles( - "$BUILDTEST_DIR", - "$PROJECTTEST_DIR", - "$PIOTEST_SRC_FILTER", - duplicate=False) + return env.CollectBuildFiles("$BUILDTEST_DIR", "$PROJECTTEST_DIR", + "$PIOTEST_SRC_FILTER") def GetExtraScripts(env, scope): diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index bb2dd1c6..9d7f333c 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -30,12 +30,11 @@ SRC_HEADER_EXT = ["h", "hpp"] SRC_C_EXT = ["c", "cc", "cpp"] SRC_BUILD_EXT = SRC_C_EXT + ["S", "spp", "SPP", "sx", "s", "asm", "ASM"] SRC_FILTER_DEFAULT = ["+<*>", "-<.git%s>" % sep, "-" % sep] +SRC_FILTER_PATTERNS_RE = re.compile(r"(\+|\-)<([^>]+)>") def scons_patched_match_splitext(path, suffixes=None): - """ - Patch SCons Builder, append $OBJSUFFIX to the end of each target - """ + """Patch SCons Builder, append $OBJSUFFIX to the end of each target""" tokens = Util.splitext(path) if suffixes and tokens[1] and tokens[1] in suffixes: return (path, tokens[1]) @@ -91,16 +90,14 @@ def BuildProgram(env): # Handle SRC_BUILD_FLAGS env.ProcessFlags(env.get("SRC_BUILD_FLAGS")) - env.Append( - LIBPATH=["$BUILD_DIR"], - PIOBUILDFILES=env.CollectBuildFiles( - "$BUILDSRC_DIR", - "$PROJECTSRC_DIR", - src_filter=env.get("SRC_FILTER"), - duplicate=False)) - if "__test" in COMMAND_LINE_TARGETS: env.Append(PIOBUILDFILES=env.ProcessTest()) + else: + env.Append( + PIOBUILDFILES=env.CollectBuildFiles( + "$BUILDSRC_DIR", + "$PROJECTSRC_DIR", + src_filter=env.get("SRC_FILTER"))) if not env['PIOBUILDFILES'] and not COMMAND_LINE_TARGETS: sys.stderr.write( @@ -197,8 +194,6 @@ def IsFileWithExt(env, file_, ext): # pylint: disable=W0613 def MatchSourceFiles(env, src_dir, src_filter=None): - SRC_FILTER_PATTERNS_RE = re.compile(r"(\+|\-)<([^>]+)>") - def _append_build_item(items, item, src_dir): if env.IsFileWithExt(item, SRC_BUILD_EXT + SRC_HEADER_EXT): items.add(item.replace(src_dir + sep, "")) diff --git a/platformio/managers/core.py b/platformio/managers/core.py index c5fb0084..3aa37fe7 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -23,7 +23,7 @@ from platformio.managers.package import PackageManager CORE_PACKAGES = { "contrib-piohome": ">=0.9.5,<2", "contrib-pysite": ">=0.2.0,<2", - "tool-pioplus": ">=1.3.0,<2", + "tool-pioplus": ">=1.3.1,<2", "tool-unity": "~1.20403.0", "tool-scons": "~2.20501.4" }