You've already forked libadalang
mirror of
https://github.com/AdaCore/libadalang.git
synced 2026-02-12 12:28:54 -08:00
This commit turns on the "PLE root" Langkit mechanism to be able to run PLE on each compilation unit independently, even if compilation units are stored in the same source file. In addition, it extends all the unit provider where this is possible (Auto_Provider, Project_Provider for GPR2) so that resolving a unit yields a filename *plus* the compilation unit index in that source file. Finally, it adds several testcases to exercize these features.
56 lines
1.2 KiB
Python
56 lines
1.2 KiB
Python
"""
|
|
Check that App reports missing source files as expected.
|
|
"""
|
|
|
|
import dataclasses
|
|
import os.path
|
|
import subprocess
|
|
import sys
|
|
from typing import List
|
|
|
|
import libadalang as lal
|
|
|
|
|
|
@dataclasses.dataclass
|
|
class Testcase:
|
|
"""
|
|
Each testcase runs the ``App`` below and passes it the command line
|
|
arguments ``args``.
|
|
"""
|
|
label: str
|
|
args: List[str]
|
|
|
|
|
|
class App(lal.App):
|
|
def process_unit(self, unit):
|
|
print("Processing:", os.path.basename(unit.filename))
|
|
unit.populate_lexical_env(1)
|
|
|
|
|
|
tests = [
|
|
Testcase("no_missing", ["no_missing.adb", "no_such_file.adb"]),
|
|
Testcase(
|
|
"missing_warn",
|
|
["-k", "no_missing.adb", "missing.adb", "no_such_file.adb"],
|
|
),
|
|
Testcase(
|
|
"missing_error",
|
|
["no_missing.adb", "missing.adb", "no_such_file.adb"],
|
|
),
|
|
]
|
|
|
|
|
|
if len(sys.argv) == 1:
|
|
print("test.py: Starting...")
|
|
print("")
|
|
for t in tests:
|
|
print(f"== {t.label} ==")
|
|
print("")
|
|
sys.stdout.flush()
|
|
p = subprocess.run([sys.executable, __file__] + t.args)
|
|
print("Return code:", p.returncode)
|
|
print("")
|
|
print("test.py: Done.")
|
|
else:
|
|
App.run(sys.argv[1:])
|