Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit56a4564

Browse files
committed
Provide for testing on python3 modules when under MSVC
This should have been done some years ago as promised in commitc4dcdd0. However, better late than never.Along the way do a little housekeeping, including using a simpler testfor the python version being tested, and removing a redundant subroutineparameter. These changes only apply back to release 9.5.Backpatch to all live releases.
1 parentd03cf45 commit56a4564

File tree

2 files changed

+68
-29
lines changed

2 files changed

+68
-29
lines changed

‎src/tools/msvc/Install.pm

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,14 +458,12 @@ sub CopyContribFiles
458458
opendir($D,$subdir) || croak"Could not opendir on$subdir!\n";
459459
while (my$d =readdir($D))
460460
{
461-
462461
# These configuration-based exclusions must match vcregress.pl
463462
nextif ($deq"uuid-ossp" && !defined($config->{uuid}));
464463
nextif ($deq"sslinfo" && !defined($config->{openssl}));
465464
nextif ($deq"xml2" && !defined($config->{xml}));
466-
nextif ($deq"hstore_plperl" && !defined($config->{perl}));
467-
nextif ($deq"hstore_plpython" && !defined($config->{python}));
468-
nextif ($deq"ltree_plpython" && !defined($config->{python}));
465+
nextif ($d =~/_plperl$/ && !defined($config->{perl}));
466+
nextif ($d =~/_plpython$/ && !defined($config->{python}));
469467
nextif ($deq"sepgsql");
470468

471469
CopySubdirFiles($subdir,$d,$config,$target);

‎src/tools/msvc/vcregress.pl

Lines changed: 66 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,51 @@ sub taptest
244244
exit$statusif$status;
245245
}
246246

