Alien-Build-Plugin-Build-Xrepo
view release on metacpan or search on metacpan
t/001_build_plugin.t view on Meta::CPAN
delete $Alien::Build::Plugin::Build::Xrepo::TestSpy::FAIL{libsdl3};
my $errors = $build->install_prop->{xrepo}{errors};
like $errors->{libsdl3}, qr/boom/, 'failed sibling recorded in errors';
like $rp->{errors}{libsdl3}, qr/boom/, 'failure flagged in the returned runtime_prop';
ok !exists $rp->{errors}{zstd}, 'successful packages are not flagged';
like winslash( $rp->{cflags} ), qr/-I[^\s]*zstd\/include/, 'primary package still gathered';
ok exists $rp->{alt}{ninja}, 'sibling after the failure gathered in alt';
ok !exists $rp->{alt}{libsdl3}, 'failed sibling omitted from alt';
is $build->install_type, 'share', 'a partial success is still a share install';
my $mf = path( $build->install_prop->{xrepo}{download_dir} )->child('xrepo.manifest');
ok -e $mf, 'xrepo.manifest written';
my $m = $mf->slurp_utf8;
like $m, qr[^zstd$]m, 'manifest lists the installed package';
like $m, qr[^ninja$]m, 'manifest lists the surviving sibling';
unlike $m, qr[^libsdl3$]m, 'manifest omits the failed package';
};
subtest 'ffi gathers a name and dynamic libs' => sub {
my $r = driven_build( sf( "['zstd']", ffi => 1 ) );
my $build = $r->{build};
my $rp = $build->runtime_prop;
is $rp->{ffi_name}, 'zstd', 'ffi_name from the primary links';
ok scalar @{ $rp->{dynamic_libs} } >= 1, 'dynamic libs listed';
ok scalar grep {/zstd\.dll/} @{ $rp->{dynamic_libs} }, 'dynamic libs name the package dll';
};
subtest 'probe records per-package satisfaction from the engine' => sub {
my $r = driven_build( sf("['zstd']") );
my $build = $r->{build};
my $probe = $build->install_prop->{xrepo}{probed}{zstd};
ok defined $probe, 'probe ran and populated install_prop';
is $probe->{satisfied}, 0, 'spy reported no store hit, so not satisfied';
is $probe->{version}, undef, 'no version found for an uninstalled package';
};
subtest 'nested xrepo export layout is flattened into the prefix' => sub {
$main::NESTED = 1;
my $r = driven_build( sf("['zstd']") );
$main::NESTED = 0;
my $build = $r->{build};
my $stage = $build->install_prop->{prefix};
ok -e "$stage/zstd/include/zstd.h", 'include flattened from the nested content dir';
ok -e "$stage/zstd/lib/zstd.lib", 'lib flattened';
ok -e "$stage/zstd/bin/zstd.dll", 'bin flattened';
ok -e "$stage/bin/zstd.dll", 'bin merged into stage/bin';
my $rp = $build->runtime_prop;
like winslash( $rp->{cflags} ), qr/-I[^\s]*zstd\/include/, 'cflags point at the flattened include dir';
};
subtest 'local_repos are registered with the engine' => sub {
my $lr = Path::Tiny->tempdir;
$lr->child('packages')->mkpath;
@main::ALL_CALLS = ();
my $build = driven_build( sf( "['zstd']", local_repos => [$lr] ) )->{build};
my @repos = map { $_->{url} } grep { $_->{action} eq 'add_repo' } @main::ALL_CALLS;
like "@repos", qr/\Q$lr\E/, 'local repo path passed to the engine add_repo';
is scalar @repos, 1, 'exactly one repo registered';
};
subtest 'missing packages is rejected at alienfile compile' => sub {
my $dir = Path::Tiny->tempdir;
like dies {
alienfile( source => "use alienfile;\nplugin 'Build::Xrepo';\n", stage => "$dir/stage", prefix => "$dir/prefix", root => "$dir/root" );
}, qr[packages], 'packages is a required property';
};
subtest 'interpolate helpers read their own build, not a shared global' => sub {
my $a = driven_build( sf( "['zstd']", version => '1.2.3' ) );
my $b = driven_build( sf( "['ninja']", version => '9.9.9' ) );
my $ia = $a->{build}->meta->interpolator;
my $ib = $b->{build}->meta->interpolator;
like $ia->interpolate( '%{xrepo_version}', $a->{build} ), qr[1\.2\.3], 'A helper sees version from its own build';
like $ib->interpolate( '%{xrepo_version}', $b->{build} ), qr[9\.9\.9], 'B helper sees version from its own build';
is $ia->interpolate( '%{xrepo_cflags}', $a->{build} ), $a->{build}->runtime_prop->{cflags}, 'A helper sees cflags from its own build';
is $ib->interpolate( '%{xrepo_cflags}', $b->{build} ), $b->{build}->runtime_prop->{cflags}, 'B helper sees cflags from its own build';
};
#
done_testing;
( run in 0.793 second using v1.01-cache-2.11-cpan-1236ad508bc )