[mapguide-commits] r10229 - in branches/4.0/MgDev: Common/Foundation/System Server/src/UnitTesting
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Fri Oct 23 13:37:05 PDT 2026
Author: jng
Date: 2026-10-23 13:37:05 -0700 (Fri, 23 Oct 2026)
New Revision: 10229
Modified:
branches/4.0/MgDev/Common/Foundation/System/Resources.cpp
branches/4.0/MgDev/Server/src/UnitTesting/UnitTesting.cpp
Log:
Allow mgserver test to accept a comma-delimited set of suites to run
Fixes #2893
Modified: branches/4.0/MgDev/Common/Foundation/System/Resources.cpp
===================================================================
--- branches/4.0/MgDev/Common/Foundation/System/Resources.cpp 2026-10-23 19:36:50 UTC (rev 10228)
+++ branches/4.0/MgDev/Common/Foundation/System/Resources.cpp 2026-10-23 20:37:05 UTC (rev 10229)
@@ -101,8 +101,10 @@
const STRING MgResources::ServerCmdTestDescription = L" test <Test> <Filename>\n"\
L" Runs the server unit test(s).\n\n"\
L" By default all of the unit tests will be run unless you specify an\n"\
- L" optional \"Test\" to run. If you specify \"List\" as the test to run you\n"\
- L" will get a list of the available unit tests.\n\n"\
+ L" optional \"Test\" to run. \"Test\" may be a comma-delimited list of\n"\
+ L" test names, for example \"Geometry,MdfModel\", which runs all of the\n"\
+ L" named tests in a single server start. If you specify \"List\" as the\n"\
+ L" test to run you will get a list of the available unit tests.\n\n"\
L" Default output of the unit tests will be the console unless you specify\n"\
L" an optional \"Filename\". The output to the \"Filename\" will be in XML.\n\n";
Modified: branches/4.0/MgDev/Server/src/UnitTesting/UnitTesting.cpp
===================================================================
--- branches/4.0/MgDev/Server/src/UnitTesting/UnitTesting.cpp 2026-10-23 19:36:50 UTC (rev 10228)
+++ branches/4.0/MgDev/Server/src/UnitTesting/UnitTesting.cpp 2026-10-23 20:37:05 UTC (rev 10229)
@@ -20,9 +20,110 @@
#include "FoundationDefs.h"
#include "TestServiceFactory.h"
+#include <vector>
+
#define CATCH_CONFIG_RUNNER
#include "catch.hpp"
+namespace
+{
+ void AddAllSuitesToRun()
+ {
+ static const char* const allSuites[] =
+ {
+ "[CoordinateSystem]",
+ "[DrawingService]",
+ "[FeatureService]",
+ "[Geometry]",
+ "[KmlService]",
+ "[LogManager]",
+ "[MappingService]",
+ "[MdfModel]",
+ "[Misc]",
+ "[Performance]",
+ "[RenderingService]",
+ "[RasterStylization]",
+ "[ResourceService]",
+ "[ServerAdminService]",
+ "[ServerManager]",
+ "[ServiceManager]",
+ "[SiteManager]",
+ "[SiteService]",
+ "[Stylization]",
+ "[TileService]",
+ "[ProfilingService]",
+ "[TransformMesh]"
+ };
+
+ for (size_t i = 0; i < sizeof(allSuites) / sizeof(allSuites[0]); ++i)
+ {
+ TestServiceFactory::AddSuiteToRun(allSuites[i]);
+ }
+ }
+
+ void PrintAvailableSuites()
+ {
+ // Title
+ ACE_OS::printf("The following test suites are available to run:\n\n");
+
+ // Available tests
+ ACE_OS::printf(" all - Excluding Performance\n");
+ ACE_OS::printf(" CoordinateSystem\n");
+ ACE_OS::printf(" DrawingService\n");
+ ACE_OS::printf(" FeatureService\n");
+ ACE_OS::printf(" Geometry\n");
+ ACE_OS::printf(" KmlService\n");
+ ACE_OS::printf(" LogManager\n");
+ ACE_OS::printf(" MappingService\n");
+ ACE_OS::printf(" MdfModel\n");
+ ACE_OS::printf(" Misc\n");
+ ACE_OS::printf(" Performance\n");
+ ACE_OS::printf(" RenderingService\n");
+ ACE_OS::printf(" RasterStylization\n");
+ ACE_OS::printf(" ResourceService\n");
+ ACE_OS::printf(" ServerAdminService\n");
+ ACE_OS::printf(" ServerManager\n");
+ ACE_OS::printf(" ServiceManager\n");
+ ACE_OS::printf(" SiteManager\n");
+ ACE_OS::printf(" SiteService\n");
+ ACE_OS::printf(" Stylization\n");
+ ACE_OS::printf(" TileService\n");
+ ACE_OS::printf(" ProfilingService\n");
+ ACE_OS::printf(" TransformMesh\n");
+ ACE_OS::printf("\n");
+ }
+
+ // Splits a delimited list of suite names. Commas, semicolons and
+ // whitespace are accepted as delimiters, so both
+ // "FeatureService,Geometry" and "FeatureService Geometry" work.
+ void SplitSuiteList(CREFSTRING test, std::vector<STRING>& suites)
+ {
+ STRING name;
+ for (size_t i = 0; i < test.length(); ++i)
+ {
+ wchar_t ch = test[i];
+ if (ch == L',' || ch == L';' || ch == L' ' || ch == L'\t' ||
+ ch == L'\r' || ch == L'\n')
+ {
+ if (!name.empty())
+ {
+ suites.push_back(name);
+ name.clear();
+ }
+ }
+ else
+ {
+ name += ch;
+ }
+ }
+
+ if (!name.empty())
+ {
+ suites.push_back(name);
+ }
+ }
+}
+
int Execute(CREFSTRING fileName, CREFSTRING test)
{
// Set the default user information for this test run.
@@ -34,70 +135,41 @@
Catch::Session session;
if (!test.empty())
{
- if (test == L"all")
+ std::vector<STRING> suites;
+ SplitSuiteList(test, suites);
+
+ // Preserve the previous behavior for a value that has no suite names
+ // in it: it is still bracketed and run as a single (matching nothing)
+ // tag.
+ if (suites.empty())
{
- TestServiceFactory::AddSuiteToRun("[CoordinateSystem]");
- TestServiceFactory::AddSuiteToRun("[DrawingService]");
- TestServiceFactory::AddSuiteToRun("[FeatureService]");
- TestServiceFactory::AddSuiteToRun("[Geometry]");
- TestServiceFactory::AddSuiteToRun("[KmlService]");
- TestServiceFactory::AddSuiteToRun("[LogManager]");
- TestServiceFactory::AddSuiteToRun("[MappingService]");
- TestServiceFactory::AddSuiteToRun("[MdfModel]");
- TestServiceFactory::AddSuiteToRun("[Misc]");
- TestServiceFactory::AddSuiteToRun("[Performance]");
- TestServiceFactory::AddSuiteToRun("[RenderingService]");
- TestServiceFactory::AddSuiteToRun("[RasterStylization]");
- TestServiceFactory::AddSuiteToRun("[ResourceService]");
- TestServiceFactory::AddSuiteToRun("[ServerAdminService]");
- TestServiceFactory::AddSuiteToRun("[ServerManager]");
- TestServiceFactory::AddSuiteToRun("[ServiceManager]");
- TestServiceFactory::AddSuiteToRun("[SiteManager]");
- TestServiceFactory::AddSuiteToRun("[SiteService]");
- TestServiceFactory::AddSuiteToRun("[Stylization]");
- TestServiceFactory::AddSuiteToRun("[TileService]");
- TestServiceFactory::AddSuiteToRun("[ProfilingService]");
- TestServiceFactory::AddSuiteToRun("[TransformMesh]");
+ suites.push_back(test);
}
- else if (test == L"list")
- {
- // Title
- ACE_OS::printf("The following test suites are available to run:\n\n");
- // Available tests
- ACE_OS::printf(" all - Excluding Performance\n");
- ACE_OS::printf(" CoordinateSystem\n");
- ACE_OS::printf(" DrawingService\n");
- ACE_OS::printf(" FeatureService\n");
- ACE_OS::printf(" Geometry\n");
- ACE_OS::printf(" KmlService\n");
- ACE_OS::printf(" LogManager\n");
- ACE_OS::printf(" MappingService\n");
- ACE_OS::printf(" MdfModel\n");
- ACE_OS::printf(" Misc\n");
- ACE_OS::printf(" Performance\n");
- ACE_OS::printf(" RenderingService\n");
- ACE_OS::printf(" RasterStylization\n");
- ACE_OS::printf(" ResourceService\n");
- ACE_OS::printf(" ServerAdminService\n");
- ACE_OS::printf(" ServerManager\n");
- ACE_OS::printf(" ServiceManager\n");
- ACE_OS::printf(" SiteManager\n");
- ACE_OS::printf(" SiteService\n");
- ACE_OS::printf(" Stylization\n");
- ACE_OS::printf(" TileService\n");
- ACE_OS::printf(" ProfilingService\n");
- ACE_OS::printf(" TransformMesh\n");
- ACE_OS::printf("\n");
+ bool bListOnly = (suites.size() == 1 && suites[0] == L"list");
- bRunTests = false;
- }
- else
+ for (size_t i = 0; i < suites.size(); ++i)
{
- std::string testToRun = "[";
- testToRun += MgUtil::WideCharToMultiByte(test);
- testToRun += "]";
- TestServiceFactory::AddSuiteToRun(testToRun);
+ const STRING& suite = suites[i];
+ if (suite == L"all")
+ {
+ AddAllSuitesToRun();
+ }
+ else if (suite == L"list")
+ {
+ PrintAvailableSuites();
+ if (bListOnly)
+ {
+ bRunTests = false;
+ }
+ }
+ else
+ {
+ std::string testToRun = "[";
+ testToRun += MgUtil::WideCharToMultiByte(suite);
+ testToRun += "]";
+ TestServiceFactory::AddSuiteToRun(testToRun);
+ }
}
}
More information about the mapguide-commits
mailing list