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

Commit966268c

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 parent608a710 commit966268c

File tree

2 files changed

+68
-34
lines changed

2 files changed

+68
-34
lines changed

‎src/tools/msvc/Install.pm

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -461,16 +461,12 @@ sub CopyContribFiles
461461
opendir($D,$subdir) || croak"Could not opendir on$subdir!\n";
462462
while (my$d =readdir($D))
463463
{
464-
465464
# These configuration-based exclusions must match vcregress.pl
466465
nextif ($deq"uuid-ossp" && !defined($config->{uuid}));
467466
nextif ($deq"sslinfo" && !defined($config->{openssl}));
468467
nextif ($deq"xml2" && !defined($config->{xml}));
469-
nextif ($deq"hstore_plperl" && !defined($config->{perl}));
470-
nextif ($deq"jsonb_plperl" && !defined($config->{perl}));
471-
nextif ($deq"hstore_plpython" && !defined($config->{python}));
472-
nextif ($deq"jsonb_plpython" && !defined($config->{python}));
473-
nextif ($deq"ltree_plpython" && !defined($config->{python}));
468+
nextif ($d =~/_plperl$/ && !defined($config->{perl}));
469+
nextif ($d =~/_plpython$/ && !defined($config->{python}));
474470
nextif ($deq"sepgsql");
475471

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

‎src/tools/msvc/vcregress.pl

Lines changed: 66 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,51 @@ sub taptest
246246
exit$statusif$status;
247247
}
248248

