Skip to content

Commit

Permalink
Self-review
Browse files Browse the repository at this point in the history
  • Loading branch information
mosteo committed Aug 6, 2023
1 parent 3c78245 commit 3455674
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/alire/alire-builds-hashes.adb
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
3 changes: 1 addition & 2 deletions src/alire/alire-builds-hashes.ads
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion src/alire/alire-hashes-common.adb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions testsuite/drivers/builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@ 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]


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]


Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/build/hashes/input-profiles/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/dockerized/misc/default-cache/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"), \
Expand Down
1 change: 1 addition & 0 deletions testsuite/tests/misc/sync-missing-deps/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3455674

Please sign in to comment.