commit 8b0ce50790b61fef20f3a613435381bc8427a6ca
Author: Alvaro Herrera <alvherre@alvh.no-ip.org>
Date:   Fri Nov 28 12:37:50 2014 -0300

    MSVC updates

diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 004942c..9530ffb 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -528,16 +528,19 @@ sub mkvcbuild
 	my $mf = Project::read_file('contrib/pgcrypto/Makefile');
 	GenerateContribSqlFiles('pgcrypto', $mf);
 
-	my $D;
-	opendir($D, 'contrib') || croak "Could not opendir on contrib!\n";
-	while (my $d = readdir($D))
+	foreach my $subdir ('contrib', 'src/test/modules')
 	{
-		next if ($d =~ /^\./);
-		next unless (-f "contrib/$d/Makefile");
-		next if (grep { /^$d$/ } @contrib_excludes);
-		AddContrib($d);
+		my $D;
+		opendir($D, $subdir) || croak "Could not opendir on $subdir!\n";
+		while (my $d = readdir($D))
+		{
+			next if ($d =~ /^\./);
+			next unless (-f "$subdir/$d/Makefile");
+			next if (grep { /^$d$/ } @contrib_excludes);
+			AddContrib($subdir, $d);
+		}
+		closedir($D);
 	}
-	closedir($D);
 
 	$mf =
 	  Project::read_file('src\backend\utils\mb\conversion_procs\Makefile');
@@ -649,17 +652,19 @@ sub AddSimpleFrontend
 	return $p;
 }
 
-# Add a simple contrib project
+# Add a simple contrib project.  First arg is the subdir on which to find
+# the module; some of them reside in src/test/modules
 sub AddContrib
 {
+	my $subdir = shift;
 	my $n  = shift;
-	my $mf = Project::read_file('contrib\\' . $n . '\Makefile');
+	my $mf = Project::read_file($subdir . '\\' . $n . '\Makefile');
 
 	if ($mf =~ /^MODULE_big\s*=\s*(.*)$/mg)
 	{
 		my $dn = $1;
 		my $proj =
-		  $solution->AddProject($dn, 'dll', 'contrib', 'contrib\\' . $n);
+		  $solution->AddProject($dn, 'dll', 'contrib', $subdir . '\\' . $n);
 		$proj->AddReference($postgres);
 		AdjustContribProj($proj);
 	}
@@ -668,7 +673,7 @@ sub AddContrib
 		foreach my $mod (split /\s+/, $1)
 		{
 			my $proj =
-			  $solution->AddProject($mod, 'dll', 'contrib', 'contrib\\' . $n);
+			  $solution->AddProject($mod, 'dll', 'contrib', $subdir . '\\' . $n);
 			$proj->AddFile('contrib\\' . $n . '\\' . $mod . '.c');
 			$proj->AddReference($postgres);
 			AdjustContribProj($proj);
@@ -677,7 +682,7 @@ sub AddContrib
 	elsif ($mf =~ /^PROGRAM\s*=\s*(.*)$/mg)
 	{
 		my $proj =
-		  $solution->AddProject($1, 'exe', 'contrib', 'contrib\\' . $n);
+		  $solution->AddProject($1, 'exe', 'contrib', $subdir . '\\' . $n);
 		AdjustContribProj($proj);
 	}
 	else
diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl
index b84f70d..294894f 100644
--- a/src/tools/msvc/vcregress.pl
+++ b/src/tools/msvc/vcregress.pl
@@ -31,7 +31,7 @@ if (-e "src/tools/msvc/buildenv.pl")
 
 my $what = shift || "";
 if ($what =~
-/^(check|installcheck|plcheck|contribcheck|ecpgcheck|isolationcheck|upgradecheck)$/i
+/^(check|installcheck|plcheck|contribcheck|modulescheck|ecpgcheck|isolationcheck|upgradecheck)$/i
   )
 {
 	$what = uc $what;
@@ -76,6 +76,7 @@ my %command = (
 	INSTALLCHECK   => \&installcheck,
 	ECPGCHECK      => \&ecpgcheck,
 	CONTRIBCHECK   => \&contribcheck,
+	MODULESCHECK   => \&modulescheck,
 	ISOLATIONCHECK => \&isolationcheck,
 	UPGRADECHECK   => \&upgradecheck,);
 
@@ -213,22 +214,18 @@ sub plcheck
 	chdir "../../..";
 }
 
-sub contribcheck
+sub subdircheck
 {
-	chdir "../../../contrib";
+	my $topdir = shift;
+	my $subdir = shift;
+	my $module = shift;
 	my $mstat = 0;
-	foreach my $module (glob("*"))
-	{
-		# these configuration-based exclusions must match Install.pm
-		next if ($module eq "uuid-ossp" && !defined($config->{uuid}));
-		next if ($module eq "sslinfo"   && !defined($config->{openssl}));
-		next if ($module eq "xml2"      && !defined($config->{xml}));
-		next if ($module eq "sepgsql");
 
-		next
-		  unless -d "$module/sql"
-			  && -d "$module/expected"
-			  && (-f "$module/GNUmakefile" || -f "$module/Makefile");
+	{
+		return
+		     unless -d "$module/sql"
+		  && -d "$module/expected"
+		  && (-f "$module/GNUmakefile" || -f "$module/Makefile");
 		chdir $module;
 		print
 		  "============================================================\n";
@@ -236,17 +233,41 @@ sub contribcheck
 		my @tests = fetchTests();
 		my @opts  = fetchRegressOpts();
 		my @args  = (
-			"../../$Config/pg_regress/pg_regress",
-			"--psqldir=../../$Config/psql",
-			"--dbname=contrib_regression", @opts, @tests);
+			"$topdir/pg_regress/pg_regress",
+			"--psqldir=$topdir/psql", "--dbname=contrib", @opts, @tests);
 		system(@args);
 		my $status = $? >> 8;
 		$mstat ||= $status;
 		chdir "..";
 	}
+
 	exit $mstat if $mstat;
 }
 
+sub contribcheck
+{
+	chdir "../../../contrib";
+	foreach my $module (glob("*"))
+	{
+		# these configuration-based exclusions must match Install.pm
+		next if ($module eq "uuid-ossp" && !defined($config->{uuid}));
+		next if ($module eq "sslinfo"   && !defined($config->{openssl}));
+		next if ($module eq "xml2"      && !defined($config->{xml}));
+		next if ($module eq "sepgsql");
+
+		subdircheck("../../$Config", "../../../contrib", $module);
+	}
+}
+
+sub modulescheck
+{
+	chdir "../../../src/test/modules";
+	foreach my $module (glob("*"))
+	{
+		subdircheck("../../$Config", "../../../src/test/modules", $module);
+	}
+}
+
 sub upgradecheck
 {
 	my $status;