249+
submangle_plpython3
250+
{
251+
my$tests =shift;
252+
mkdir"results"unless-d"results";
253+
mkdir"sql/python3";
254+
mkdir"results/python3";
255+
mkdir"expected/python3";
256+
257+
foreachmy$test (@$tests)
258+
{
259+
local$/ =undef;
260+
foreachmy$dir ('sql','expected')
261+
{
262+
my$extension = ($direq'sql' ?'sql' :'out');
263+
264+
my@files =glob("$dir/$test.$extension$dir/${test}_[0-9].$extension");
265+
foreachmy$file (@files)
266+
{
267+
open(my$handle,"$file") ||die"test file$file not found";
268+
my$contents = <$handle>;
269+
close($handle);
270+
map
271+
{
272+
s/except ([[:alpha:]][[:alpha:].]*), *([[:alpha:]][[:alpha:]]*):/except$1 as$2:/g;
273+
s/<type 'exceptions\.([[:alpha:]]*)'>/<class '$1'>/g;
274+
s/<type 'long'>/<class 'int'>/g;
275+
s/([0-9][0-9]*)L/$1/g;
276+
s/([ [{])u"/$1"/g;
277+
s/([ [{])u'/$1'/g;
278+
s/def next/def __next__/g;
279+
s/LANGUAGE plpython2?u/LANGUAGE plpython3u/g;
280+
s/EXTENSION ([^ ]*_)*plpython2?u/EXTENSION $1plpython3u/g;
281+
s/installing required extension "plpython2u"/installing required extension "plpython3u"/g;
282+
}$contents;
283+
my$base = basename$file;
284+
open($handle,">$dir/python3/$base") ||die"opening python 3 file for$file";
285+
print$handle$contents;
286+
close($handle);
287+
}
288+
}
289+
}
290+
map {$_ =~s!^!python3/!; }@$tests;
291+
return@$tests;
292+
}
293+
249294
subplcheck
250295
{
251296
chdir"$topdir/src/pl";
@@ -268,7 +313,8 @@ sub plcheck
268313
}
269314
if ($langeq'plpython')
270315
{
271-
nextunless-d"$topdir/$Config/plpython2";
316+
nextunless-d"$topdir/$Config/plpython2" ||
317+
-d"$topdir/$Config/plpython3";
272318
$lang ='plpythonu';
273319
}
274320
else
@@ -278,6 +324,8 @@ sub plcheck
278324
my@lang_args = ("--load-extension=$lang");
279325
chdir$dir;
280326
my@tests = fetchTests();
327+
@tests = mangle_plpython3(\@tests)
328+
if$langeq'plpythonu' &&-d"$topdir/$Config/plpython3";
281329
if ($langeq'plperl')
282330
{
283331

@@ -293,6 +341,10 @@ sub plcheck
293341
push(@tests,'plperl_plperlu');
294342
}
295343
}
344+
elsif ($langeq'plpythonu' &&-d"$topdir/$Config/plpython3")
345+
{
346+
@lang_args = ();
347+
}
296348
print
297349
"============================================================\n";
298350
print"Checking$lang\n";
@@ -311,7 +363,6 @@ sub plcheck
311363

312364
subsubdircheck
313365
{
314-
my$subdir =shift;
315366
my$module =shift;
316367

317368
if ( !-d"$module/sql"
@@ -325,44 +376,35 @@ sub subdircheck
325376
my@tests = fetchTests();
326377
my@opts = fetchRegressOpts();
327378

328-
#Add some optionsfor transform modules, see their respective
329-
#Makefile for more details regarding Python-version specific
379+
#Special processingfor python transform modules, see their respective
380+
#Makefiles for more details regarding Python-version specific
330381
# dependencies.
331-
if ($moduleeq"hstore_plpython"
332-
||$moduleeq"jsonb_plpython"
333-
||$moduleeq"ltree_plpython")
382+
if ($module =~/_plpython$/ )
334383
{
335384
die"Python not enabled in configuration"
336385
if !defined($config->{python});
337386

338-
# Attempt to get python version and location.
339-
# Assume python.exe in specified dir.
340-
my$pythonprog ="import sys;" ."print(str(sys.version_info[0]))";
341-
my$prefixcmd =$config->{python} ."\\python -c\"$pythonprog\"";
342-
my$pyver =`$prefixcmd`;
343-
die"Could not query for python version!\n"if$?;
344-
chomp($pyver);
345-
if ($pyvereq"2")
387+
@opts =grep {$_ !~/plpythonu/ }@opts;
388+
389+
if (-d"$topdir/$Config/plpython2")
346390
{
347391
push@opts,"--load-extension=plpythonu";
348392
push@opts,'--load-extension=' .$module .'u';
349393
}
350394
else
351395
{
352-
353-
# disable tests on python3 for now.
354-
chdir"..";
355-
return;
396+
# must be python 3
397+
@tests = mangle_plpython3(\@tests);
356398
}
357399
}
358400

359-
360401
print"============================================================\n";
361402
print"Checking$module\n";
362403
my@args = (
363404
"$topdir/$Config/pg_regress/pg_regress",
364405
"--bindir=${topdir}/${Config}/psql",
365406
"--dbname=contrib_regression",@opts,@tests);
407+
printjoin('',@args),"\n";
366408
system(@args);
367409
chdir"..";
368410
}
@@ -373,19 +415,15 @@ sub contribcheck
373415
my$mstat = 0;
374416
foreachmy$module (glob("*"))
375417
{
376-
377418
# these configuration-based exclusions must match Install.pm
378419
nextif ($moduleeq"uuid-ossp" && !defined($config->{uuid}));
379420
nextif ($moduleeq"sslinfo" && !defined($config->{openssl}));
380421
nextif ($moduleeq"xml2" && !defined($config->{xml}));
381-
nextif ($moduleeq"hstore_plperl" && !defined($config->{perl}));
382-
nextif ($moduleeq"jsonb_plperl" && !defined($config->{perl}));
383-
nextif ($moduleeq"hstore_plpython" && !defined($config->{python}));
384-
nextif ($moduleeq"jsonb_plpython" && !defined($config->{python}));
385-
nextif ($moduleeq"ltree_plpython" && !defined($config->{python}));
422+
nextif ($module =~/_plperl$/ && !defined($config->{perl}));
423+
nextif ($module =~/_plpython$/ && !defined($config->{python}));
386424
nextif ($moduleeq"sepgsql");
387425

388-
subdircheck("$topdir/contrib",$module);
426+
subdircheck($module);
389427
my$status =$? >> 8;
390428
$mstat ||=$status;
391429
}
@@ -398,7 +436,7 @@ sub modulescheck
398436
my$mstat = 0;
399437
foreachmy$module (glob("*"))
400438
{
401-
subdircheck("$topdir/src/test/modules",$module);
439+
subdircheck($module);
402440
my$status =$? >> 8;
403441
$mstat ||=$status;
404442
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp