diff --git a/testsuite/drivers/alr.py b/testsuite/drivers/alr.py index 3e40ff625..8a86e2b22 100644 --- a/testsuite/drivers/alr.py +++ b/testsuite/drivers/alr.py @@ -4,15 +4,13 @@ import os import os.path - +import re from shutil import copytree -from e3.os.process import Run, quote_arg + from e3.fs import mkdir +from e3.os.process import Run, quote_arg from e3.testsuite.driver.classic import ProcessResult -import re - - TESTSUITE_ROOT = os.path.dirname(os.path.dirname( os.path.abspath(__file__))) @@ -530,4 +528,15 @@ def alr_builds_dir() -> str: """ Return the path to the builds directory """ - return os.path.join(alr_config_dir(), "cache", "builds") \ No newline at end of file + return os.path.join(alr_config_dir(), "cache", "builds") + + +def external_compiler_version() -> str: + """ + Return the version of the external compiler + """ + # Obtain available compilers + p = run_alr("toolchain") + + # Capture version + return re.search("gnat_external ([0-9.]+)", p.out, re.MULTILINE).group(1) \ No newline at end of file diff --git a/testsuite/drivers/helpers.py b/testsuite/drivers/helpers.py index 8112c09fa..353cd61e7 100644 --- a/testsuite/drivers/helpers.py +++ b/testsuite/drivers/helpers.py @@ -272,4 +272,4 @@ def __exit__(self, exc_type, exc_val, exc_tb): # Release the file lock import fcntl fcntl.flock(self.lock_file.fileno(), fcntl.LOCK_UN) - self.lock_file.close() + self.lock_file.close() \ No newline at end of file diff --git a/testsuite/tests/build/hashes/compiler-input/test.py b/testsuite/tests/build/hashes/compiler-input/test.py index 7633bc40d..5a127ac36 100644 --- a/testsuite/tests/build/hashes/compiler-input/test.py +++ b/testsuite/tests/build/hashes/compiler-input/test.py @@ -4,8 +4,8 @@ import sys -from drivers.alr import run_alr, init_local_crate, alr_with -from drivers.asserts import assert_match, match_solution +from drivers.alr import external_compiler_version, run_alr, init_local_crate, alr_with +from drivers.asserts import assert_match from drivers.builds import clear_builds_dir, hash_input @@ -16,16 +16,36 @@ def check_hash(signature: str) -> None: assert_match(f".*{signature}.*", hash_input("crate_real")) -run_alr("config", "--set", "--global", "dependencies.shared", "true") +# The first test is to check that the external compiler is used when no +# explicit compiler is selected. -# Select the default preferred compiler, in this index is gnat_native=8888 -run_alr("toolchain", "--select") +# Disable compiler selection, so the external is used +run_alr("toolchain", "--disable-assistant") + +# Enable shared dependencies +run_alr("config", "--set", "--global", "dependencies.shared", "true") # Init a crate without explicit compiler dependency init_local_crate("xxx") alr_with("crate_real") # A regular crate in the index run_alr("update") # Ensure the hash inputs are written to disk +# Check the external compiler is in the hash inputs +check_hash(f"version:gnat_external={external_compiler_version()}") + + +# Next, check that selecting a compiler results in it being used + +# Select the default preferred compiler, in this index is gnat_native=8888 +run_alr("toolchain", "--select", "gnat_native") +# Clear the build cache so we are able to locate the new hash +clear_builds_dir() +run_alr("update") +run_alr("update") +# Twice necessary because otherwise the hash inputs cannot be written (during +# the first update the destination folder does not yet exist, and the crate +# sync would remove the hash inputs file) + # Check the expected compiler is in the hash inputs check_hash("version:gnat_native=8888.0.0") @@ -33,7 +53,6 @@ def check_hash(signature: str) -> None: # Next, check with an explicit compiler in the dependencies. Note that we give # the virtual dependency, but the actual native one is used for the hash. -# Clear the build cache so we are able to locate the new hash clear_builds_dir() alr_with("gnat=7777") # Downgrade the compiler with an explicit dependency run_alr("update")