From 3455674f49fd115fbeb58e5786f6038932d433e3 Mon Sep 17 00:00:00 2001 From: "Alejandro R. Mosteo" Date: Sun, 6 Aug 2023 12:04:08 +0200 Subject: [PATCH] Self-review --- src/alire/alire-builds-hashes.adb | 2 ++ src/alire/alire-builds-hashes.ads | 3 +-- src/alire/alire-hashes-common.adb | 3 ++- testsuite/drivers/builds.py | 6 ++---- testsuite/tests/build/hashes/input-profiles/test.py | 2 +- testsuite/tests/dockerized/misc/default-cache/test.py | 2 +- testsuite/tests/misc/sync-missing-deps/test.py | 1 + 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/alire/alire-builds-hashes.adb b/src/alire/alire-builds-hashes.adb index 60bc1dca4..e123a2e77 100644 --- a/src/alire/alire-builds-hashes.adb +++ b/src/alire/alire-builds-hashes.adb @@ -68,6 +68,8 @@ package body Alire.Builds.Hashes is begin for Var of Vars loop SHA.Update (C, Var, Append_Nul => True); + -- The nul character as separator ensures no ambiguity because + -- of consecutive entries. end loop; This.Hashes.Insert (Rel.Name, SHA.Get_Digest (C)); diff --git a/src/alire/alire-builds-hashes.ads b/src/alire/alire-builds-hashes.ads index 4d4e6efe7..272c1b7c6 100644 --- a/src/alire/alire-builds-hashes.ads +++ b/src/alire/alire-builds-hashes.ads @@ -21,8 +21,7 @@ package Alire.Builds.Hashes is Name : Crate_Name) return String with Pre => not This.Is_Empty; - -- Retrieve the hash of a crate in Root's solution; if This.Is_Empty all - -- hashes will be computed at this time. + -- Retrieve the hash of a crate in Root's solution private diff --git a/src/alire/alire-hashes-common.adb b/src/alire/alire-hashes-common.adb index a5c57fe71..e040c8bdf 100644 --- a/src/alire/alire-hashes-common.adb +++ b/src/alire/alire-hashes-common.adb @@ -42,7 +42,8 @@ package body Alire.Hashes.Common is is use Ada.Streams; Bytes : Stream_Element_Array (1 .. S'Length) - with Address => S (S'First)'address, Import; + with Address => S (S'First)'Address, Import; + pragma Assert (Bytes'Size = S (S'Range)'Size); begin Update (C, Bytes); if Append_Nul then diff --git a/testsuite/drivers/builds.py b/testsuite/drivers/builds.py index ddbf56ab7..ed1bee964 100644 --- a/testsuite/drivers/builds.py +++ b/testsuite/drivers/builds.py @@ -11,8 +11,8 @@ def find_dir(crate_name: str) -> str: """ Find the build dir of a crate in the shared build directory """ - if len(glob(f"{path()}/{crate_name}_*")) != 1: - raise AssertionError(f"Unexpected number of dirs for crate {crate_name}") + if len(found := glob(f"{path()}/{crate_name}_*")) != 1: + raise AssertionError(f"Unexpected number of dirs for crate {crate_name}: {found}") return glob(f"{path()}/{crate_name}_*")[0] @@ -20,8 +20,6 @@ def find_hash(crate_name: str) -> str: """ Find the hash of a crate in the shared build directory """ - if len(found := glob(f"{path()}/{crate_name}_*")) != 1: - raise AssertionError(f"Unexpected number of dirs for crate {crate_name}: {found}") return find_dir(crate_name).split("_")[-1] diff --git a/testsuite/tests/build/hashes/input-profiles/test.py b/testsuite/tests/build/hashes/input-profiles/test.py index 8d1266cd7..4af2a0e3f 100644 --- a/testsuite/tests/build/hashes/input-profiles/test.py +++ b/testsuite/tests/build/hashes/input-profiles/test.py @@ -18,7 +18,7 @@ assert_match(".*profile:libhello=RELEASE.*", hash_input("libhello")) -# Build with dependencies in VALIDATION modes. +# Build with dependencies in VALIDATION mode # Clean up first because find_hash() will fail if there are multiple builds shutil.rmtree(builds.path()) run_alr("build", "--profiles=*=validation") diff --git a/testsuite/tests/dockerized/misc/default-cache/test.py b/testsuite/tests/dockerized/misc/default-cache/test.py index 62270df35..1a2367a4c 100644 --- a/testsuite/tests/dockerized/misc/default-cache/test.py +++ b/testsuite/tests/dockerized/misc/default-cache/test.py @@ -35,7 +35,7 @@ f"Vault not found at the expected location: f{contents(base)}" # Shared builds -# We hardcode this hash so we detect unwilling changes ot our hashing scheme +# We hardcode this hash so we detect unwilling changes to our hashing scheme hash = "e66592c9a181de97dc3a342cf76378f6ffa6667d7c1864c74d98bec8ffaf4f3d" assert \ os.path.isdir(f"{base}/builds/crate_real_1.0.0_filesystem_{hash}"), \ diff --git a/testsuite/tests/misc/sync-missing-deps/test.py b/testsuite/tests/misc/sync-missing-deps/test.py index f7264edad..ba91edda1 100644 --- a/testsuite/tests/misc/sync-missing-deps/test.py +++ b/testsuite/tests/misc/sync-missing-deps/test.py @@ -20,6 +20,7 @@ # Run commands that require a valid session after deleting a dependency. All # should succeed and recreate the missing dependency folder. +# The first round uses sandboxed dependencies. The second round uses shared ones. for round in range(2): if round == 2: # Prepare same test for shared dependencies