Skip to content

Commit 1e5e32c

Browse files
committed
testrunner: remove non-gcc-style output format
1 parent dad455c commit 1e5e32c

7 files changed

Lines changed: 27 additions & 77 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ test: all
260260
./testrunner
261261

262262
check: all
263-
./testrunner -g -q
263+
./testrunner -q
264264

265265
checkcfg: cppcheck
266266
./test/cfg/runtests.sh

test/options.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@
1919
options::options(int argc, const char* argv[])
2020
:_options(argv + 1, argv + argc)
2121
,_which_test("")
22-
,_gcc_style_errors(_options.count("-g") != 0)
2322
,_quiet(_options.count("-q") != 0)
2423
{
25-
_options.erase("-g");
2624
_options.erase("-q");
2725
if (! _options.empty()) {
2826
_which_test = *_options.rbegin();
@@ -34,11 +32,6 @@ bool options::quiet() const
3432
return _quiet;
3533
}
3634

37-
bool options::gcc_style_errors() const
38-
{
39-
return _gcc_style_errors;
40-
}
41-
4235
const std::string& options::which_test() const
4336
{
4437
return _which_test;

test/options.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ class options {
3131
options(int argc, const char* argv[]);
3232
/** Don't print the name of each method being tested. */
3333
bool quiet() const;
34-
/** __FILE__:__LINE__: Error message. Makes it easier for editors to find
35-
* failing tests/ */
36-
bool gcc_style_errors() const;
3734
/** Which test should be run. Empty string means 'all tests' */
3835
const std::string& which_test() const;
3936

@@ -45,7 +42,6 @@ class options {
4542
private:
4643
std::set<std::string> _options;
4744
std::string _which_test;
48-
const bool _gcc_style_errors;
4945
const bool _quiet;
5046
};
5147

test/testoptions.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class TestOptions: public TestFixture {
3232
TEST_CASE(no_test_method);
3333
TEST_CASE(not_quiet);
3434
TEST_CASE(quiet);
35-
TEST_CASE(gcc_errors);
3635
TEST_CASE(multiple_testcases);
3736
TEST_CASE(invalid_switches);
3837
}
@@ -73,11 +72,6 @@ class TestOptions: public TestFixture {
7372
}
7473

7574

76-
void gcc_errors() const {
77-
const char* argv[] = {"./test_runner", "TestClass::TestMethod", "-g"};
78-
options args(sizeof argv / sizeof argv[0], argv);
79-
ASSERT_EQUALS(true, args.gcc_style_errors());
80-
}
8175

8276

8377
void multiple_testcases() const {
@@ -88,10 +82,9 @@ class TestOptions: public TestFixture {
8882

8983

9084
void invalid_switches() const {
91-
const char* argv[] = {"./test_runner", "TestClass::TestMethod", "-a", "-v", "-q", "-g"};
85+
const char* argv[] = {"./test_runner", "TestClass::TestMethod", "-a", "-v", "-q"};
9286
options args(sizeof argv / sizeof argv[0], argv);
9387
ASSERT_EQUALS("TestClass::TestMethod", args.which_test());
94-
ASSERT_EQUALS(true, args.gcc_style_errors());
9588
ASSERT_EQUALS(true, args.quiet());
9689
}
9790
};

test/testsuite.cpp

Lines changed: 24 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ std::set<std::string> TestFixture::missingLibs;
6868

6969
TestFixture::TestFixture(const std::string &_name)
7070
:classname(_name)
71-
,gcc_style_errors(false)
7271
,quiet_tests(false)
7372
{
7473
TestRegistry::theInstance().addTest(this);
@@ -121,38 +120,25 @@ void TestFixture::assert_(const char *filename, unsigned int linenr, bool condit
121120
{
122121
if (!condition) {
123122
++fails_counter;
124-
if (gcc_style_errors) {
125-
errmsg << filename << ':' << linenr << ": Assertion failed." << std::endl;
126-
} else {
127-
errmsg << "Assertion failed in " << filename << " at line " << linenr << std::endl << "_____" << std::endl;
128-
}
123+
errmsg << filename << ':' << linenr << ": Assertion failed." << std::endl << "_____" << std::endl;
124+
129125
}
130126
}
131127

132128
void TestFixture::assertEquals(const char *filename, unsigned int linenr, const std::string &expected, const std::string &actual, const std::string &msg) const
133129
{
134130
if (expected != actual) {
135131
++fails_counter;
136-
if (gcc_style_errors) {
137-
errmsg << filename << ':' << linenr << ": Assertion failed. "
138-
<< "Expected: "
139-
<< writestr(expected, true)
140-
<< ". Actual: "
141-
<< writestr(actual, true)
142-
<< '.'
143-
<< std::endl;
144-
if (!msg.empty())
145-
errmsg << msg << std::endl;
146-
} else {
147-
errmsg << "Assertion failed in " << filename << " at line " << linenr << std::endl
148-
<< "Expected:" << std::endl
149-
<< writestr(expected) << std::endl
150-
<< "Actual:" << std::endl
151-
<< writestr(actual) << std::endl;
152-
if (!msg.empty())
153-
errmsg << "Hint:" << std::endl << msg << std::endl;
154-
errmsg << "_____" << std::endl;
155-
}
132+
errmsg << filename << ':' << linenr << ": Assertion failed. " << std::endl
133+
<< "Expected: " << std::endl
134+
<< writestr(expected) << std::endl
135+
<< "Actual: " << std::endl
136+
<< writestr(actual) << std::endl;
137+
if (!msg.empty())
138+
errmsg << "Hint:" << std::endl << msg << std::endl;
139+
errmsg << "_____" << std::endl;
140+
141+
156142
}
157143
}
158144
void TestFixture::assertEquals(const char *filename, unsigned int linenr, const char expected[], const std::string& actual, const std::string &msg) const
@@ -192,13 +178,9 @@ void TestFixture::todoAssertEquals(const char *filename, unsigned int linenr,
192178
const std::string &actual) const
193179
{
194180
if (wanted == actual) {
195-
if (gcc_style_errors) {
196-
errmsg << filename << ':' << linenr << ": Assertion succeeded unexpectedly. "
197-
<< "Result: " << writestr(wanted, true) << "." << std::endl;
198-
} else {
199-
errmsg << "Assertion succeeded unexpectedly in " << filename << " at line " << linenr << std::endl
200-
<< "Result:" << std::endl << writestr(wanted) << std::endl << "_____" << std::endl;
201-
}
181+
errmsg << filename << ':' << linenr << ": Assertion succeeded unexpectedly. "
182+
<< "Result: " << writestr(wanted, true) << std::endl << "_____" << std::endl;
183+
202184
++succeeded_todos_counter;
203185
} else {
204186
assertEquals(filename, linenr, current, actual);
@@ -218,37 +200,25 @@ void TestFixture::todoAssertEquals(const char *filename, unsigned int linenr, lo
218200
void TestFixture::assertThrow(const char *filename, unsigned int linenr) const
219201
{
220202
++fails_counter;
221-
if (gcc_style_errors) {
222-
errmsg << filename << ':' << linenr << " Assertion succeeded. "
223-
<< "The expected exception was thrown" << std::endl;
224-
} else {
225-
errmsg << "Assertion succeeded in " << filename << " at line " << linenr << std::endl
226-
<< "The expected exception was thrown" << std::endl << "_____" << std::endl;
227-
}
203+
errmsg << filename << ':' << linenr << ": Assertion succeeded. "
204+
<< "The expected exception was thrown" << std::endl << "_____" << std::endl;
205+
228206
}
229207

230208
void TestFixture::assertThrowFail(const char *filename, unsigned int linenr) const
231209
{
232210
++fails_counter;
233-
if (gcc_style_errors) {
234-
errmsg << filename << ':' << linenr << " Assertion failed. "
235-
<< "The expected exception was not thrown" << std::endl;
236-
} else {
237-
errmsg << "Assertion failed in " << filename << " at line " << linenr << std::endl
238-
<< "The expected exception was not thrown" << std::endl << "_____" << std::endl;
239-
}
211+
errmsg << filename << ':' << linenr << ": Assertion failed. "
212+
<< "The expected exception was not thrown" << std::endl << "_____" << std::endl;
213+
240214
}
241215

242216
void TestFixture::assertNoThrowFail(const char *filename, unsigned int linenr) const
243217
{
244218
++fails_counter;
245-
if (gcc_style_errors) {
246-
errmsg << filename << ':' << linenr << " Assertion failed. "
247-
<< "Unexpected exception was thrown" << std::endl;
248-
} else {
249-
errmsg << "Assertion failed in " << filename << " at line " << linenr << std::endl
250-
<< "Unexpected exception was thrown" << std::endl << "_____" << std::endl;
251-
}
219+
errmsg << filename << ':' << linenr << ": Assertion failed. "
220+
<< "Unexpected exception was thrown" << std::endl << "_____" << std::endl;
221+
252222
}
253223

254224
void TestFixture::complainMissingLib(const char* libname) const
@@ -272,7 +242,6 @@ void TestFixture::run(const std::string &str)
272242
void TestFixture::processOptions(const options& args)
273243
{
274244
quiet_tests = args.quiet();
275-
gcc_style_errors = args.gcc_style_errors();
276245
}
277246

278247
std::size_t TestFixture::runTests(const options& args)

test/testsuite.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ class TestFixture : public ErrorLogger {
3838
protected:
3939
std::string classname;
4040
std::string testToRun;
41-
bool gcc_style_errors;
4241
bool quiet_tests;
4342
std::string currentTest;
4443

tools/dmake.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ int main(int argc, char **argv)
374374
fout << "test:\tall\n";
375375
fout << "\t./testrunner\n\n";
376376
fout << "check:\tall\n";
377-
fout << "\t./testrunner -g -q\n\n";
377+
fout << "\t./testrunner -q\n\n";
378378
fout << "checkcfg:\tcppcheck\n";
379379
fout << "\t./test/cfg/runtests.sh\n\n";
380380
fout << "dmake:\ttools/dmake.o cli/filelister.o lib/pathmatch.o lib/path.o\n";

0 commit comments

Comments
 (0)