Skip to content

Commit 4932c63

Browse files
committed
Update Perforce integration tests to log progresses
1 parent a8fb2cb commit 4932c63

3 files changed

Lines changed: 73 additions & 51 deletions

File tree

Test/Perforce/PerforceTest.pm

Lines changed: 50 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ BEGIN {
1212

1313
sub PerforceIntegrationTests
1414
{
15-
$dir = $_[0];
16-
$p4port = $_[1];
17-
$option = $_[2];
18-
$filter = $_[3];
15+
$suite = $_[0];
16+
$dir = $_[1];
17+
$p4port = $_[2];
18+
$option = $_[3];
19+
$filter = $_[4];
1920
$mfa = index($dir, "MultiFactorAuthentication") > -1;
2021
$devnull = "> /dev/null 2>&1";
2122

@@ -25,11 +26,11 @@ sub PerforceIntegrationTests
2526
if ($filter ne ""
2627
&& index($filter, $dir) == -1)
2728
{
28-
print "Not Running Perforce Integration Tests in dir:'",$dir,"' p4port:'",$p4port,"' (Not included in filter).\n";
29-
return 0;
29+
print "\n[$suite] '",$dir,"' Perforce Integration Tests Ignored (p4port:'",$p4port,"') (Not included in filter).\n";
30+
return 0;
3031
}
3132

32-
print "Running Perforce Integration Tests in dir:'",$dir,"' p4port:'",$p4port,"'\n";
33+
print "\n\n[$suite] '",$dir,"' Perforce Integration Tests Running (p4port:'",$p4port,"')\n";
3334

3435
rmtree("Test/tmp");
3536
mkdir "Test/tmp";
@@ -44,7 +45,7 @@ sub PerforceIntegrationTests
4445
$ENV{'P4CHARSET'} = 'utf8';
4546
$ENV{'VCS_P4PASSWD'} = 'Secret';
4647
$ENV{'P4EXECABS'} = getcwd() . "/" . $ENV{'P4EXEC'};
47-
48+
4849
if ($ENV{'TARGET'} eq "win32")
4950
{
5051
$ENV{'VCS_P4ROOT'} =~ s/\//\\/g;
@@ -73,7 +74,7 @@ sub PerforceIntegrationTests
7374
# print "Press ENTER to continue...";
7475
# <STDIN>;
7576

76-
$exitCode = RunTests($dir, $option, $filter);
77+
$exitCode = RunTests($suite, $dir, $option, $filter);
7778

7879
# print "Press ENTER to continue...";
7980
# <STDIN>;
@@ -85,34 +86,40 @@ sub PerforceIntegrationTests
8586

8687
sub RunTests()
8788
{
88-
$dir = $_[0];
89-
$option = $_[1];
90-
$filter = $_[2];
89+
$suite = $_[0];
90+
$dir = $_[1];
91+
$option = $_[2];
92+
$filter = $_[3];
9193

9294
@files = <Test/$dir/*.txt>;
9395

94-
$total = 0;
96+
$total = @files;
97+
$count = 0;
9598
$success = 0;
99+
$failed = 0;
100+
$ignored = 0;
96101

97102
$pluginexec = abs_path($ENV{'P4PLUGIN'});
98103
$testserver = abs_path($ENV{'TESTSERVER'});
99104
$clientroot = $ENV{'VCS_P4CLIENTROOT'};
100105

101106
if (not(-e -f -x $testserver))
102107
{
103-
print "Error testserver '$testserver' doesn't exist\n";
104-
return 1;
108+
print "\n[$suite][$count/$total] Error testserver '$testserver' doesn't exist\n\n";
109+
return $total;
105110
}
106111

107112
$cwd = getcwd();
108113
foreach $i (@files) {
109-
if ($filter ne ""
114+
$count++;
115+
if ($filter ne ""
110116
&& index($i, $filter) == -1)
111117
{
112-
print "Not running Perforce Integration Tests in file:'",$i,"' p4port:'",$p4port,"'\n";
118+
$ignored++;
119+
print "\n[$suite][$count/$total] '",$i,"' Ignored (p4port:'",$p4port,"')\n";
113120
next;
114121
}
115-
print "Running Perforce Integration Tests in file:'",$i,"' p4port:'",$p4port,"'\n";
122+
print "\n[$suite][$count/$total] '",$i,"' Running (p4port:'",$p4port,"')\n";
116123
chdir $cwd;
117124
rmtree( $clientroot, {keep_root => 1} );
118125
print "Changing working directory to: '", $clientroot,"'\n";
@@ -129,21 +136,29 @@ sub RunTests()
129136
}
130137
elsif ($? == -1)
131138
{
132-
print "Error running test '$i' : $!\n";
139+
print "\n[$suite][$count/$total] '",$i,"' Error running test: $!\n\n";
133140
chdir $cwd;
134141
return 1;
135142
}
136143
else
137144
{
138-
print "Test failed -> stopping all tests\n";
139-
chdir $cwd;
140-
return 1;
145+
print "\n[$suite][$count/$total] '",$i,"' Failed (p4port:'",$p4port,"')\n\n";
146+
$failed++;
141147
}
142-
$total++;
143148
RemoveExclusiveFile();
144149
}
145-
print "Done: $success of $total tests passed.\n";
146150
chdir $cwd;
151+
if ($ignored > 0)
152+
{
153+
print "[$suite] $ignored of $total tests ignored.\n";
154+
}
155+
if ($failed > 0)
156+
{
157+
print "[$suite] Failed: $failed of $total tests failed.\n";
158+
print "[$suite] $success of $total tests passed.\n";
159+
return $failed;
160+
}
161+
print "[$suite] Success: $success of $total tests passed.\n";
147162
return 0;
148163
}
149164

@@ -160,7 +175,7 @@ sub AddExclusiveFile
160175
open(FH, '>', 'Assets/exclusivefile.txt') or die $!;
161176
print(FH 'File with exclusive open file type modifier.');
162177
close(FH) or die $1;
163-
178+
164179
RunCommand('add -t text+l Assets/exclusivefile.txt');
165180
RunCommand('submit -d "Add Assets/exclusivefile.txt." Assets/exclusivefile.txt');
166181
}
@@ -173,7 +188,7 @@ sub RemoveExclusiveFile
173188

174189
sub SetupServer
175190
{
176-
$root = $ENV{'VCS_P4ROOT'};
191+
$root = $ENV{'VCS_P4ROOT'};
177192
my $p4port = $ENV{'VCS_P4PORT'};
178193
print "Setting server in '$root' listening on port '$p4port'\n";
179194
rmtree($root);
@@ -190,6 +205,7 @@ sub SetupServer
190205
}
191206

192207
my $p4d = $ENV{'P4DEXEC'};
208+
print "Starting server '$p4d'\n";
193209
system("$p4d -xi -r \"$root\"");
194210
my $pidfile = getcwd() . "/server.pid";
195211
my $pid = SpawnSubProcess($p4d, " -r \"$root\" -p $p4port --pid-file=$pidfile");
@@ -288,9 +304,9 @@ Update: 2022/07/20 11:40:48
288304
289305
Access: 2022/07/20 11:40:48
290306
291-
FullName: Multi Factor Authentication
307+
FullName: Multi Factor Authentication
292308
293-
Password: ******
309+
Password: ******
294310
295311
AuthMethod: perforce+2fa
296312
EOF
@@ -313,9 +329,9 @@ sub SetupMFATriggers
313329
$TRIGGERS =<<EOF;
314330
315331
Triggers:
316-
test-pre-2fa auth-pre-2fa auth "$mfa_script -t pre-2fa -e %quote%%email%%quote% -u %user% -h %host%"
317-
test-init-2fa auth-init-2fa auth "$mfa_script -t init-2fa -e %quote%%email%%quote% -u %user% -h %host% -m %method%"
318-
test-check-2fa auth-check-2fa auth "$mfa_script -t check-2fa -e %quote%%email%%quote% -u %user% -h %host% -s %scheme% -k %token%"
332+
test-pre-2fa auth-pre-2fa auth "$mfa_script -t pre-2fa -e %quote%%email%%quote% -u %user% -h %host%"
333+
test-init-2fa auth-init-2fa auth "$mfa_script -t init-2fa -e %quote%%email%%quote% -u %user% -h %host% -m %method%"
334+
test-check-2fa auth-check-2fa auth "$mfa_script -t check-2fa -e %quote%%email%%quote% -u %user% -h %host% -s %scheme% -k %token%"
319335
EOF
320336

321337
open(FD, "| $ENV{'P4EXEC'} -p $ENV{'VCS_P4PORT'} -u mfa_test_user -P Mfau1111 triggers -i ");
@@ -341,7 +357,7 @@ Update:2013/02/19 09:13:18
341357
Access:2013/06/24 12:38:18
342358
343359
Description:
344-
Created by $ENV{'VCS_P4USER'}.
360+
Created by $ENV{'VCS_P4USER'}.
345361
346362
Root:$root
347363
@@ -352,8 +368,8 @@ SubmitOptions:submitunchanged
352368
LineEnd:local
353369
354370
View:
355-
//depot/... //$ENV{'VCS_P4CLIENT'}/...
356-
-//depot/Assets/excludedfile.txt //$ENV{'VCS_P4CLIENT'}/Assets/excludedfile.txt
371+
//depot/... //$ENV{'VCS_P4CLIENT'}/...
372+
-//depot/Assets/excludedfile.txt //$ENV{'VCS_P4CLIENT'}/Assets/excludedfile.txt
357373
EOF
358374

359375
open(FD, "| $ENV{'P4EXEC'} -p $ENV{'VCS_P4PORT'} -u vcs_test_user client -i ");

Test/VCSTest.pm

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@ use PerforceTest;
33

44
sub IntegrationTest
55
{
6-
$exitCode = PerforceIntegrationTests(@_);
7-
if ($exitCode != 0)
8-
{
9-
exit $exitCode;
10-
}
6+
$failed = PerforceIntegrationTests(@_);
7+
return $failed;
118
}
129

1310
1;

build.pl

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,29 @@
9696

9797
sub TestPerforce()
9898
{
99-
IntegrationTest("Plugin", "localhost:1667", $testoption, $filter);
100-
IntegrationTest("Plugin", "ssl:localhost:1667", $testoption, $filter);
101-
IntegrationTest("Perforce/Common", "localhost:1667", $testoption, $filter);
102-
IntegrationTest("Perforce/Common", "ssl:localhost:1667", $testoption, $filter);
103-
IntegrationTest("Perforce/BaseIPv4", "tcp4:localhost:1667", $testoption, $filter);
104-
IntegrationTest("Perforce/SecureBaseIPv4", "ssl4:localhost:1667", $testoption, $filter);
105-
IntegrationTest("Perforce/SquareBracketIPv4", "tcp4:[localhost]:1667", $testoption, $filter);
99+
my $failed = 0;
100+
$failed += IntegrationTest("1-7", "Plugin", "localhost:1667", $testoption, $filter);
101+
$failed += IntegrationTest("2-7", "Plugin", "ssl:localhost:1667", $testoption, $filter);
102+
$failed += IntegrationTest("3-7", "Perforce/Common", "localhost:1667", $testoption, $filter);
103+
$failed += IntegrationTest("4-7", "Perforce/Common", "ssl:localhost:1667", $testoption, $filter);
104+
$failed += IntegrationTest("5-7", "Perforce/BaseIPv4", "tcp4:localhost:1667", $testoption, $filter);
105+
$failed += IntegrationTest("6-7", "Perforce/SecureBaseIPv4", "ssl4:localhost:1667", $testoption, $filter);
106+
$failed += IntegrationTest("7-7", "Perforce/SquareBracketIPv4", "tcp4:[localhost]:1667", $testoption, $filter);
106107
# Only works if DNS routes via IPv6
107-
# IntegrationTest("Perforce/BaseIPv6", "tcp6:[localhost]:1667", $testoption, $filter);
108+
# $failed += IntegrationTest("9-7", "Perforce/BaseIPv6", "tcp6:[localhost]:1667", $testoption, $filter);
108109
# Does not work in new version of Perforce server
109-
# IntegrationTest("Perforce/SquareBracketIPv6", "tcp6:[::1]:1667", $testoption, $filter);
110-
# IntegrationTest("Perforce/SecureSquareBracketIPv6", "ssl6:[::1]:1667", $testoption, $filter);
111-
IntegrationTest("Perforce/MultiFactorAuthentication", "localhost:1667", $testoption, $filter);
110+
# $failed += IntegrationTest("10-7", "Perforce/SquareBracketIPv6", "tcp6:[::1]:1667", $testoption, $filter);
111+
# $failed += IntegrationTest("11-7", "Perforce/SecureSquareBracketIPv6", "ssl6:[::1]:1667", $testoption, $filter);
112+
113+
if ($failed > 0)
114+
{
115+
print "\nFAILURE $failed Perforce Integrations Test(s) failed!\n\n";
116+
exit 1;
117+
}
118+
else
119+
{
120+
print "\nSUCCESS: All Perforce Integrations Tests passed\n\n";
121+
}
112122
}
113123

114124
sub BuildMac
@@ -149,7 +159,6 @@ sub TestWin32
149159

150160
sub BuildLinux ($)
151161
{
152-
153162
system ('make', '-f', 'Makefile.gnu', 'clean');
154163
system ('make', '-f', 'Makefile.gnu') && die ("Failed to build PerforcePlugin for linux64");
155164
}

0 commit comments

Comments
 (0)