Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-32700 Fix regression in unit test verbose output #19297

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading