Skip to content

Commit 99e454d

Browse files
committed
test.py: make logic for finding scripts clearer
We search for and find non-generated scripts (`.sh`, but not `.gen.sh`), whereas we record all generated scripts, which we then combine to get all scripts.
1 parent 089ee78 commit 99e454d

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

tests/integration/tests/__init__.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ class Test(object):
2626
"check": ["check.sh", "test.sh"]
2727
}
2828

29-
def __init__(self, directory: str, generated_scripts: set[Path]):
30-
self.scripts = {
31-
f.name for f in Path(directory).iterdir() if f.suffix == ".sh" and
32-
(".gen" not in f.suffixes or any(f.samefile(script) for script in generated_scripts))
33-
}
34-
self.dir = directory
35-
self.conf_file = os.path.join(directory, CONF_YML)
36-
self.name = os.path.basename(directory)
29+
def __init__(self, directory: Path, generated_scripts: set[Path]):
30+
# We only want scripts that have been generated by us now,
31+
# but non `*.gen*` scripts we can search for.
32+
non_gen_script_paths = { f for f in directory.iterdir() if f.suffix == ".sh" and ".gen" not in f.suffixes }
33+
script_paths = non_gen_script_paths | generated_scripts
34+
self.scripts = { str(script.relative_to(directory)) for script in script_paths }
35+
self.dir = str(directory)
36+
self.conf_file = str(directory / CONF_YML)
37+
self.name = directory.name
3738

3839
def run_script(self, stage, script, verbose=False, xfail=False) -> bool:
3940
"""
@@ -217,7 +218,7 @@ def run_tests(conf: Config, generated_scripts: set[Path]):
217218
if not conf.ignore_requirements:
218219
check(conf)
219220

220-
tests = [Test(td, generated_scripts) for td in conf.project_dirs]
221+
tests = [Test(Path(td), generated_scripts) for td in conf.project_dirs]
221222

222223
def run(test: Test) -> TestResult:
223224
start = perf_counter()

0 commit comments

Comments
 (0)