Skip to content

Commit 14ae4c9

Browse files
committed
Testsuite: Allow altruns to specify an alternate builder
The altrun mechanism allows to specify alternate programs for all the "gnatcov <command>" commands. To be able to support CCG, we also need to be able to override which builder is used. This change adds the possibility to specify an overriding program for gprbuild. Note that gprbuild still needs to be present on path, as it will be used when dumping version information, and to build the support library, as this is done through a Makefile out of the testsuite's control.
1 parent d31efbf commit 14ae4c9

File tree

4 files changed

+44
-7
lines changed

4 files changed

+44
-7
lines changed

testsuite/SUITE/context.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,12 @@ def suite_covpgm_for(self, cmd):
459459
"""
460460
return getattr(thistest.options, 'gnatcov_%s' % cmd, None)
461461

462+
def suite_gprpgm_for(self, pgm):
463+
"""
464+
Alternate program to launch in lieu of "gpr<tool>",
465+
"""
466+
return getattr(thistest.options, pgm, None)
467+
462468
def support_dir(self):
463469
return os.path.join(ROOT_DIR, 'support')
464470

testsuite/SUITE/control.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,16 +384,19 @@ def gnatcov_info():
384384
('pre', 'testcase'),
385385
('post', 'testcase'))
386386

387+
# Allowed alternatives for the --gpr<tool> family of command line options
388+
ALTRUN_GPR = ('gprbuild', )
387389

388-
def altrun_opt_for(p0, p1):
390+
391+
def altrun_opt_for(p0, p1=None):
389392
"""Name of the command line option controlling the ALTRUN (P0, P1) pair."""
390-
return "%s_%s" % (p0, p1)
393+
return "%s_%s" % (p0, p1) if p1 else p0
391394

392395

393-
def altrun_attr_for(p0, p1):
396+
def altrun_attr_for(p0, p1=None):
394397
"""Name of our internal controlling options attribute for the
395398
ALTRUN (P0, P1) pair."""
396-
return "%s_%s" % (p0, p1)
399+
return "%s_%s" % (p0, p1) if p1 else p0
397400

398401

399402
def cargs_opt_for(lang):
@@ -422,6 +425,14 @@ def add_shared_options_to(parser, toplevel):
422425
metavar="CMD",
423426
help='Use CMD instead of "%s %s"' % (pgm, cmd))
424427

428+
# --gpr<tool> family
429+
for pgm in ALTRUN_GPR:
430+
parser.add_argument(
431+
f'--{altrun_opt_for(pgm)}', dest=altrun_attr_for(pgm),
432+
metavar="CMD",
433+
help=f'use CMD instead of "{pgm}"'
434+
)
435+
425436
# Valgrind control
426437
parser.add_argument(
427438
'--enable-valgrind', dest='enable_valgrind',

testsuite/SUITE/tutils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,12 @@ def gprbuild(project,
291291
# Now cleanup, do build and check status
292292
thistest.cleanup(project)
293293

294-
args = (to_list(BUILDER.BASE_COMMAND) +
294+
builder = thistest.suite_gprpgm_for(os.path.basename(BUILDER.BASE_COMMAND))
295+
296+
if builder is None:
297+
builder = BUILDER.BASE_COMMAND
298+
299+
args = (to_list(builder) +
295300
['-P%s' % project] + all_gargs + all_cargs + all_largs)
296301
p = run_and_log(args, output=out, timeout=thistest.options.timeout)
297302
if register_failure:

testsuite/testsuite.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,15 @@ def set_up(self):
579579
'opt': altrun_opt_for(pgm, cmd),
580580
'val': getattr(mopt, altrun_attr_for(pgm, cmd))})
581581

582+
# --gpr<tool> family
583+
for pgm in control.ALTRUN_GPR:
584+
if getattr(mopt, altrun_attr_for(pgm)) is None:
585+
continue
586+
testcase_cmd.append(
587+
f"--{altrun_opt_for(pgm)}="
588+
f"{getattr(mopt, altrun_attr_for(pgm))}"
589+
)
590+
582591
# --cargs family
583592

584593
for lang in [None] + control.KNOWN_LANGUAGES:
@@ -1480,7 +1489,9 @@ def _resolve_paths(self):
14801489
["kernel", "altrun"] +
14811490
[altrun_attr_for(p0, p1)
14821491
for p0, p1 in (control.ALTRUN_HOOK_PAIRS
1483-
+ control.ALTRUN_GNATCOV_PAIRS)])
1492+
+ control.ALTRUN_GNATCOV_PAIRS)] +
1493+
[altrun_attr_for(p0) for p0 in control.ALTRUN_GPR]
1494+
)
14841495

14851496
for attr in attributes_to_resolve:
14861497
current_value = getattr(self.main.args, attr)
@@ -1582,7 +1593,7 @@ def _setup_altrun_hooks(self):
15821593
self.maybe_exec(
15831594
bin=self._bin_for("setup", indir=ctldir), edir=ctldir)
15841595

1585-
def install_altrun_for(p0, p1, binbase):
1596+
def install_altrun_for(p0, p1=None, binbase=None):
15861597
"""Establish an implicit value for the --P0_P1 command line option
15871598
if we find a matching binary program in the altrun subdir we are
15881599
processing. BINBASE provides the binary base name to use."""
@@ -1614,6 +1625,10 @@ def install_altrun_for(p0, p1, binbase):
16141625
for pgm, cmd in control.ALTRUN_GNATCOV_PAIRS:
16151626
install_altrun_for(p0=pgm, p1=cmd, binbase="c%s" % cmd)
16161627

1628+
# For the gpr<tool> replacements, map on binaries called cgpr<tool>:
1629+
for pgm in control.ALTRUN_GPR:
1630+
install_altrun_for(p0=pgm, p1=None, binbase=f"c{pgm}")
1631+
16171632

16181633
if __name__ == "__main__":
16191634
sys.exit(TestSuite().testsuite_main())

0 commit comments

Comments
 (0)