diff options
author | Daniel Mensinger <daniel@mensinger-ka.de> | 2020-08-25 19:27:10 +0200 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2020-08-27 00:08:57 +0000 |
commit | 17439fa3e890266efeb0af1880640427be71a2ab (patch) | |
tree | c2bf09e7b76571e24b921766100732b1c8a0ada5 /run_project_tests.py | |
parent | fdae213a4960f530e6a2e48d78788d6c50aaedcf (diff) | |
download | meson-17439fa3e890266efeb0af1880640427be71a2ab.zip meson-17439fa3e890266efeb0af1880640427be71a2ab.tar.gz meson-17439fa3e890266efeb0af1880640427be71a2ab.tar.bz2 |
test: Add 'dir' support for installed files in test.json
This is useful for automatically generated docs (doxygen, hotdoc)
with a lot of generated files that may differ with different
versions of the generator.
Diffstat (limited to 'run_project_tests.py')
-rwxr-xr-x | run_project_tests.py | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/run_project_tests.py b/run_project_tests.py index 56b7e2a..c843888 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -131,7 +131,7 @@ class InstalledFile: return None # Handle the different types - if self.typ == 'file': + if self.typ in ['file', 'dir']: return p elif self.typ == 'shared_lib': if env.machines.host.is_windows() or env.machines.host.is_cygwin(): @@ -182,6 +182,20 @@ class InstalledFile: return p + def get_paths(self, compiler: str, env: environment.Environment, installdir: Path) -> T.List[Path]: + p = self.get_path(compiler, env) + if not p: + return [] + if self.typ == 'dir': + abs_p = installdir / p + if not abs_p.exists(): + raise RuntimeError('{} does not exist'.format(p)) + if not abs_p.is_dir(): + raise RuntimeError('{} is not a directory'.format(p)) + return [x.relative_to(installdir) for x in abs_p.rglob('*') if x.is_file() or x.is_symlink()] + else: + return [p] + @functools.total_ordering class TestDef: def __init__(self, path: Path, name: T.Optional[str], args: T.List[str], skip: bool = False): @@ -295,10 +309,15 @@ def platform_fix_name(fname: str, canonical_compiler: str, env: environment.Envi return fname def validate_install(test: TestDef, installdir: Path, compiler: str, env: environment.Environment) -> str: - expected_raw = [x.get_path(compiler, env) for x in test.installed_files] - expected = {Path(x): False for x in expected_raw if x} - found = [x.relative_to(installdir) for x in installdir.rglob('*') if x.is_file() or x.is_symlink()] ret_msg = '' + expected_raw = [] # type: T.List[Path] + for i in test.installed_files: + try: + expected_raw += i.get_paths(compiler, env, installdir) + except RuntimeError as err: + ret_msg += 'Expected path error: {}\n'.format(err) + expected = {x: False for x in expected_raw} + found = [x.relative_to(installdir) for x in installdir.rglob('*') if x.is_file() or x.is_symlink()] # Mark all found files as found and detect unexpected files for fname in found: if fname not in expected: |