diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl index 2904679..43d5d76 100644 --- a/src/tools/msvc/vcregress.pl +++ b/src/tools/msvc/vcregress.pl @@ -244,6 +244,53 @@ sub taptest 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///g; + s///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 { chdir "../../pl"; @@ -254,7 +301,8 @@ sub plcheck my $lang = $pl eq 'tcl' ? 'pltcl' : $pl; if ($lang eq 'plpython') { - next unless -d "../../$Config/plpython2"; + next unless -d "$topdir/$Config/plpython2" || + -d "$topdir/$Config/plpython3"; $lang = 'plpythonu'; } else @@ -264,6 +312,8 @@ sub plcheck my @lang_args = ("--load-extension=$lang"); chdir $pl; my @tests = fetchTests(); + @tests = mangle_plpython3(\@tests) + if $lang eq 'plpythonu' && -d "$topdir/$Config/plpython3"; if ($lang eq 'plperl') { @@ -279,6 +329,10 @@ sub plcheck push(@tests, 'plperl_plperlu'); } } + elsif ($lang eq 'plpythonu' && -d "$topdir/$Config/plpython3") + { + @lang_args = (); + } print "============================================================\n"; print "Checking $lang\n"; @@ -320,6 +374,8 @@ sub subdircheck die "Python not enabled in configuration" if !defined($config->{python}); + @opts = grep { $_ !~ /plpythonu/ } @opts; + # Attempt to get python version and location. # Assume python.exe in specified dir. my $pythonprog = "import sys;" . "print(str(sys.version_info[0]))"; @@ -334,10 +390,7 @@ sub subdircheck } else { - - # disable tests on python3 for now. - chdir ".."; - return; + @tests = mangle_plpython3(\@tests); } } @@ -348,6 +401,7 @@ sub subdircheck "$topdir/$Config/pg_regress/pg_regress", "--bindir=${topdir}/${Config}/psql", "--dbname=contrib_regression", @opts, @tests); + print join(' ',@args),"\n"; system(@args); chdir ".."; } @@ -363,9 +417,8 @@ sub contribcheck next if ($module eq "uuid-ossp" && !defined($config->{uuid})); next if ($module eq "sslinfo" && !defined($config->{openssl})); next if ($module eq "xml2" && !defined($config->{xml})); - next if ($module eq "hstore_plperl" && !defined($config->{perl})); - next if ($module eq "hstore_plpython" && !defined($config->{python})); - next if ($module eq "ltree_plpython" && !defined($config->{python})); + next if ($module =~ /_plperl$/ && !defined($config->{perl})); + next if ($module =~ /_plpython$/ && !defined($config->{python})); next if ($module eq "sepgsql"); subdircheck("$topdir/contrib", $module);