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

Commita9fbf55

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 parent679b074 commita9fbf55

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
@@ -243,6 +243,51 @@ sub taptest
243243
exit$statusif$status;
244244
}
245245

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

@@ -278,6 +326,10 @@ sub plcheck
278326
push(@tests,'plperl_plperlu');
279327
}
280328
}
329+
elsif ($langeq'plpythonu' &&-d"$topdir/$Config/plpython3")
330+
{
331+
@lang_args = ();
332+
}
281333
print
282334
"============================================================\n";
283335
print"Checking$lang\n";
@@ -296,7 +348,6 @@ sub plcheck
296348

297349
subsubdircheck
298350
{
299-
my$subdir =shift;
300351
my$module =shift;
301352

302353
if ( !-d"$module/sql"
@@ -310,43 +361,35 @@ sub subdircheck
310361
my@tests = fetchTests();
311362
my@opts = fetchRegressOpts();
312363

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

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

343-
344386
print"============================================================\n";
345387
print"Checking$module\n";
346388
my@args = (
347389
"$topdir/$Config/pg_regress/pg_regress",
348390
"--bindir=${topdir}/${Config}/psql",
349391
"--dbname=contrib_regression",@opts,@tests);
392+
printjoin('',@args),"\n";
350393
system(@args);
351394
chdir"..";
352395
}
@@ -357,17 +400,15 @@ sub contribcheck
357400
my$mstat = 0;
358401
foreachmy$module (glob("*"))
359402
{
360-
361403
# these configuration-based exclusions must match Install.pm
362404
nextif ($moduleeq"uuid-ossp" && !defined($config->{uuid}));
363405
nextif ($moduleeq"sslinfo" && !defined($config->{openssl}));
364406
nextif ($moduleeq"xml2" && !defined($config->{xml}));
365-
nextif ($moduleeq"hstore_plperl" && !defined($config->{perl}));
366-
nextif ($moduleeq"hstore_plpython" && !defined($config->{python}));
367-
nextif ($moduleeq"ltree_plpython" && !defined($config->{python}));
407+
nextif ($module =~/_plperl$/ && !defined($config->{perl}));
408+
nextif ($module =~/_plpython$/ && !defined($config->{python}));
368409
nextif ($moduleeq"sepgsql");
369410

370-
subdircheck("$topdir/contrib",$module);
411+
subdircheck($module);
371412
my$status =$? >> 8;
372413
$mstat ||=$status;
373414
}
@@ -380,7 +421,7 @@ sub modulescheck
380421
my$mstat = 0;
381422
foreachmy$module (glob("*"))
382423
{
383-
subdircheck("$topdir/src/test/modules",$module);
424+
subdircheck($module);
384425
my$status =$? >> 8;
385426
$mstat ||=$status;
386427
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp