From b83fc48bfbe3867819759f97f1cf6c4c452d62ca Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Wed, 20 Mar 2024 15:19:23 +0100 Subject: [PATCH] Early error if toolchain unavailable for testsuite (#1655) --- testsuite/run.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/testsuite/run.py b/testsuite/run.py index 15f9370c4..e20b2df9f 100755 --- a/testsuite/run.py +++ b/testsuite/run.py @@ -10,6 +10,7 @@ from __future__ import absolute_import, print_function import os.path +import shutil import sys from argparse import ArgumentTypeError @@ -35,6 +36,13 @@ def add_options(self, parser): dest='alr_path', metavar='FILE', help='''Set `alr` binary to run the testsuite against. Defaults to `alr` from project's `bin` directory.''') + def require_executable(self, name): + path = shutil.which(name) + if path is None: + raise FileNotFoundError(f"{name} not found in PATH") + else: + print(f"Using {name} at {path}") + def set_up(self): super().set_up() os.environ['ALR_PATH'] = self.main.args.alr_path @@ -51,6 +59,13 @@ def set_up(self): # during the tests (e.g. submitting a release by accident) os.environ["ALR_TESTSUITE"] = "TRUE" + # Ensure toolchain is in scope, or err early instead of during tests + # Locate gnat and gprbuild in path and report their location + required_executables = ['gnat', 'gprbuild'] + for exe in required_executables: + self.require_executable(exe) + print() + def _alr_path(self, alr_file): alr_path = os.path.abspath(alr_file) if not os.path.isfile(alr_path):