Skip to content
Permalink
Browse files

Test reproducibility of precompilation

Compile NativeCall.pm6 twice and check that it produces the exact same bytecode
as signified by the precomp file's checksum. NativeCall is a good candidate for
this as it's a somewhat complex and good sized module with a couple of
dependencies. This should cover a nice range of reproducibility issues.
  • Loading branch information...
niner committed May 2, 2019
1 parent 8ec2c43 commit 532d19fc4e18bc08f7660d430d1c696bcbbe4b9d
Showing with 27 additions and 0 deletions.
  1. +27 −0 t/02-rakudo/reproducible-builds.t
@@ -0,0 +1,27 @@
use Test;

my $store = CompUnit::PrecompilationStore::File.new(
:prefix($*TMPDIR.child("rakudo-precomp" ~ (^2**128).pick.base(36)))
);
my $precompilation-repository = CompUnit::PrecompilationRepository::Default.new(:$store);
my @checksums;
my $compiler-id = CompUnit::PrecompilationId.new-without-check($*PERL.compiler.id);
my $id = CompUnit::PrecompilationId.new('000');
for ^2 -> $run {
$precompilation-repository.precompile(
'lib/NativeCall.pm6'.IO,
$id,
:force,
);
@checksums.push: $store.load-unit($compiler-id, $id).checksum;
$store.remove-from-cache($id);
$store.delete-by-compiler($compiler-id);
}
$store.prefix.child('.lock').unlink;
$store.prefix.rmdir;

is @checksums[1], @checksums[0], 'Both precompilation runs resulted in the same checksum';

done-testing;

# vim: ft=perl6

0 comments on commit 532d19f

Please sign in to comment.
You can’t perform that action at this time.