Skip to content

Commit af39c1d

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 594ff3d commit af39c1d

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
@@ -161,6 +161,51 @@ sub isolationcheck
161161
exit $status if $status;
162162
}
163163

164+
sub mangle_plpython3
165+
{
166+
my $tests = shift;
167+
mkdir "results" unless -d "results";
168+
mkdir "sql/python3";
169+
mkdir "results/python3";
170+
mkdir "expected/python3";
171+
172+
foreach my $test (@$tests)
173+
{
174+
local $/ = undef;
175+
foreach my $dir ('sql','expected')
176+
{
177+
my $extension = ($dir eq 'sql' ? 'sql' : 'out');
178+
179+
my @files = glob("$dir/$test.$extension $dir/${test}_[0-9].$extension");
180+
foreach my $file (@files)
181+
{
182+
open(my $handle, "$file") || die "test file $file not found";
183+
my $contents = <$handle>;
184+
close($handle);
185+
map
186+
{
187+
s/except ([[:alpha:]][[:alpha:].]*), *([[:alpha:]][[:alpha:]]*):/except $1 as $2:/g;
188+
s/<type 'exceptions\.([[:alpha:]]*)'>/<class '$1'>/g;
189+
s/<type 'long'>/<class 'int'>/g;
190+
s/([0-9][0-9]*)L/$1/g;
191+
s/([ [{])u"/$1"/g;
192+
s/([ [{])u'/$1'/g;
193+
s/def next/def __next__/g;
194+
s/LANGUAGE plpython2?u/LANGUAGE plpython3u/g;
195+
s/EXTENSION ([^ ]*_)*plpython2?u/EXTENSION $1plpython3u/g;
196+
s/installing required extension "plpython2u"/installing required extension "plpython3u"/g;
197+
} $contents;
198+
my $base = basename $file;
199+
open($handle, ">$dir/python3/$base") || die "opening python 3 file for $file";
200+
print $handle $contents;
201+
close($handle);
202+
}
203+
}
204+
}
205+
map { $_ =~ s!^!python3/!; } @$tests;
206+
return @$tests;
207+
}
208+
164209
sub plcheck
165210
{
166211
chdir "../../pl";
@@ -171,7 +216,8 @@ sub plcheck
171216
my $lang = $pl eq 'tcl' ? 'pltcl' : $pl;
172217
if ($lang eq 'plpython')
173218
{
174-
next unless -d "../../$Config/plpython2";
219+
next unless -d "$topdir/$Config/plpython2" ||
220+
-d "$topdir/$Config/plpython3";
175221
$lang = 'plpythonu';
176222
}
177223
else
@@ -181,6 +227,8 @@ sub plcheck
181227
my @lang_args = ("--load-extension=$lang");
182228
chdir $pl;
183229
my @tests = fetchTests();
230+
@tests = mangle_plpython3(\@tests)
231+
if $lang eq 'plpythonu' && -d "$topdir/$Config/plpython3";
184232
if ($lang eq 'plperl')
185233
{
186234

@@ -196,6 +244,10 @@ sub plcheck
196244
push(@tests, 'plperl_plperlu');
197245
}
198246
}
247+
elsif ($lang eq 'plpythonu' && -d "$topdir/$Config/plpython3")
248+
{
249+
@lang_args = ();
250+
}
199251
print
200252
"============================================================\n";
201253
print "Checking $lang\n";

0 commit comments

Comments
 (0)