mirror of
https://github.com/postgres/postgres.git
synced 2025-05-03 22:24:49 +03:00
Provide for testing on python3 modules when under MSVC
This should have been done some years ago as promised in commit c4dcdd0c2. However, better late than never. Along the way do a little housekeeping, including using a simpler test for the python version being tested, and removing a redundant subroutine parameter. These changes only apply back to release 9.5. Backpatch to all live releases.
This commit is contained in:
parent
d03cf45fd9
commit
56a45646d4
@ -458,14 +458,12 @@ sub CopyContribFiles
|
|||||||
opendir($D, $subdir) || croak "Could not opendir on $subdir!\n";
|
opendir($D, $subdir) || croak "Could not opendir on $subdir!\n";
|
||||||
while (my $d = readdir($D))
|
while (my $d = readdir($D))
|
||||||
{
|
{
|
||||||
|
|
||||||
# These configuration-based exclusions must match vcregress.pl
|
# These configuration-based exclusions must match vcregress.pl
|
||||||
next if ($d eq "uuid-ossp" && !defined($config->{uuid}));
|
next if ($d eq "uuid-ossp" && !defined($config->{uuid}));
|
||||||
next if ($d eq "sslinfo" && !defined($config->{openssl}));
|
next if ($d eq "sslinfo" && !defined($config->{openssl}));
|
||||||
next if ($d eq "xml2" && !defined($config->{xml}));
|
next if ($d eq "xml2" && !defined($config->{xml}));
|
||||||
next if ($d eq "hstore_plperl" && !defined($config->{perl}));
|
next if ($d =~ /_plperl$/ && !defined($config->{perl}));
|
||||||
next if ($d eq "hstore_plpython" && !defined($config->{python}));
|
next if ($d =~ /_plpython$/ && !defined($config->{python}));
|
||||||
next if ($d eq "ltree_plpython" && !defined($config->{python}));
|
|
||||||
next if ($d eq "sepgsql");
|
next if ($d eq "sepgsql");
|
||||||
|
|
||||||
CopySubdirFiles($subdir, $d, $config, $target);
|
CopySubdirFiles($subdir, $d, $config, $target);
|
||||||
|
@ -244,6 +244,51 @@ sub taptest
|
|||||||
exit $status if $status;
|
exit $status if $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub mangle_plpython3
|
||||||
|
{
|
||||||
|
my $tests = shift;
|
||||||
|
mkdir "results" unless -d "results";
|
||||||
|
mkdir "sql/python3";
|
||||||
|
mkdir "results/python3";
|
||||||
|
mkdir "expected/python3";
|
||||||
|
|
||||||
|
foreach my $test (@$tests)
|
||||||
|
{
|
||||||
|
local $/ = undef;
|
||||||
|
foreach my $dir ('sql','expected')
|
||||||
|
{
|
||||||
|
my $extension = ($dir eq 'sql' ? 'sql' : 'out');
|
||||||
|
|
||||||
|
my @files = glob("$dir/$test.$extension $dir/${test}_[0-9].$extension");
|
||||||
|
foreach my $file (@files)
|
||||||
|
{
|
||||||
|
open(my $handle, "$file") || die "test file $file not found";
|
||||||
|
my $contents = <$handle>;
|
||||||
|
close($handle);
|
||||||
|
map
|
||||||
|
{
|
||||||
|
s/except ([[:alpha:]][[:alpha:].]*), *([[:alpha:]][[:alpha:]]*):/except $1 as $2:/g;
|
||||||
|
s/<type 'exceptions\.([[:alpha:]]*)'>/<class '$1'>/g;
|
||||||
|
s/<type 'long'>/<class 'int'>/g;
|
||||||
|
s/([0-9][0-9]*)L/$1/g;
|
||||||
|
s/([ [{])u"/$1"/g;
|
||||||
|
s/([ [{])u'/$1'/g;
|
||||||
|
s/def next/def __next__/g;
|
||||||
|
s/LANGUAGE plpython2?u/LANGUAGE plpython3u/g;
|
||||||
|
s/EXTENSION ([^ ]*_)*plpython2?u/EXTENSION $1plpython3u/g;
|
||||||
|
s/installing required extension "plpython2u"/installing required extension "plpython3u"/g;
|
||||||
|
} $contents;
|
||||||
|
my $base = basename $file;
|
||||||
|
open($handle, ">$dir/python3/$base") || die "opening python 3 file for $file";
|
||||||
|
print $handle $contents;
|
||||||
|
close($handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map { $_ =~ s!^!python3/!; } @$tests;
|
||||||
|
return @$tests;
|
||||||
|
}
|
||||||
|
|
||||||
sub plcheck
|
sub plcheck
|
||||||
{
|
{
|
||||||
chdir "../../pl";
|
chdir "../../pl";
|
||||||
@ -254,7 +299,8 @@ sub plcheck
|
|||||||
my $lang = $pl eq 'tcl' ? 'pltcl' : $pl;
|
my $lang = $pl eq 'tcl' ? 'pltcl' : $pl;
|
||||||
if ($lang eq 'plpython')
|
if ($lang eq 'plpython')
|
||||||
{
|
{
|
||||||
next unless -d "../../$Config/plpython2";
|
next unless -d "$topdir/$Config/plpython2" ||
|
||||||
|
-d "$topdir/$Config/plpython3";
|
||||||
$lang = 'plpythonu';
|
$lang = 'plpythonu';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -264,6 +310,8 @@ sub plcheck
|
|||||||
my @lang_args = ("--load-extension=$lang");
|
my @lang_args = ("--load-extension=$lang");
|
||||||
chdir $pl;
|
chdir $pl;
|
||||||
my @tests = fetchTests();
|
my @tests = fetchTests();
|
||||||
|
@tests = mangle_plpython3(\@tests)
|
||||||
|
if $lang eq 'plpythonu' && -d "$topdir/$Config/plpython3";
|
||||||
if ($lang eq 'plperl')
|
if ($lang eq 'plperl')
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -279,6 +327,10 @@ sub plcheck
|
|||||||
push(@tests, 'plperl_plperlu');
|
push(@tests, 'plperl_plperlu');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
elsif ($lang eq 'plpythonu' && -d "$topdir/$Config/plpython3")
|
||||||
|
{
|
||||||
|
@lang_args = ();
|
||||||
|
}
|
||||||
print
|
print
|
||||||
"============================================================\n";
|
"============================================================\n";
|
||||||
print "Checking $lang\n";
|
print "Checking $lang\n";
|
||||||
@ -297,7 +349,6 @@ sub plcheck
|
|||||||
|
|
||||||
sub subdircheck
|
sub subdircheck
|
||||||
{
|
{
|
||||||
my $subdir = shift;
|
|
||||||
my $module = shift;
|
my $module = shift;
|
||||||
|
|
||||||
if ( !-d "$module/sql"
|
if ( !-d "$module/sql"
|
||||||
@ -311,43 +362,35 @@ sub subdircheck
|
|||||||
my @tests = fetchTests();
|
my @tests = fetchTests();
|
||||||
my @opts = fetchRegressOpts();
|
my @opts = fetchRegressOpts();
|
||||||
|
|
||||||
# Add some options for transform modules, see their respective
|
# Special processing for python transform modules, see their respective
|
||||||
# Makefile for more details regarding Python-version specific
|
# Makefiles for more details regarding Python-version specific
|
||||||
# dependencies.
|
# dependencies.
|
||||||
if ( $module eq "hstore_plpython"
|
if ( $module =~ /_plpython$/ )
|
||||||
|| $module eq "ltree_plpython")
|
|
||||||
{
|
{
|
||||||
die "Python not enabled in configuration"
|
die "Python not enabled in configuration"
|
||||||
if !defined($config->{python});
|
if !defined($config->{python});
|
||||||
|
|
||||||
# Attempt to get python version and location.
|
@opts = grep { $_ !~ /plpythonu/ } @opts;
|
||||||
# Assume python.exe in specified dir.
|
|
||||||
my $pythonprog = "import sys;" . "print(str(sys.version_info[0]))";
|
if (-d "$topdir/$Config/plpython2")
|
||||||
my $prefixcmd = $config->{python} . "\\python -c \"$pythonprog\"";
|
|
||||||
my $pyver = `$prefixcmd`;
|
|
||||||
die "Could not query for python version!\n" if $?;
|
|
||||||
chomp($pyver);
|
|
||||||
if ($pyver eq "2")
|
|
||||||
{
|
{
|
||||||
push @opts, "--load-extension=plpythonu";
|
push @opts, "--load-extension=plpythonu";
|
||||||
push @opts, '--load-extension=' . $module . 'u';
|
push @opts, '--load-extension=' . $module . 'u';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
# must be python 3
|
||||||
# disable tests on python3 for now.
|
@tests = mangle_plpython3(\@tests);
|
||||||
chdir "..";
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
print "============================================================\n";
|
print "============================================================\n";
|
||||||
print "Checking $module\n";
|
print "Checking $module\n";
|
||||||
my @args = (
|
my @args = (
|
||||||
"$topdir/$Config/pg_regress/pg_regress",
|
"$topdir/$Config/pg_regress/pg_regress",
|
||||||
"--bindir=${topdir}/${Config}/psql",
|
"--bindir=${topdir}/${Config}/psql",
|
||||||
"--dbname=contrib_regression", @opts, @tests);
|
"--dbname=contrib_regression", @opts, @tests);
|
||||||
|
print join(' ',@args),"\n";
|
||||||
system(@args);
|
system(@args);
|
||||||
chdir "..";
|
chdir "..";
|
||||||
}
|
}
|
||||||
@ -358,17 +401,15 @@ sub contribcheck
|
|||||||
my $mstat = 0;
|
my $mstat = 0;
|
||||||
foreach my $module (glob("*"))
|
foreach my $module (glob("*"))
|
||||||
{
|
{
|
||||||
|
|
||||||
# these configuration-based exclusions must match Install.pm
|
# these configuration-based exclusions must match Install.pm
|
||||||
next if ($module eq "uuid-ossp" && !defined($config->{uuid}));
|
next if ($module eq "uuid-ossp" && !defined($config->{uuid}));
|
||||||
next if ($module eq "sslinfo" && !defined($config->{openssl}));
|
next if ($module eq "sslinfo" && !defined($config->{openssl}));
|
||||||
next if ($module eq "xml2" && !defined($config->{xml}));
|
next if ($module eq "xml2" && !defined($config->{xml}));
|
||||||
next if ($module eq "hstore_plperl" && !defined($config->{perl}));
|
next if ($module =~ /_plperl$/ && !defined($config->{perl}));
|
||||||
next if ($module eq "hstore_plpython" && !defined($config->{python}));
|
next if ($module =~ /_plpython$/ && !defined($config->{python}));
|
||||||
next if ($module eq "ltree_plpython" && !defined($config->{python}));
|
|
||||||
next if ($module eq "sepgsql");
|
next if ($module eq "sepgsql");
|
||||||
|
|
||||||
subdircheck("$topdir/contrib", $module);
|
subdircheck($module);
|
||||||
my $status = $? >> 8;
|
my $status = $? >> 8;
|
||||||
$mstat ||= $status;
|
$mstat ||= $status;
|
||||||
}
|
}
|
||||||
@ -381,7 +422,7 @@ sub modulescheck
|
|||||||
my $mstat = 0;
|
my $mstat = 0;
|
||||||
foreach my $module (glob("*"))
|
foreach my $module (glob("*"))
|
||||||
{
|
{
|
||||||
subdircheck("$topdir/src/test/modules", $module);
|
subdircheck($module);
|
||||||
my $status = $? >> 8;
|
my $status = $? >> 8;
|
||||||
$mstat ||= $status;
|
$mstat ||= $status;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user