Skip to content

Commit

Permalink
t/87-xs-cross.t: remove TODO from tests, add test using "pp --clean ..."
Browse files Browse the repository at this point in the history
  • Loading branch information
rschupp committed Mar 5, 2024
1 parent 0f4614e commit 4a4c535
Showing 1 changed file with 54 additions and 57 deletions.
111 changes: 54 additions & 57 deletions t/87-xs-cross.t
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,43 @@ plan skip_all => "Tests only relevant on Windows" unless $^O eq 'MSWin32';
# In the Gnome stack almost all glue DLLs call functions from Glib.xs.dll
# and e.g. Gtk2.xs.dll calls functions in Pango.xs.dll and Cairo.xs.dll.

# XXX debug helpers
use File::Find;
use IPC::Run3;
use Module::ScanDeps; # XXX
diag("FOO Module::ScanDeps version $Module::ScanDeps::VERSION"); # XXX

sub show_tree
{
my ($top) = @_;
my @files;
find(sub { push @files, $File::Find::name if -f $_ }, $top);
diag(join("\n", "--- $top ---", (sort @files), "---"));
}

sub show_dlls
{
my ($install_base, $mod_name) = @_;
my @mod_parts = split("::", $mod_name);
my $mod_dll = catfile($install_base, qw(lib perl5), $Config{archname},
qw(auto), @mod_parts, "$mod_parts[-1].$Config{dlext}");
diag("FOO $mod_name => $mod_dll"); # XXX

my ($out, $err);
run3([qw(objdump -ax), $mod_dll], \undef, \$out, \$err);
if ($? != 0)
{
diag(qq["objdump -ax $mod_dll" failed:\n$err]);
return;
}

run3([$^X, "-nE", "print if /DLL Name.*/"], \$out, \$err, \$err);
if ($? != 0)
{
diag(qq[Extracting DLL names from $mod_dll failed:\n$err]);
return;
}

diag("$mod_dll links to:\n$err");
}
### debug helpers (Windows only)
#use File::Find;
#use IPC::Run3;
#use Module::ScanDeps;
#
#sub show_tree
#{
# my ($top) = @_;
# my @files;
# find(sub { push @files, $File::Find::name if -f $_ }, $top);
# diag(join("\n", "--- $top ---", (sort @files), "---"));
#}
#
#sub show_dlls
#{
# my ($install_base, $mod_name) = @_;
# my @mod_parts = split("::", $mod_name);
# my $mod_dll = catfile($install_base, qw(lib perl5), $Config{archname},
# qw(auto), @mod_parts, "$mod_parts[-1].$Config{dlext}");
# diag("XS module $mod_name => $mod_dll");
#
# my ($out, $err);
# run3([qw(objdump -ax), $mod_dll], \undef, \$out, \$err);
# if ($? != 0)
# {
# diag(qq["objdump -ax $mod_dll" failed:\n$err]);
# return;
# }
# run3([$^X, "-nE", "print if /DLL Name.*/"], \$out, \$err, \$err);
# if ($? != 0)
# {
# diag(qq[Extracting DLL names from $mod_dll failed:\n$err]);
# return;
# }
# diag("$mod_dll links to:\n$err");
#}


my @checks = (
Expand All @@ -74,7 +72,7 @@ my @checks = (
},
);

plan tests => 2 * 4 + 7 * @checks + 6; # XXX +6
plan tests => 2 * 4 + 10 * @checks;


# get $(MAKE) from the toplevel Makefile
Expand All @@ -88,7 +86,6 @@ my $make;
}
close $mk;
}
diag("FOO make = $make");

# create temporary directory to install modules into
my $base = $ENV{PAR_TMPDIR} = tempdir(TMPDIR => 1, CLEANUP => 1);
Expand All @@ -101,52 +98,52 @@ my @libs = (catdir($base, qw(lib perl5), $Config{archname}), catdir($base, qw(li
# - auto/XSQuux/XSQuux.a (added to LIBS by ExtUtils::Depends::find_extra_libs())
# (this causes XSBar.xs.dll to link to XSQuux.xs.dll)
$ENV{PERL5LIB} = join($Config{path_sep}, @libs, $ENV{PERL5LIB});
diag("FOO PERL5LIB = $ENV{PERL5LIB}"); # XXX

my $cwd = getcwd();
my ($exe, $out, $err);

foreach my $mod (qw(PAR XSQuux XSBar))
foreach my $mod (qw(XSQuux XSBar))
{
diag("build and install $mod");
chdir(catdir($cwd, qw(t data), $mod)) or die "can't chdir to $mod source: $!";
run_ok($^X, "Makefile.PL", "INSTALL_BASE=$base");
run_ok($make);
run_ok($make, "install");
run_ok($make, "clean");
next if $mod eq "PAR"; # XXX
show_tree($base); # XXX
show_dlls($base, $mod); # XXX
# DEBUG show_tree($base);
# DEBUG show_dlls($base, $mod);

}

chdir($cwd) or die "can't chdir back to build dir: $!";

($out, $err) = run_ok($^X, '-E', 'use PAR; print $PAR::VERSION;'); # XXX
is($out, "1.020", "check PAR version"); # XXX

# first round: run code (2 checks)
# first round: run code (2 checks each)
foreach (@checks)
{
diag(qq[running "$_->{code}"...]);
($out, $err) = run_ok($^X, "-e", $_->{code});
is($out, $_->{exp}, "check output");
}

# second round: pack code and run it twice (5 checks)
# second round: pack code and run it twice (5 checks each)
foreach (@checks)
{
diag(qq[packing "$_->{code}"...]);
$exe = pp_ok(-e => $_->{code});
($out, $err) = run_ok($exe);
is($out, $_->{exp}, "check output (first run)");

TODO: {
local $TODO = "rschupp/PAR#11" if $_->{code} =~ /XSBar/;

# run $exe again (with a populated cache directory)
($out, $err) = run_ok($exe);
is($out, $_->{exp}, "check output (second run)");
}
# run $exe again (with a populated cache directory)
($out, $err) = run_ok($exe);
is($out, $_->{exp}, "check output (second run)");
}


# third round: pack code with "--clean" and run it (3 checks each)
foreach (@checks)
{
diag(qq[packing "$_->{code}" with --clean ...]);
$exe = pp_ok("--clean", -e => $_->{code});
($out, $err) = run_ok($exe);
is($out, $_->{exp}, "check output (with --clean)");
}

0 comments on commit 4a4c535

Please sign in to comment.