Skip to content

Commit

Permalink
Merge branch 'topic/libadalang-internal-testsuite/13' into 'master'
Browse files Browse the repository at this point in the history
gnat_compare test driver: handle more fields for test configuration

See merge request eng/libadalang/libadalang!1579
  • Loading branch information
thvnx committed Mar 29, 2024
2 parents 9b9a7a5 + 21494e5 commit 7bd17f0
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion testsuite/drivers/gnat_compare_driver.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from __future__ import annotations
from drivers.base_driver import BaseDriver
import os.path


class GNATCompareDriver(BaseDriver):
Expand All @@ -12,15 +14,56 @@ class GNATCompareDriver(BaseDriver):
* ``project_file`` (mandatory): A filename for a project file, used to
create a project unit provider.
* ``project_path``: List of directory names (relative to the testsuite root
directory) to add to the project files lookup path
(``GPR_PROJECT_PATH``).
* ``project_vars``: Name/value mapping for project files external
variables.
* ``preprocessor_data_file``: Filename for the preprocessor data file.
* ``preprocessor_path``: List of directories where preprocessor data files
can be found.
* ``comparisons``: Select what differences between GNAT's xrefs and
Libadalang's to report.
"""

def run(self):
env: dict[str, str] = {}
"""
Additional environment variables for "nameres".
"""

# Path for project files: make directories from the "project_path" key
# prioritary and append existing paths from the environment.
env["GPR_PROJECT_PATH"] = os.path.pathsep.join(
[
os.path.join(self.env.root_dir, p)
for p in self.test_env.get("project_path", [])
]
+ os.environ.get("GPR_PROJECT_PATH", "").split(os.path.pathsep)
)

project_file = self.test_env['project_file']
comparisons = self.test_env.get('comparisons')

argv = ['gnat_compare', '-P' + project_file]
if comparisons:
argv.append('-d{}'.format(comparisons))
self.run_and_check(argv, memcheck=True)

for name, value in sorted(
self.test_env.get("project_vars", {}).items()
):
argv.append(f"-X{name}={value}")

# Preprocessor handling
preprocessor_data_file = self.test_env.get("preprocessor_data_file",
None)
preprocessor_path = self.test_env.get("preprocessor_path", [])
if preprocessor_data_file:
argv.append(f"--preprocessor-data-file={preprocessor_data_file}")
argv.extend(f"--preprocessor-path={d}" for d in preprocessor_path)

self.run_and_check(argv, memcheck=True, env=env)

0 comments on commit 7bd17f0

Please sign in to comment.