Files
langkit/testsuite/python_support/lkt_compile.py
Pierre-Marie de Rodat fa79e76f46 Testsuite: create a new "lkt_compile" test driver
All tests which just check the presence/absence of errors when compiling
Lkt language specs have the same "test.py" script: put a reference
script in "python_support", create a new test driver to let tests use
it easily and migrate relevant tests to it.

For GitHub issue #622
2022-06-08 12:24:31 +00:00

41 lines
876 B
Python

"""
Test script to compile all Lkt sources in the current directory up to code
emission and to print error messages.
"""
import argparse
import glob
import langkit
from utils import emit_and_print_errors
parser = argparse.ArgumentParser()
parser.add_argument(
"--generate-unparser",
action="store_true",
help="Enable the generation of the unparser",
)
args = parser.parse_args()
# Compile all *.lkt" file except the ones starting with "common", as they
# contain just common code for the other sources, but are not compilable alone.
tests = [f for f in glob.glob("*.lkt") if not f.startswith("common")]
for lkt_file in sorted(tests):
print(f"== {lkt_file} ==")
emit_and_print_errors(
lkt_file=lkt_file,
types_from_lkt=True,
generate_unparser=args.generate_unparser,
)
langkit.reset()
print("")
print("Done")