2575 - better messages on trace count failures
This commit is contained in:
parent
ff9d5f43cf
commit
7163e18a77
10
003trace.cc
10
003trace.cc
|
@ -272,6 +272,16 @@ int trace_count(string label, string line) {
|
|||
return; \
|
||||
}
|
||||
|
||||
#define CHECK_TRACE_COUNT(label, count) \
|
||||
if (trace_count(label) != (count)) { \
|
||||
++Num_failures; \
|
||||
cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): trace_count of " << label << " should be " << count << '\n'; \
|
||||
cerr << " got " << trace_count(label) << '\n'; /* multiple eval */ \
|
||||
DUMP(label); \
|
||||
Passed = false; \
|
||||
return; /* Currently we stop at the very first failure. */ \
|
||||
}
|
||||
|
||||
bool trace_doesnt_contain(string label, string line) {
|
||||
return trace_count(label, line) == 0;
|
||||
}
|
||||
|
|
|
@ -318,7 +318,7 @@ void emit_test(const string& name, list<Line>& lines, list<Line>& result) {
|
|||
size_t pos = in.find(": ");
|
||||
string layer = in.substr(1, pos-1);
|
||||
string count = in.substr(pos+2);
|
||||
result.push_back(Line(" CHECK_EQ(trace_count(\""+layer+"\"), "+count+");", front(lines)));
|
||||
result.push_back(Line(" CHECK_TRACE_COUNT(\""+layer+"\", "+count+");", front(lines)));
|
||||
lines.pop_front();
|
||||
}
|
||||
if (!lines.empty() && front(lines).contents == "===") {
|
||||
|
|
|
@ -321,7 +321,7 @@ void test_tangle_can_check_for_count_in_scenario() {
|
|||
CHECK_EQ(lines.front().contents, "void test_does_bar() {"); lines.pop_front();
|
||||
CHECK_EQ(lines.front().contents, " Trace_file = \"does_bar\";"); lines.pop_front();
|
||||
CHECK_EQ(lines.front().contents, " run(\"abc def\\n efg\\n\");"); lines.pop_front();
|
||||
CHECK_EQ(lines.front().contents, " CHECK_EQ(trace_count(\"layer1\"), 2);"); lines.pop_front();
|
||||
CHECK_EQ(lines.front().contents, " CHECK_TRACE_COUNT(\"layer1\", 2);"); lines.pop_front();
|
||||
CHECK_EQ(lines.front().contents, "}"); lines.pop_front();
|
||||
CHECK(lines.empty());
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ void test_tangle_can_handle_mu_comments_in_scenario() {
|
|||
CHECK_EQ(lines.front().contents, " run(\"abc def\\n# comment1\\n efg\\n # indented comment 2\\n\");"); lines.pop_front();
|
||||
CHECK_EQ(lines.front().contents, " CHECK_TRACE_CONTENTS(\"layer1: pqrlayer1: xyz\");"); lines.pop_front();
|
||||
CHECK_EQ(lines.front().contents, " CHECK_TRACE_DOESNT_CONTAIN(\"layer1: z\");"); lines.pop_front();
|
||||
CHECK_EQ(lines.front().contents, " CHECK_EQ(trace_count(\"layer1\"), 2);"); lines.pop_front();
|
||||
CHECK_EQ(lines.front().contents, " CHECK_TRACE_COUNT(\"layer1\", 2);"); lines.pop_front();
|
||||
CHECK_EQ(lines.front().contents, "}"); lines.pop_front();
|
||||
CHECK(lines.empty());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue