Skip to content

Commit

Permalink
Early error if toolchain unavailable for testsuite (#1655)
Browse files Browse the repository at this point in the history
  • Loading branch information
mosteo authored Mar 20, 2024
1 parent 86f4124 commit b83fc48
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions testsuite/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from __future__ import absolute_import, print_function

import os.path
import shutil
import sys
from argparse import ArgumentTypeError

Expand All @@ -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
Expand All @@ -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):
Expand Down

0 comments on commit b83fc48

Please sign in to comment.