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).