Skip to content

Commit

Permalink
[issue1109] Test all individual portfolio configs.
Browse files Browse the repository at this point in the history
  • Loading branch information
jendrikseipp committed Sep 4, 2023
1 parent e6f39a0 commit 2bad7ac
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions driver/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@
"""

import os
from pathlib import Path
import subprocess
import sys
import traceback

import pytest

from .aliases import ALIASES, PORTFOLIOS
from .arguments import EXAMPLES
from .call import check_call
from . import limits
from . import returncodes
from .run_components import get_executable, REL_SEARCH_PATH
from .util import REPO_ROOT_DIR, find_domain_filename


Expand Down Expand Up @@ -59,6 +63,49 @@ def test_portfolios():
run_driver(parameters)


def _get_portfolio_configs(portfolio: Path):
content = portfolio.read_text()
attributes = {}
try:
exec(content, attributes)
except Exception:
traceback.print_exc()
raise SyntaxError(
f"The portfolio {portfolio} could not be loaded.")
if "CONFIGS" not in attributes:
raise ValueError("portfolios must define CONFIGS")
return [config for _, config in attributes["CONFIGS"]]


def _convert_to_standalone_config(config):
replacements = [
("H_COST_TRANSFORM", "no_transform()"),
("S_COST_TYPE", "normal"),
("BOUND", "infinity"),
]
for index, part in enumerate(config):
for before, after in replacements:
part = part.replace(before, after)
config[index] = part
return config


def _run_search(config):
check_call(
"search",
[get_executable("release", REL_SEARCH_PATH)] + list(config),
stdin="output.sas")


def test_portfolio_configs():
all_configs = set()
for portfolio in PORTFOLIOS.values():
configs = _get_portfolio_configs(Path(portfolio))
all_configs |= set(tuple(_convert_to_standalone_config(config)) for config in configs)
for config in all_configs:
_run_search(config)


@pytest.mark.skipif(not limits.can_set_time_limit(), reason="Cannot set time limits on this system")
def test_hard_time_limit():
def preexec_fn():
Expand Down

0 comments on commit 2bad7ac

Please sign in to comment.