Skip to content

Commit 0617036

Browse files
committed
TestFixture: immediately bail out when library could not be loaded
1 parent 50c8a0d commit 0617036

2 files changed

Lines changed: 1 addition & 20 deletions

File tree

test/fixture.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ unsigned int TestFixture::countTests;
7373
std::size_t TestFixture::fails_counter = 0;
7474
std::size_t TestFixture::todos_counter = 0;
7575
std::size_t TestFixture::succeeded_todos_counter = 0;
76-
std::set<std::string> TestFixture::missingLibs;
7776

7877
TestFixture::TestFixture(const char * const _name)
7978
: mVerbose(false),
@@ -283,11 +282,6 @@ void TestFixture::assertNoThrowFail(const char * const filename, const unsigned
283282

284283
}
285284

286-
void TestFixture::complainMissingLib(const char * const libname)
287-
{
288-
missingLibs.insert(libname);
289-
}
290-
291285
void TestFixture::printHelp()
292286
{
293287
std::cout << "Testrunner - run Cppcheck tests\n"
@@ -356,12 +350,6 @@ std::size_t TestFixture::runTests(const options& args)
356350
std::cerr << "Tests failed: " << fails_counter << std::endl << std::endl;
357351
std::cerr << errmsg.str();
358352

359-
if (!missingLibs.empty()) {
360-
std::cerr << "Missing libraries: ";
361-
for (const std::string & missingLib : missingLibs)
362-
std::cerr << missingLib << " ";
363-
std::cerr << std::endl << std::endl;
364-
}
365353
std::cerr.flush();
366354
return fails_counter;
367355
}

test/fixture.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ class TestFixture : public ErrorLogger {
3939
static std::size_t fails_counter;
4040
static std::size_t todos_counter;
4141
static std::size_t succeeded_todos_counter;
42-
static std::set<std::string> missingLibs;
4342
bool mVerbose;
4443
std::string mTemplateFormat;
4544
std::string mTemplateLocation;
@@ -91,7 +90,6 @@ class TestFixture : public ErrorLogger {
9190
void assertThrow(const char * const filename, const unsigned int linenr) const;
9291
void assertThrowFail(const char * const filename, const unsigned int linenr) const;
9392
void assertNoThrowFail(const char * const filename, const unsigned int linenr) const;
94-
static void complainMissingLib(const char * const libname);
9593
static std::string deleteLineNumber(const std::string &message);
9694

9795
void setVerbose(bool v) {
@@ -159,12 +157,7 @@ extern std::ostringstream output;
159157
#define EXPECT_EQ( EXPECTED, ACTUAL ) assertEquals(__FILE__, __LINE__, EXPECTED, ACTUAL)
160158
#define REGISTER_TEST( CLASSNAME ) namespace { CLASSNAME instance_ ## CLASSNAME; }
161159

162-
#define LOAD_LIB_2( LIB, NAME ) do { \
163-
if (((LIB).load(exename.c_str(), NAME).errorcode != Library::ErrorCode::OK)) { \
164-
complainMissingLib(NAME); \
165-
return; \
166-
} \
167-
} while (false)
160+
#define LOAD_LIB_2( LIB, NAME ) do { if (((LIB).load(exename.c_str(), NAME).errorcode != Library::ErrorCode::OK)) throw std::runtime_error("library '" + std::string(NAME) + "' not found"); } while (false)
168161

169162
#define PLATFORM( S, P ) do { std::string errstr; assertEquals(__FILE__, __LINE__, true, S.platform(cppcheck::Platform::platformString(P), errstr, {exename}), errstr); } while (false)
170163

0 commit comments

Comments
 (0)