Skip to content

Commit 06a6450

Browse files
committed
Codegen: make --qltest-output optional
1 parent cdd4e80 commit 06a6450

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

misc/codegen/generators/qlgen.py

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,9 @@ def generate(opts, renderer):
320320

321321
generated = {q for q in out.rglob("*.qll")}
322322
generated.add(include_file)
323-
generated.update(q for q in test_out.rglob("*.ql"))
324-
generated.update(q for q in test_out.rglob(missing_test_source_filename))
323+
if test_out:
324+
generated.update(q for q in test_out.rglob("*.ql"))
325+
generated.update(q for q in test_out.rglob(missing_test_source_filename))
325326

326327
stubs = {q for q in stub_out.rglob("*.qll")}
327328

@@ -373,28 +374,29 @@ def generate(opts, renderer):
373374
),
374375
out / 'ParentChild.qll')
375376

376-
for c in data.classes.values():
377-
if _should_skip_qltest(c, data.classes):
378-
continue
379-
test_dir = test_out / c.group / c.name
380-
test_dir.mkdir(parents=True, exist_ok=True)
381-
if all(f.suffix in (".txt", ".ql", ".actual", ".expected") for f in test_dir.glob("*.*")):
382-
log.warning(f"no test source in {test_dir.relative_to(test_out)}")
383-
renderer.render(ql.MissingTestInstructions(),
384-
test_dir / missing_test_source_filename)
385-
continue
386-
total_props, partial_props = _partition(_get_all_properties_to_be_tested(c, data.classes),
387-
lambda p: p.is_total)
388-
renderer.render(ql.ClassTester(class_name=c.name,
389-
properties=total_props,
390-
elements_module=elements_module,
391-
# in case of collapsed hierarchies we want to see the actual QL class in results
392-
show_ql_class="qltest_collapse_hierarchy" in c.pragmas),
393-
test_dir / f"{c.name}.ql")
394-
for p in partial_props:
395-
renderer.render(ql.PropertyTester(class_name=c.name,
396-
elements_module=elements_module,
397-
property=p), test_dir / f"{c.name}_{p.getter}.ql")
377+
if test_out:
378+
for c in data.classes.values():
379+
if _should_skip_qltest(c, data.classes):
380+
continue
381+
test_dir = test_out / c.group / c.name
382+
test_dir.mkdir(parents=True, exist_ok=True)
383+
if all(f.suffix in (".txt", ".ql", ".actual", ".expected") for f in test_dir.glob("*.*")):
384+
log.warning(f"no test source in {test_dir.relative_to(test_out)}")
385+
renderer.render(ql.MissingTestInstructions(),
386+
test_dir / missing_test_source_filename)
387+
continue
388+
total_props, partial_props = _partition(_get_all_properties_to_be_tested(c, data.classes),
389+
lambda p: p.is_total)
390+
renderer.render(ql.ClassTester(class_name=c.name,
391+
properties=total_props,
392+
elements_module=elements_module,
393+
# in case of collapsed hierarchies we want to see the actual QL class in results
394+
show_ql_class="qltest_collapse_hierarchy" in c.pragmas),
395+
test_dir / f"{c.name}.ql")
396+
for p in partial_props:
397+
renderer.render(ql.PropertyTester(class_name=c.name,
398+
elements_module=elements_module,
399+
property=p), test_dir / f"{c.name}_{p.getter}.ql")
398400

399401
final_ipa_types = []
400402
non_final_ipa_types = []

0 commit comments

Comments
 (0)