Skip to content

Fix for default test config file #5559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions tools/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,20 @@ class Config(object):
"LOWPAN_BORDER_ROUTER", "LOWPAN_HOST", "LOWPAN_ROUTER", "NANOSTACK_FULL", "THREAD_BORDER_ROUTER", "THREAD_END_DEVICE", "THREAD_ROUTER", "ETHERNET_HOST"
]

@classmethod
def find_app_config(cls, top_level_dirs):
app_config_location = None
for directory in top_level_dirs:
full_path = os.path.join(directory, cls.__mbed_app_config_name)
if os.path.isfile(full_path):
if app_config_location is not None:
raise ConfigException("Duplicate '%s' file in '%s' and '%s'"
% (cls.__mbed_app_config_name,
cls.app_config_location, full_path))
else:
app_config_location = full_path
return app_config_location

def __init__(self, tgt, top_level_dirs=None, app_config=None):
"""Construct a mbed configuration

Expand All @@ -391,16 +405,8 @@ def __init__(self, tgt, top_level_dirs=None, app_config=None):
"""
config_errors = []
self.app_config_location = app_config
if self.app_config_location is None:
for directory in top_level_dirs or []:
full_path = os.path.join(directory, self.__mbed_app_config_name)
if os.path.isfile(full_path):
if self.app_config_location is not None:
raise ConfigException("Duplicate '%s' file in '%s' and '%s'"
% (self.__mbed_app_config_name,
self.app_config_location, full_path))
else:
self.app_config_location = full_path
if self.app_config_location is None and top_level_dirs:
self.app_config_location = self.find_app_config(top_level_dirs)
try:
self.app_config_data = json_file_to_dict(self.app_config_location) \
if self.app_config_location else {}
Expand Down
2 changes: 1 addition & 1 deletion tools/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
if not config:
args_error(parser, "argument --test-config contains invalid path or identifier")
elif not options.app_config:
config = TestConfig.get_default_config(mcu)
config = TestConfig.get_default_config(options.source_dir or ['.'], mcu)
else:
config = options.app_config

Expand Down
7 changes: 5 additions & 2 deletions tools/test_configs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from os.path import dirname, abspath, join
from os.path import dirname, abspath, join, exists

from tools.utils import json_file_to_dict
from tools.targets import TARGET_MAP
from tools.config import Config

CONFIG_DIR = dirname(abspath(__file__))
CONFIG_MAP = json_file_to_dict(join(CONFIG_DIR, "config_paths.json"))
Expand All @@ -28,12 +29,14 @@ def get_config_path(conf_name, target_name):
else:
return None

def get_default_config(target_name):
def get_default_config(source_dir, target_name):
if target_name in TARGET_CONFIGS:
config_name = TARGET_CONFIGS[target_name]['default_test_configuration']
if config_name == "NONE":
return None
return join(CONFIG_DIR, CONFIG_MAP[config_name])
elif Config.find_app_config(source_dir):
return None
elif (target_name in TARGET_MAP and 'LWIP' in TARGET_MAP[target_name].features):
return join(CONFIG_DIR, CONFIG_MAP["ETHERNET"])
else:
Expand Down