1
1
using BinaryBuilderBase: Prefix, archive_artifact, package, list_tarball_files
2
2
using Pkg. Artifacts: create_artifact, remove_artifact, with_artifacts_directory
3
+ using SHA
3
4
using Test
4
5
5
6
@testset " Archive Utils" begin
@@ -25,11 +26,22 @@ using Test
25
26
end
26
27
27
28
mktempdir () do output_dir
28
- for (format, ext) in [(" gzip" , " gz" ), (" xz" , " xz" )]
29
+ for (format, ext, hash) in ((" gzip" , " gz" , " 568f743e965b63d3187b6a2647700a71d1d7520b4596fbf2bfb39ffa67c4bb55" ),
30
+ # Compressing with p7zip/xz doesn't seem to be fully reproducible, at least not
31
+ # across different systems. We'll try to investigate more, but for the time being
32
+ # skip the reproducibility test for it.
33
+ (" xz" , " xz" , " " ))
29
34
tarball_path = joinpath (output_dir, " foo.tar.$ext " )
30
35
package (prefix, tarball_path; format= format)
31
36
@test isfile (tarball_path)
32
37
38
+ if ! isempty (hash)
39
+ tarball_hash = open (tarball_path, " r" ) do io
40
+ bytes2hex (sha256 (io))
41
+ end
42
+ @test tarball_hash == hash
43
+ end
44
+
33
45
# Test that we can inspect the contents of the tarball
34
46
contents = list_tarball_files (tarball_path)
35
47
@test " bin/bar.sh" in contents
@@ -52,7 +64,8 @@ using Test
52
64
53
65
# Create an artifact containing the full source directory
54
66
mktempdir () do output_dir
55
- tarball, _, tree_hash = package (Prefix (src_dir), joinpath (output_dir, lib), v " 1.2.3" )
67
+ tarball, tarball_hash, tree_hash = package (Prefix (src_dir), joinpath (output_dir, lib), v " 1.2.3" )
68
+ @test tarball_hash == " 46abbba8bf97315ecf3d979fb1c95e2e1a639ab71d8d569736e68e6a2ab4a427"
56
69
@test tree_hash == Base. SHA1 (" b316cc5e582cbd503b2da34bd1b79aaf3941ad80" )
57
70
contents = list_tarball_files (tarball)
58
71
@test libname ∈ contents
@@ -61,7 +74,8 @@ using Test
61
74
62
75
# Create an artifact containing *only* the log file logs/libfoo.gz
63
76
mktempdir () do output_dir
64
- tarball, _, tree_hash = package (Prefix (src_dir), joinpath (output_dir, lib), v " 1.2.3" ; filter= (_, f) -> f == " logs" )
77
+ tarball, tarball_hash, tree_hash = package (Prefix (src_dir), joinpath (output_dir, lib), v " 1.2.3" ; filter= (_, f) -> f == " logs" )
78
+ @test tarball_hash == " 6b51bcbed720e98d5eaef43a0b10d5b08e11ff05d05fe3ca9525686871767c4c"
65
79
@test tree_hash == Base. SHA1 (" 3a3ccf24312676bdd8c2ec769232dbd3bd1b9857" )
66
80
contents = list_tarball_files (tarball)
67
81
@test libname ∉ contents
@@ -77,7 +91,7 @@ using Test
77
91
with_artifacts_directory (art_dir) do
78
92
hash = create_artifact (p -> touch (joinpath (p, " foo" )))
79
93
tarball_path = joinpath (art_dir, " foo.tar.gz" )
80
- archive_artifact (hash, tarball_path)
94
+ @test archive_artifact (hash, tarball_path) == " 59f35d4bde88850c3e80d6890770902ca6e9e6c3a3b3e9343df686a7b28e89b0 "
81
95
@test " foo" in list_tarball_files (tarball_path)
82
96
rm (tarball_path)
83
97
0 commit comments