Skip to content

Commit

Permalink
Testsuite: Add option to build & install TGen_RTS from source
Browse files Browse the repository at this point in the history
This reduces manual work in development setups, and can help to
avoid potential race conditions if a non-externally built version of
TGen_RTS is present in the GPR_PROJECT_PATH env var
  • Loading branch information
leocreuse committed Dec 6, 2024
1 parent df7cf28 commit 588e605
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion testsuite/testsuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import e3.testsuite
from e3.fs import sync_tree
from e3.os.fs import which
from e3.os.process import Run

from drivers.python_script import PythonScriptDriver
Expand Down Expand Up @@ -46,6 +45,13 @@ def add_options(self, parser):
action="store_true",
help="Rewrite test baselines according to current output.",
)
parser.add_argument(
"--setup-tgen-rts",
action="store_true",
help="Build and install TGen_RTS to prevent tests from re-building"
" the library. This is not needed if the environment already"
" provides the installed project."
)

def set_up(self):
super().set_up()
Expand All @@ -67,6 +73,45 @@ def set_up(self):
os.environ["PATH"],
)

if self.main.args.setup_tgen_rts:
# Copy the TGen_RTS sources from the tree to a temporary directory
rts_build_dir = os.path.join(self.working_dir, "tgen_rts")
rts_install_dir = os.path.join(rts_build_dir, "local")
sync_tree(
os.path.join(self.root_dir, "..", "src", "tgen", "tgen_rts"),
rts_build_dir
)
e3.testsuite.logger.info("Building TGen_RTS ...")
p_build = Run([
"gprbuild",
f"-P{os.path.join(rts_build_dir, 'tgen_rts.gpr')}",
"-g",
"-bargs",
"-Es"
])
if p_build.status != 0:
e3.testsuite.logger.fatal(
f"Failed to build TGen_RTS: {p_build.out}"
)
exit(1)

e3.testsuite.logger.info("Installing TGen_RTS ...")
p_install = Run([
"gprinstall",
"-p",
f"-P{os.path.join(rts_build_dir, 'tgen_rts.gpr')}",
f"--prefix={rts_install_dir}",
])
if p_install.status != 0:
e3.testsuite.logger.fatal(
f"Failed to install TGen_RTS: {p_install.out}"
)
exit(1)
self.env.add_search_path(
"GPR_PROJECT_PATH",
os.path.join(rts_install_dir, "share", "gpr")
)

if self.env.valgrind:
# The --valgrind switch was given. Set the PATH to point to the
# valgrind directory (see ../../valgrind/README).
Expand Down

0 comments on commit 588e605

Please sign in to comment.