mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-31 02:27:13 +02:00
Look for custom "unity_config.h" only in the "test" dir
This commit is contained in:
@ -210,9 +210,7 @@ void unityOutputComplete(void) { unittest_uart_end(); }
|
|||||||
|
|
||||||
def configure_build_env(self, env):
|
def configure_build_env(self, env):
|
||||||
env.Append(CPPDEFINES=["UNITY_INCLUDE_CONFIG_H"])
|
env.Append(CPPDEFINES=["UNITY_INCLUDE_CONFIG_H"])
|
||||||
if self.custom_unity_config_exists(
|
if self.custom_unity_config_exists():
|
||||||
[env.subst(item) for item in (env.get("CPPPATH") or [])]
|
|
||||||
):
|
|
||||||
return env
|
return env
|
||||||
env.Replace(
|
env.Replace(
|
||||||
UNITY_CONFIG_DIR=os.path.join("$BUILD_DIR", "unity_config"),
|
UNITY_CONFIG_DIR=os.path.join("$BUILD_DIR", "unity_config"),
|
||||||
@ -223,11 +221,19 @@ void unityOutputComplete(void) { unittest_uart_end(); }
|
|||||||
env.BuildSources("$BUILD_UNITY_CONFIG_DIR", "$UNITY_CONFIG_DIR")
|
env.BuildSources("$BUILD_UNITY_CONFIG_DIR", "$UNITY_CONFIG_DIR")
|
||||||
return env
|
return env
|
||||||
|
|
||||||
@staticmethod
|
def custom_unity_config_exists(self):
|
||||||
def custom_unity_config_exists(include_dirs):
|
test_dir = self.project_config.get("platformio", "test_dir")
|
||||||
return any(
|
config_fname = "unity_config.h"
|
||||||
os.path.isfile(os.path.join(d, "unity_config.h")) for d in include_dirs
|
if os.path.isfile(os.path.join(test_dir, config_fname)):
|
||||||
|
return True
|
||||||
|
test_name = (
|
||||||
|
self.test_suite.test_name if self.test_suite.test_name != "*" else None
|
||||||
)
|
)
|
||||||
|
while test_name:
|
||||||
|
if os.path.isfile(os.path.join(test_dir, test_name, config_fname)):
|
||||||
|
return True
|
||||||
|
test_name = os.path.dirname(test_name) # parent dir
|
||||||
|
return False
|
||||||
|
|
||||||
def generate_unity_extras(self, dst_dir):
|
def generate_unity_extras(self, dst_dir):
|
||||||
dst_dir = Path(dst_dir)
|
dst_dir = Path(dst_dir)
|
||||||
|
Reference in New Issue
Block a user