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

Commitc53e288

Browse files
committed
Skip psql's TAP test for query cancellation entirely on Windows
This changes 020_cancel.pl so as the test is entirely skipped onWindows. This test was already doing nothing under WIN32, exceptinitializing and starting a node without using it so this shaves a fewtest cycles.Author: Yugo NAGATAReviewed-by: Fabien CoelhoDiscussion:https://postgr.es/m/20230810125935.22c2922ea5250ba79358965b@sraoss.co.jpBackpatch-through: 15
1 parente434e21 commitc53e288

File tree

1 file changed

+59
-59
lines changed

1 file changed

+59
-59
lines changed

‎src/bin/psql/t/020_cancel.pl

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -9,72 +9,72 @@
99
use Test::More;
1010
use Time::HiResqw(usleep);
1111

12-
my$tempdir = PostgreSQL::Test::Utils::tempdir;
13-
14-
my$node = PostgreSQL::Test::Cluster->new('main');
15-
$node->init;
16-
$node->start;
17-
1812
# Test query canceling by sending SIGINT to a running psql
1913
#
2014
# There is, as of this writing, no documented way to get the PID of
2115
# the process from IPC::Run. As a workaround, we have psql print its
2216
# own PID (which is the parent of the shell launched by psql) to a
2317
# file.
24-
SKIP:
18+
if ($windows_os)
2519
{
26-
skip"cancel test requires a Unix shell", 2if$windows_os;
27-
28-
local%ENV =$node->_get_env();
29-
30-
my ($stdin,$stdout,$stderr);
31-
32-
# Test whether shell supports $PPID. It's part of POSIX, but some
33-
# pre-/non-POSIX shells don't support it (e.g., NetBSD).
34-
$stdin ="\\! echo\$PPID";
35-
IPC::Run::run(['psql','-X','-v','ON_ERROR_STOP=1' ],
36-
'<', \$stdin,'>', \$stdout,'2>', \$stderr);
37-
$stdout =~/^\d+$/or skip"shell apparently does not support\$PPID", 2;
38-
39-
# Now start the real test
40-
my$h = IPC::Run::start(['psql','-X','-v','ON_ERROR_STOP=1' ],
41-
\$stdin, \$stdout, \$stderr);
42-
43-
# Get the PID
44-
$stdout ='';
45-
$stderr ='';
46-
$stdin ="\\! echo\$PPID >$tempdir/psql.pid\n";
47-
pump$hwhilelength$stdin;
48-
my$count;
49-
my$psql_pid;
50-
until (
51-
-s"$tempdir/psql.pid"
52-
and ($psql_pid =
53-
PostgreSQL::Test::Utils::slurp_file("$tempdir/psql.pid")) =~
54-
/^\d+\n/s)
55-
{
56-
($count++ < 100 *$PostgreSQL::Test::Utils::timeout_default)
57-
ordie"pid file did not appear";
58-
usleep(10_000);
59-
}
60-
61-
# Send sleep command and wait until the server has registered it
62-
$stdin ="select pg_sleep($PostgreSQL::Test::Utils::timeout_default);\n";
63-
pump$hwhilelength$stdin;
64-
$node->poll_query_until('postgres',
65-
q{SELECT (SELECT count(*) FROM pg_stat_activity WHERE query ~ '^select pg_sleep') > 0;}
66-
)ordie"timed out";
67-
68-
# Send cancel request
69-
kill'INT',$psql_pid;
70-
71-
my$result = finish$h;
72-
73-
ok(!$result,'query failed as expected');
74-
like(
75-
$stderr,
76-
qr/canceling statement due to user request/,
77-
'query was canceled');
20+
planskip_all=>"cancel test requires a Unix shell";
7821
}
7922

23+
my$tempdir = PostgreSQL::Test::Utils::tempdir;
24+
25+
my$node = PostgreSQL::Test::Cluster->new('main');
26+
$node->init;
27+
$node->start;
28+
29+
local%ENV =$node->_get_env();
30+
31+
my ($stdin,$stdout,$stderr);
32+
33+
# Test whether shell supports $PPID. It's part of POSIX, but some
34+
# pre-/non-POSIX shells don't support it (e.g., NetBSD).
35+
$stdin ="\\! echo\$PPID";
36+
IPC::Run::run(['psql','-X','-v','ON_ERROR_STOP=1' ],
37+
'<', \$stdin,'>', \$stdout,'2>', \$stderr);
38+
$stdout =~/^\d+$/or skip"shell apparently does not support\$PPID", 2;
39+
40+
# Now start the real test
41+
my$h = IPC::Run::start(['psql','-X','-v','ON_ERROR_STOP=1' ],
42+
\$stdin, \$stdout, \$stderr);
43+
44+
# Get the PID
45+
$stdout ='';
46+
$stderr ='';
47+
$stdin ="\\! echo\$PPID >$tempdir/psql.pid\n";
48+
pump$hwhilelength$stdin;
49+
my$count;
50+
my$psql_pid;
51+
until (
52+
-s"$tempdir/psql.pid"
53+
and
54+
($psql_pid = PostgreSQL::Test::Utils::slurp_file("$tempdir/psql.pid"))
55+
=~/^\d+\n/s)
56+
{
57+
($count++ < 100 *$PostgreSQL::Test::Utils::timeout_default)
58+
ordie"pid file did not appear";
59+
usleep(10_000);
60+
}
61+
62+
# Send sleep command and wait until the server has registered it
63+
$stdin ="select pg_sleep($PostgreSQL::Test::Utils::timeout_default);\n";
64+
pump$hwhilelength$stdin;
65+
$node->poll_query_until('postgres',
66+
q{SELECT (SELECT count(*) FROM pg_stat_activity WHERE query ~ '^select pg_sleep') > 0;}
67+
)ordie"timed out";
68+
69+
# Send cancel request
70+
kill'INT',$psql_pid;
71+
72+
my$result = finish$h;
73+
74+
ok(!$result,'query failed as expected');
75+
like(
76+
$stderr,
77+
qr/canceling statement due to user request/,
78+
'query was canceled');
79+
8080
done_testing();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp