Tests: Add ability to take several input files in one test
Change-Id: I50a495ec448cf1b312d4d86a3dee08773c6debc2
This commit is contained in:
parent
af9e394c8e
commit
d9c10ec725
@ -18,6 +18,7 @@ from jenkins_jobs.modules import project_multibranch
|
||||
from jenkins_jobs.modules import project_multijob
|
||||
from jenkins_jobs.registry import ModuleRegistry
|
||||
from jenkins_jobs.xml_config import XmlJob, XmlJobGenerator, XmlViewGenerator
|
||||
from jenkins_jobs import utils
|
||||
|
||||
from jenkins_jobs.roots import Roots
|
||||
from jenkins_jobs.loader import load_files
|
||||
@ -127,7 +128,13 @@ def check_folders(scenario, job_xml_list):
|
||||
return "/".join(dirs)
|
||||
|
||||
def path_parent(path):
|
||||
dir = str(path.relative_to(root_dir).parent)
|
||||
if scenario.in_path.is_dir():
|
||||
# In directory tests, output file directory does not
|
||||
# indicate expected job folder.
|
||||
base_dir = scenario.in_path
|
||||
else:
|
||||
base_dir = root_dir
|
||||
dir = str(path.relative_to(base_dir).parent)
|
||||
if dir == ".":
|
||||
return ""
|
||||
else:
|
||||
@ -173,7 +180,11 @@ def check_parser(jjb_config, registry):
|
||||
def check_job(scenario, expected_output, jjb_config, registry):
|
||||
def check():
|
||||
roots = Roots(jjb_config)
|
||||
load_files(jjb_config, roots, [scenario.in_path])
|
||||
if jjb_config.recursive:
|
||||
path_list = [Path(p) for p in utils.recurse_path(str(scenario.in_path))]
|
||||
else:
|
||||
path_list = [scenario.in_path]
|
||||
load_files(jjb_config, roots, path_list)
|
||||
registry.set_macros(roots.macros)
|
||||
job_data_list = roots.generate_jobs()
|
||||
registry.amend_job_dicts(job_data_list)
|
||||
|
@ -26,9 +26,26 @@ Scenario = namedtuple(
|
||||
|
||||
|
||||
def scenario_list(fixtures_dir, in_ext=".yaml", out_ext=".xml"):
|
||||
compound_dirs = set()
|
||||
if out_ext == ".xml":
|
||||
for path in fixtures_dir.rglob("expected-output.xml"):
|
||||
dir = path.parent
|
||||
compound_dirs.add(dir)
|
||||
yield Scenario(
|
||||
name=dir.stem,
|
||||
in_path=dir,
|
||||
out_paths=[path],
|
||||
error_path=dir / "expected.error",
|
||||
# When config file is missing it will still be passed and not None,
|
||||
# so JJBConfig will prefer it over system and user configs.
|
||||
config_path=dir / "test.conf",
|
||||
plugins_info_path=dir / "test.plugins_info.yaml",
|
||||
)
|
||||
for path in fixtures_dir.rglob(f"*{in_ext}"):
|
||||
if path.name.endswith("plugins_info.yaml"):
|
||||
continue
|
||||
if any(d in path.parents for d in compound_dirs):
|
||||
continue
|
||||
out_path = path.with_suffix(out_ext)
|
||||
out_path_list = list(fixtures_dir.rglob(out_path.name))
|
||||
yield Scenario(
|
||||
|
Loading…
Reference in New Issue
Block a user