From 588e605a2696c27e867e88bd129f3952c38a75ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Creuse?= Date: Thu, 5 Dec 2024 16:50:04 +0100 Subject: [PATCH] Testsuite: Add option to build & install TGen_RTS from source 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 --- testsuite/testsuite.py | 47 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/testsuite/testsuite.py b/testsuite/testsuite.py index 0a7a6263..668f772a 100755 --- a/testsuite/testsuite.py +++ b/testsuite/testsuite.py @@ -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 @@ -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() @@ -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).