Skip to content

Commit

Permalink
Add sinol_undocumented_test_limits
Browse files Browse the repository at this point in the history
  • Loading branch information
MasloMaslane committed Sep 16, 2023
1 parent bdcb96e commit 90d1a30
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/sinol_make/helpers/package_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ class LimitTypes(Enum):
MEMORY_LIMIT = 2


def _get_limit_from_dict(dict: Dict[str, Any], limit_type: LimitTypes, test_id: str, test_group: str, test_path: str):
def _get_limit_from_dict(dict: Dict[str, Any], limit_type: LimitTypes, test_id: str, test_group: str, test_path: str,
allow_test_limit: bool = False):
if limit_type == LimitTypes.TIME_LIMIT:
limit_name = "time_limit"
plural_limit_name = "time_limits"
Expand All @@ -96,7 +97,10 @@ def _get_limit_from_dict(dict: Dict[str, Any], limit_type: LimitTypes, test_id:

if plural_limit_name in dict:
if test_id in dict[plural_limit_name] and test_id != "0":
util.exit_with_error(f'{os.path.basename(test_path)}: Specifying limit for single test is a bad practice and is not supported.')
if allow_test_limit:
return dict[plural_limit_name][test_id]
else:
util.exit_with_error(f'{os.path.basename(test_path)}: Specifying limit for single test is a bad practice and is not supported.')
elif test_group in dict[plural_limit_name]:
return dict[plural_limit_name][test_group]
if limit_name in dict:
Expand All @@ -108,9 +112,11 @@ def _get_limit_from_dict(dict: Dict[str, Any], limit_type: LimitTypes, test_id:
def _get_limit(limit_type: LimitTypes, test_path: str, config: Dict[str, Any], lang: str):
test_id = extract_test_id(test_path)
test_group = str(get_group(test_path))
global_limit = _get_limit_from_dict(config, limit_type, test_id, test_group, test_path)
allow_test_limit = config.get("sinol_undocumented_test_limits", False)
global_limit = _get_limit_from_dict(config, limit_type, test_id, test_group, test_path, allow_test_limit)
override_limits_dict = config.get("override_limits", {}).get(lang, {})
overriden_limit = _get_limit_from_dict(override_limits_dict, limit_type, test_id, test_group, test_path)
overriden_limit = _get_limit_from_dict(override_limits_dict, limit_type, test_id, test_group, test_path,
allow_test_limit)
if overriden_limit is not None:
return overriden_limit
else:
Expand Down

0 comments on commit 90d1a30

Please sign in to comment.