Skip to content

Commit 6d69614

Browse files
committed
STDERR instead of STDOUT for c++ unit tests
1 parent 20217da commit 6d69614

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1010
- Yaml files support select/reject critera for paths of unit tests for targeted testing
1111

1212
### Changed
13+
- Unit test executables print to STDERR just in case there are segfaults. Uh, just in case I ever write any.
1314

1415
### Deprecated
1516

cpp/unittest/ArduinoUnitTests.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,23 @@ class Test
2828
~ReporterTAP() {}
2929

3030
void onTestRunInit(int numTests) {
31-
cout << "TAP version 13" << endl;
32-
cout << 1 << ".." << numTests << endl; // we know how many tests, in advance
31+
cerr << "TAP version 13" << endl;
32+
cerr << 1 << ".." << numTests << endl; // we know how many tests, in advance
3333
mTestCounter = 0;
3434
}
3535

3636
void onTestStart(TestData td) {
3737
mAssertCounter = 0;
3838
++mTestCounter;
39-
cout << "# Subtest: " << td.name << endl;
39+
cerr << "# Subtest: " << td.name << endl;
4040
}
4141

4242
void onTestEnd(TestData td) {
43-
cout << " 1.." << mAssertCounter << endl;
43+
cerr << " 1.." << mAssertCounter << endl;
4444
if (td.result == RESULT_PASS) {
45-
cout << "ok " << mTestCounter << " - " << td.name << endl;
45+
cerr << "ok " << mTestCounter << " - " << td.name << endl;
4646
} else {
47-
cout << "not ok " << mTestCounter << " - " << td.name << endl;
47+
cerr << "not ok " << mTestCounter << " - " << td.name << endl;
4848
}
4949
}
5050

@@ -61,17 +61,17 @@ class Test
6161
const char* rhsLabel,
6262
const B &rhs
6363
) {
64-
cout << " " << (pass ? "" : "not ") << "ok " << ++mAssertCounter << " - ";
65-
cout << description << " " << lhsLabel << " " << opLabel << " " << rhsLabel << endl;
64+
cerr << " " << (pass ? "" : "not ") << "ok " << ++mAssertCounter << " - ";
65+
cerr << description << " " << lhsLabel << " " << opLabel << " " << rhsLabel << endl;
6666
if (!pass) {
67-
cout << " ---" << endl;
68-
cout << " operator: " << opLabel << endl;
69-
cout << " " << lhsRelevance << ": " << lhs << endl;
70-
cout << " " << rhsRelevance << ": " << rhs << endl;
71-
cout << " at:" << endl;
72-
cout << " file: " << file << endl;
73-
cout << " line: " << line << endl;
74-
cout << " ..." << endl;
67+
cerr << " ---" << endl;
68+
cerr << " operator: " << opLabel << endl;
69+
cerr << " " << lhsRelevance << ": " << lhs << endl;
70+
cerr << " " << rhsRelevance << ": " << rhs << endl;
71+
cerr << " at:" << endl;
72+
cerr << " file: " << file << endl;
73+
cerr << " line: " << line << endl;
74+
cerr << " ..." << endl;
7575
}
7676
}
7777
};

0 commit comments

Comments
 (0)