Skip to content

Commit 134db37

Browse files
committed
Provide for testing on python3 modules when under MSVC
This should have been done some years ago as promised in commit c4dcdd0. 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.
1 parent ade3b27 commit 134db37

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

src/tools/msvc/vcregress.pl

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,51 @@ sub taptest
240240
exit $status if $status;
241241
}
242242

243+
sub mangle_plpython3
244+
{
245+
my $tests = shift;
246+
mkdir "results" unless -d "results";
247+
mkdir "sql/python3";
248+
mkdir "results/python3";
249+
mkdir "expected/python3";
250+
251+
foreach my $test (@$tests)
252+
{
253+
local $/ = undef;
254+
foreach my $dir ('sql','expected')
255+
{
256+
my $extension = ($dir eq 'sql' ? 'sql' : 'out');
257+
258+
my @files = glob("$dir/$test.$extension $dir/${test}_[0-9].$extension");
259+
foreach my $file (@files)
260+
{
261+
open(my $handle, "$file") || die "test file $file not found";
262+
my $contents = <$handle>;
263+
close($handle);
264+
map
265+
{
266+
s/except ([[:alpha:]][[:alpha:].]*), *([[:alpha:]][[:alpha:]]*):/except $1 as $2:/g;
267+
s/<type 'exceptions\.([[:alpha:]]*)'>/<class '$1'>/g;
268+
s/<type 'long'>/<class 'int'>/g;
269+
s/([0-9][0-9]*)L/$1/g;
270+
s/([ [{])u"/$1"/g;
271+
s/([ [{])u'/$1'/g;
272+
s/def next/def __next__/g;
273+
s/LANGUAGE plpython2?u/LANGUAGE plpython3u/g;
274+
s/EXTENSION ([^ ]*_)*plpython2?u/EXTENSION $1plpython3u/g;
275+
s/installing required extension "plpython2u"/installing required extension "plpython3u"/g;
276+
} $contents;
277+
my $base = basename $file;
278+
open($handle, ">$dir/python3/$base") || die "opening python 3 file for $file";
279+
print $handle $contents;
280+
close($handle);
281+
}
282+
}
283+
}
284+
map { $_ =~ s!^!python3/!; } @$tests;
285+
return @$tests;
286+
}
287+
243288
sub plcheck
244289
{
245290
chdir "../../pl";
@@ -250,7 +295,8 @@ sub plcheck
250295
my $lang = $pl eq 'tcl' ? 'pltcl' : $pl;
251296
if ($lang eq 'plpython')
252297
{
253-
next unless -d "../../$Config/plpython2";
298+
next unless -d "$topdir/$Config/plpython2" ||
299+
-d "$topdir/$Config/plpython3";
254300
$lang = 'plpythonu';
255301
}
256302
else
@@ -260,6 +306,8 @@ sub plcheck
260306
my @lang_args = ("--load-extension=$lang");
261307
chdir $pl;
262308
my @tests = fetchTests();
309+
@tests = mangle_plpython3(\@tests)
310+
if $lang eq 'plpythonu' && -d "$topdir/$Config/plpython3";
263311
if ($lang eq 'plperl')
264312
{
265313

@@ -275,6 +323,10 @@ sub plcheck
275323
push(@tests, 'plperl_plperlu');
276324
}
277325
}
326+
elsif ($lang eq 'plpythonu' && -d "$topdir/$Config/plpython3")
327+
{
328+
@lang_args = ();
329+
}
278330
print
279331
"============================================================\n";
280332
print "Checking $lang\n";

0 commit comments

Comments
 (0)