Skip to content

Commit

Permalink
Merge pull request hpcc-systems#19297 from ghalliday/issue32700b
Browse files Browse the repository at this point in the history
HPCC-32700 Fix regression in unit test verbose output

Reviewed-By: Terrence Asselin <[email protected]>
Merged-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday authored Nov 18, 2024
2 parents cc06db9 + b021cb9 commit 17590a5
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions testing/unittests/espapicmdtests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,6 @@ class EspApiCmdTest : public CppUnit::TestFixture
sasha(createIFile("/tmp/hpcctest/sasha.xml"))
{
try{
InitModuleObjects();
queryStderrLogMsgHandler()->setMessageFields(0);
queryLogMsgManager()->removeMonitor(queryStderrLogMsgHandler());
dir->createDirectory();

Owned<IFileIO> ioCommon = common->open(IFOcreate);
Expand Down Expand Up @@ -317,7 +314,7 @@ class EspApiCmdTest : public CppUnit::TestFixture
"/tmp/hpcctest/common.xml\n"
"/tmp/hpcctest/store.xml\n";

for(Owned<IFile>& myfile: env.files)
for(Owned<IFile>& myfile: queryEnvironment().files)
{
fileStr.append(myfile->queryFilename());
fileStr.append("\n");
Expand All @@ -333,7 +330,7 @@ class EspApiCmdTest : public CppUnit::TestFixture
string refStr =
"WSSasha\n"
"wsstore\n";
vector<const char*> services = env.esdlDefObj.getAllServices();
vector<const char*> services = queryEnvironment().esdlDefObj.getAllServices();
for(const char* service : services)
{
serviceStr.append(service);
Expand All @@ -351,7 +348,7 @@ class EspApiCmdTest : public CppUnit::TestFixture
ostringstream oss;
string res;

env.esdlDefObj.describeAllServices(oss);
queryEnvironment().esdlDefObj.describeAllServices(oss);
res = oss.str();

sortAndWriteBack(res);
Expand All @@ -368,7 +365,7 @@ class EspApiCmdTest : public CppUnit::TestFixture
"Ping\n"
"RestoreWU\n";

vector<const char*> methods = env.esdlDefObj.getAllMethods();
vector<const char*> methods = queryEnvironment().esdlDefObj.getAllMethods();
for(const char* &method:methods)
{
methodStr.append(method);
Expand All @@ -388,7 +385,7 @@ class EspApiCmdTest : public CppUnit::TestFixture
ostringstream oss;
string res;

env.esdlDefObj.describeAllMethods("WSSasha",oss);
queryEnvironment().esdlDefObj.describeAllMethods("WSSasha",oss);
res = oss.str();

sortAndWriteBack(res);
Expand All @@ -399,22 +396,22 @@ class EspApiCmdTest : public CppUnit::TestFixture
}
void testCheckValidService()
{
bool validCheck = env.esdlDefObj.checkValidService("WSSasha");
bool invalidCheck = env.esdlDefObj.checkValidService("InvalidService");
bool validCheck = queryEnvironment().esdlDefObj.checkValidService("WSSasha");
bool invalidCheck = queryEnvironment().esdlDefObj.checkValidService("InvalidService");
CPPUNIT_ASSERT_EQUAL(validCheck, true);
CPPUNIT_ASSERT_EQUAL(invalidCheck, false);
}
void testCheckValidMethod()
{
bool validCheck = env.esdlDefObj.checkValidMethod("GetVersion", "WSSasha");
bool invalidCheck = env.esdlDefObj.checkValidMethod("InvalidMethod", "WSSasha");
bool validCheck = queryEnvironment().esdlDefObj.checkValidMethod("GetVersion", "WSSasha");
bool invalidCheck = queryEnvironment().esdlDefObj.checkValidMethod("InvalidMethod", "WSSasha");
CPPUNIT_ASSERT_EQUAL(validCheck, true);
CPPUNIT_ASSERT_EQUAL(invalidCheck, false);

}
void testDescribe()
{
env.esdlDefObj.loadAllMethods("wsstore");
queryEnvironment().esdlDefObj.loadAllMethods("wsstore");
string refString =
"ListStoresRequest\n"
"string NameFilter\n"
Expand All @@ -438,19 +435,19 @@ class EspApiCmdTest : public CppUnit::TestFixture

ostringstream oss;
string res;
env.esdlDefObj.describe("wsstore","ListStores", oss);
queryEnvironment().esdlDefObj.describe("wsstore","ListStores", oss);
res = oss.str();

oss.str("");
oss.clear();
string invalidServiceRes;
env.esdlDefObj.describe("bad_name","ListStores", oss);
queryEnvironment().esdlDefObj.describe("bad_name","ListStores", oss);
invalidServiceRes = oss.str();

oss.str("");
oss.clear();
string invalidMethodRes;
env.esdlDefObj.describe("wsstore","bad_name", oss);
queryEnvironment().esdlDefObj.describe("wsstore","bad_name", oss);
invalidMethodRes = oss.str();

CPPUNIT_ASSERT_EQUAL(refString, res);
Expand All @@ -459,7 +456,12 @@ class EspApiCmdTest : public CppUnit::TestFixture
}

private:
static Environment env;
Environment & queryEnvironment()
{
//Avoid creating this object until it is first used - otherwise any calls to the logging will crash
static Environment env;
return env;
}

void sortAndWriteBack(string& input)
{
Expand All @@ -485,8 +487,6 @@ class EspApiCmdTest : public CppUnit::TestFixture
}
};

EspApiCmdTest::Environment EspApiCmdTest::env;

CPPUNIT_TEST_SUITE_REGISTRATION( EspApiCmdTest );
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( EspApiCmdTest, "EspApiCmdTest" );

Expand Down

0 comments on commit 17590a5

Please sign in to comment.