Skip to content

Commit 17439fa

Browse files
mensindanirbheek
authored andcommitted
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.
1 parent fdae213 commit 17439fa

File tree

5 files changed

+27
-401
lines changed

5 files changed

+27
-401
lines changed

data/test.schema.json

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"type": "string",
2121
"enum": [
2222
"file",
23+
"dir",
2324
"exe",
2425
"shared_lib",
2526
"pdb",

docs/markdown/Contributing.md

+1
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ current platform. The following values are currently supported:
242242
| type | Description |
243243
| ------------- | ------------------------------------------------------------------------------------------------------- |
244244
| `file` | No postprocessing, just use the provided path |
245+
| `dir` | To include all files inside the directory (for generated docs, etc). The path must be a valid directory |
245246
| `exe` | For executables. On Windows the `.exe` suffix is added to the path in `file` |
246247
| `shared_lib` | For shared libraries, always written as `name`. The appropriate suffix and prefix are added by platform |
247248
| `pdb` | For Windows PDB files. PDB entries are ignored on non Windows platforms |

run_project_tests.py

+23-4
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def get_path(self, compiler: str, env: environment.Environment) -> T.Optional[Pa
131131
return None
132132

133133
# Handle the different types
134-
if self.typ == 'file':
134+
if self.typ in ['file', 'dir']:
135135
return p
136136
elif self.typ == 'shared_lib':
137137
if env.machines.host.is_windows() or env.machines.host.is_cygwin():
@@ -182,6 +182,20 @@ def get_path(self, compiler: str, env: environment.Environment) -> T.Optional[Pa
182182

183183
return p
184184

185+
def get_paths(self, compiler: str, env: environment.Environment, installdir: Path) -> T.List[Path]:
186+
p = self.get_path(compiler, env)
187+
if not p:
188+
return []
189+
if self.typ == 'dir':
190+
abs_p = installdir / p
191+
if not abs_p.exists():
192+
raise RuntimeError('{} does not exist'.format(p))
193+
if not abs_p.is_dir():
194+
raise RuntimeError('{} is not a directory'.format(p))
195+
return [x.relative_to(installdir) for x in abs_p.rglob('*') if x.is_file() or x.is_symlink()]
196+
else:
197+
return [p]
198+
185199
@functools.total_ordering
186200
class TestDef:
187201
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
295309
return fname
296310

297311
def validate_install(test: TestDef, installdir: Path, compiler: str, env: environment.Environment) -> str:
298-
expected_raw = [x.get_path(compiler, env) for x in test.installed_files]
299-
expected = {Path(x): False for x in expected_raw if x}
300-
found = [x.relative_to(installdir) for x in installdir.rglob('*') if x.is_file() or x.is_symlink()]
301312
ret_msg = ''
313+
expected_raw = [] # type: T.List[Path]
314+
for i in test.installed_files:
315+
try:
316+
expected_raw += i.get_paths(compiler, env, installdir)
317+
except RuntimeError as err:
318+
ret_msg += 'Expected path error: {}\n'.format(err)
319+
expected = {x: False for x in expected_raw}
320+
found = [x.relative_to(installdir) for x in installdir.rglob('*') if x.is_file() or x.is_symlink()]
302321
# Mark all found files as found and detect unexpected files
303322
for fname in found:
304323
if fname not in expected:
+1-83
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,5 @@
11
{
22
"installed": [
3-
{"type": "file", "file": "usr/share/doc/spede/html/annotated.html"},
4-
{"type": "file", "file": "usr/share/doc/spede/html/bc_s.png"},
5-
{"type": "file", "file": "usr/share/doc/spede/html/bdwn.png"},
6-
{"type": "file", "file": "usr/share/doc/spede/html/classComedy_1_1Comedian.html"},
7-
{"type": "file", "file": "usr/share/doc/spede/html/classComedy_1_1Comedian.png"},
8-
{"type": "file", "file": "usr/share/doc/spede/html/classComedy_1_1Comedian-members.html"},
9-
{"type": "file", "file": "usr/share/doc/spede/html/classComedy_1_1Spede.html"},
10-
{"type": "file", "file": "usr/share/doc/spede/html/classComedy_1_1Spede.png"},
11-
{"type": "file", "file": "usr/share/doc/spede/html/classComedy_1_1Spede-members.html"},
12-
{"type": "file", "file": "usr/share/doc/spede/html/classes.html"},
13-
{"type": "file", "file": "usr/share/doc/spede/html/closed.png"},
14-
{"type": "file", "file": "usr/share/doc/spede/html/comedian_8h_source.html"},
15-
{"type": "file", "file": "usr/share/doc/spede/html/dir_7bdce917e28dfbd493cadd1d2e5c7d80.html"},
16-
{"type": "file", "file": "usr/share/doc/spede/html/dir_44a4667d36a4476878de085754f6d2b9.html"},
17-
{"type": "file", "file": "usr/share/doc/spede/html/dir_68b523c5b3a2dcea45d5ce70397fb722.html"},
18-
{"type": "file", "file": "usr/share/doc/spede/html/dir_a7e6472d2301212032fd74682f8217f3.html"},
19-
{"type": "file", "file": "usr/share/doc/spede/html/dir_ee191f21c02d247cc959e80c1a3acadf.html"},
20-
{"type": "file", "file": "usr/share/doc/spede/html/doc.png"},
21-
{"type": "file", "file": "usr/share/doc/spede/html/doxygen.css"},
22-
{"type": "file", "file": "usr/share/doc/spede/html/doxygen.png"},
23-
{"type": "file", "file": "usr/share/doc/spede/html/dynsections.js"},
24-
{"type": "file", "file": "usr/share/doc/spede/html/files.html"},
25-
{"type": "file", "file": "usr/share/doc/spede/html/folderclosed.png"},
26-
{"type": "file", "file": "usr/share/doc/spede/html/folderopen.png"},
27-
{"type": "file", "file": "usr/share/doc/spede/html/functions.html"},
28-
{"type": "file", "file": "usr/share/doc/spede/html/functions_func.html"},
29-
{"type": "file", "file": "usr/share/doc/spede/html/hierarchy.html"},
30-
{"type": "file", "file": "usr/share/doc/spede/html/index.html"},
31-
{"type": "file", "file": "usr/share/doc/spede/html/jquery.js"},
32-
{"type": "file", "file": "usr/share/doc/spede/html/menu.js"},
33-
{"type": "file", "file": "usr/share/doc/spede/html/menudata.js"},
34-
{"type": "file", "file": "usr/share/doc/spede/html/namespaceComedy.html"},
35-
{"type": "file", "file": "usr/share/doc/spede/html/namespacemembers.html"},
36-
{"type": "file", "file": "usr/share/doc/spede/html/namespacemembers_func.html"},
37-
{"type": "file", "file": "usr/share/doc/spede/html/namespaces.html"},
38-
{"type": "file", "file": "usr/share/doc/spede/html/nav_f.png"},
39-
{"type": "file", "file": "usr/share/doc/spede/html/nav_g.png"},
40-
{"type": "file", "file": "usr/share/doc/spede/html/nav_h.png"},
41-
{"type": "file", "file": "usr/share/doc/spede/html/open.png"},
42-
{"type": "file", "file": "usr/share/doc/spede/html/search/all_0.html"},
43-
{"type": "file", "file": "usr/share/doc/spede/html/search/all_0.js"},
44-
{"type": "file", "file": "usr/share/doc/spede/html/search/all_1.html"},
45-
{"type": "file", "file": "usr/share/doc/spede/html/search/all_1.js"},
46-
{"type": "file", "file": "usr/share/doc/spede/html/search/all_2.html"},
47-
{"type": "file", "file": "usr/share/doc/spede/html/search/all_2.js"},
48-
{"type": "file", "file": "usr/share/doc/spede/html/search/all_3.html"},
49-
{"type": "file", "file": "usr/share/doc/spede/html/search/all_3.js"},
50-
{"type": "file", "file": "usr/share/doc/spede/html/search/classes_0.html"},
51-
{"type": "file", "file": "usr/share/doc/spede/html/search/classes_0.js"},
52-
{"type": "file", "file": "usr/share/doc/spede/html/search/classes_1.html"},
53-
{"type": "file", "file": "usr/share/doc/spede/html/search/classes_1.js"},
54-
{"type": "file", "file": "usr/share/doc/spede/html/search/close.png"},
55-
{"type": "file", "file": "usr/share/doc/spede/html/search/files_0.html"},
56-
{"type": "file", "file": "usr/share/doc/spede/html/search/files_0.js"},
57-
{"type": "file", "file": "usr/share/doc/spede/html/search/functions_0.html"},
58-
{"type": "file", "file": "usr/share/doc/spede/html/search/functions_0.js"},
59-
{"type": "file", "file": "usr/share/doc/spede/html/search/functions_1.html"},
60-
{"type": "file", "file": "usr/share/doc/spede/html/search/functions_1.js"},
61-
{"type": "file", "file": "usr/share/doc/spede/html/search/functions_2.html"},
62-
{"type": "file", "file": "usr/share/doc/spede/html/search/functions_2.js"},
63-
{"type": "file", "file": "usr/share/doc/spede/html/search/mag_sel.png"},
64-
{"type": "file", "file": "usr/share/doc/spede/html/search/namespaces_0.html"},
65-
{"type": "file", "file": "usr/share/doc/spede/html/search/namespaces_0.js"},
66-
{"type": "file", "file": "usr/share/doc/spede/html/search/nomatches.html"},
67-
{"type": "file", "file": "usr/share/doc/spede/html/search/pages_0.html"},
68-
{"type": "file", "file": "usr/share/doc/spede/html/search/pages_0.js"},
69-
{"type": "file", "file": "usr/share/doc/spede/html/search/search.css"},
70-
{"type": "file", "file": "usr/share/doc/spede/html/search/search.js"},
71-
{"type": "file", "file": "usr/share/doc/spede/html/search/searchdata.js"},
72-
{"type": "file", "file": "usr/share/doc/spede/html/search/search_l.png"},
73-
{"type": "file", "file": "usr/share/doc/spede/html/search/search_m.png"},
74-
{"type": "file", "file": "usr/share/doc/spede/html/search/search_r.png"},
75-
{"type": "file", "file": "usr/share/doc/spede/html/spede_8cpp.html"},
76-
{"type": "file", "file": "usr/share/doc/spede/html/spede_8h.html"},
77-
{"type": "file", "file": "usr/share/doc/spede/html/spede_8h_source.html"},
78-
{"type": "file", "file": "usr/share/doc/spede/html/splitbar.png"},
79-
{"type": "file", "file": "usr/share/doc/spede/html/sync_off.png"},
80-
{"type": "file", "file": "usr/share/doc/spede/html/sync_on.png"},
81-
{"type": "file", "file": "usr/share/doc/spede/html/tabs.css"},
82-
{"type": "file", "file": "usr/share/doc/spede/html/tab_a.png"},
83-
{"type": "file", "file": "usr/share/doc/spede/html/tab_b.png"},
84-
{"type": "file", "file": "usr/share/doc/spede/html/tab_h.png"},
85-
{"type": "file", "file": "usr/share/doc/spede/html/tab_s.png"}
3+
{"type": "dir", "file": "usr/share/doc/spede/html"}
864
]
875
}

0 commit comments

Comments
 (0)