247+
submangle_plpython3
248+
{
249+
my$tests =shift;
250+
mkdir"results"unless-d"results";
251+
mkdir"sql/python3";
252+
mkdir"results/python3";
253+
mkdir"expected/python3";
254+
255+
foreachmy$test (@$tests)
256+
{
257+
local$/ =undef;
258+
foreachmy$dir ('sql','expected')
259+
{
260+
my$extension = ($direq'sql' ?'sql' :'out');
261+
262+
my@files =glob("$dir/$test.$extension$dir/${test}_[0-9].$extension");
263+
foreachmy$file (@files)
264+
{
265+
open(my$handle,"$file") ||die"test file$file not found";
266+
my$contents = <$handle>;
267+
close($handle);
268+
map
269+
{
270+
s/except ([[:alpha:]][[:alpha:].]*), *([[:alpha:]][[:alpha:]]*):/except$1 as$2:/g;
271+
s/<type 'exceptions\.([[:alpha:]]*)'>/<class '$1'>/g;
272+
s/<type 'long'>/<class 'int'>/g;
273+
s/([0-9][0-9]*)L/$1/g;
274+
s/([ [{])u"/$1"/g;
275+
s/([ [{])u'/$1'/g;
276+
s/def next/def __next__/g;
277+
s/LANGUAGE plpython2?u/LANGUAGE plpython3u/g;
278+
s/EXTENSION ([^ ]*_)*plpython2?u/EXTENSION $1plpython3u/g;
279+
s/installing required extension "plpython2u"/installing required extension "plpython3u"/g;
280+
}$contents;
281+
my$base = basename$file;
282+
open($handle,">$dir/python3/$base") ||die"opening python 3 file for$file";
283+
print$handle$contents;
284+
close($handle);
285+
}
286+
}
287+
}
288+
map {$_ =~s!^!python3/!; }@$tests;
289+
return@$tests;
290+
}
291+
247292
subplcheck
248293
{
249294
chdir"../../pl";
@@ -254,7 +299,8 @@ sub plcheck
254299
my$lang =$pleq'tcl' ?'pltcl' :$pl;
255300
if ($langeq'plpython')
256301
{
257-
nextunless-d"../../$Config/plpython2";
302+
nextunless-d"$topdir/$Config/plpython2" ||
303+
-d"$topdir/$Config/plpython3";
258304
$lang ='plpythonu';
259305
}
260306
else
@@ -264,6 +310,8 @@ sub plcheck
264310
my@lang_args = ("--load-extension=$lang");
265311
chdir$pl;
266312
my@tests = fetchTests();
313+
@tests = mangle_plpython3(\@tests)
314+
if$langeq'plpythonu' &&-d"$topdir/$Config/plpython3";
267315
if ($langeq'plperl')
268316
{
269317

@@ -279,6 +327,10 @@ sub plcheck
279327
push(@tests,'plperl_plperlu');
280328
}
281329
}
330+
elsif ($langeq'plpythonu' &&-d"$topdir/$Config/plpython3")
331+
{
332+
@lang_args = ();
333+
}
282334
print
283335
"============================================================\n";
284336
print"Checking$lang\n";
@@ -297,7 +349,6 @@ sub plcheck
297349

298350
subsubdircheck
299351
{
300-
my$subdir =shift;
301352
my$module =shift;
302353

303354
if ( !-d"$module/sql"
@@ -311,43 +362,35 @@ sub subdircheck
311362
my@tests = fetchTests();
312363
my@opts = fetchRegressOpts();
313364

314-
#Add some optionsfor transform modules, see their respective
315-
#Makefile for more details regarding Python-version specific
365+
#Special processingfor python transform modules, see their respective
366+
#Makefiles for more details regarding Python-version specific
316367
# dependencies.
317-
if ($moduleeq"hstore_plpython"
318-
||$moduleeq"ltree_plpython")
368+
if ($module =~/_plpython$/ )
319369
{
320370
die"Python not enabled in configuration"
321371
if !defined($config->{python});
322372

323-
# Attempt to get python version and location.
324-
# Assume python.exe in specified dir.
325-
my$pythonprog ="import sys;" ."print(str(sys.version_info[0]))";
326-
my$prefixcmd =$config->{python} ."\\python -c\"$pythonprog\"";
327-
my$pyver =`$prefixcmd`;
328-
die"Could not query for python version!\n"if$?;
329-
chomp($pyver);
330-
if ($pyvereq"2")
373+
@opts =grep {$_ !~/plpythonu/ }@opts;
374+
375+
if (-d"$topdir/$Config/plpython2")
331376
{
332377
push@opts,"--load-extension=plpythonu";
333378
push@opts,'--load-extension=' .$module .'u';
334379
}
335380
else
336381
{
337-
338-
# disable tests on python3 for now.
339-
chdir"..";
340-
return;
382+
# must be python 3
383+
@tests = mangle_plpython3(\@tests);
341384
}
342385
}
343386

344-
345387
print"============================================================\n";
346388
print"Checking$module\n";
347389
my@args = (
348390
"$topdir/$Config/pg_regress/pg_regress",
349391
"--bindir=${topdir}/${Config}/psql",
350392
"--dbname=contrib_regression",@opts,@tests);
393+
printjoin('',@args),"\n";
351394
system(@args);
352395
chdir"..";
353396
}
@@ -358,17 +401,15 @@ sub contribcheck
358401
my$mstat = 0;
359402
foreachmy$module (glob("*"))
360403
{
361-
362404
# these configuration-based exclusions must match Install.pm
363405
nextif ($moduleeq"uuid-ossp" && !defined($config->{uuid}));
364406
nextif ($moduleeq"sslinfo" && !defined($config->{openssl}));
365407
nextif ($moduleeq"xml2" && !defined($config->{xml}));
366-
nextif ($moduleeq"hstore_plperl" && !defined($config->{perl}));
367-
nextif ($moduleeq"hstore_plpython" && !defined($config->{python}));
368-
nextif ($moduleeq"ltree_plpython" && !defined($config->{python}));
408+
nextif ($module =~/_plperl$/ && !defined($config->{perl}));
409+
nextif ($module =~/_plpython$/ && !defined($config->{python}));
369410
nextif ($moduleeq"sepgsql");
370411

371-
subdircheck("$topdir/contrib",$module);
412+
subdircheck($module);
372413
my$status =$? >> 8;
373414
$mstat ||=$status;
374415
}
@@ -381,7 +422,7 @@ sub modulescheck
381422
my$mstat = 0;
382423
foreachmy$module (glob("*"))
383424
{
384-
subdircheck("$topdir/src/test/modules",$module);
425+
subdircheck($module);
385426
my$status =$? >> 8;
386427
$mstat ||=$status;
387428
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp