diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-06-11 10:46:37 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-06-11 10:46:37 -0700 |
commit | f72f34d35301d1a8a263c03834585a724ee2737d (patch) | |
tree | 2dcf83d16fba39155f12ae1e6a814d206c9878db | |
parent | 835d98a1a72c4b4682eb4b308703ec9e05afb2d1 (diff) | |
download | mu-f72f34d35301d1a8a263c03834585a724ee2737d.tar.gz |
3049 - clearer message for some test failures
-rw-r--r-- | 003trace.cc | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/003trace.cc b/003trace.cc index 4ac9efa6..2481c0be 100644 --- a/003trace.cc +++ b/003trace.cc @@ -218,12 +218,8 @@ bool check_trace_contents(string FUNCTION, string FILE, int LINE, string expecte string label, contents; split_label_contents(expected_lines.at(curr_expected_line), &label, &contents); for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { - if (label != p->label) - continue; - - if (contents != trim(p->contents)) - continue; - + if (label != p->label) continue; + if (contents != trim(p->contents)) continue; ++curr_expected_line; while (curr_expected_line < SIZE(expected_lines) && expected_lines.at(curr_expected_line).empty()) ++curr_expected_line; @@ -232,8 +228,14 @@ bool check_trace_contents(string FUNCTION, string FILE, int LINE, string expecte } ++Num_failures; - cerr << "\nF - " << FUNCTION << "(" << FILE << ":" << LINE << "): missing [" << contents << "] in trace:\n"; - DUMP(label); + if (line_exists_anywhere(label, contents)) { + cerr << "\nF - " << FUNCTION << "(" << FILE << ":" << LINE << "): line [" << label << ": " << contents << "] out of order in trace:\n"; + DUMP(""); + } + else { + cerr << "\nF - " << FUNCTION << "(" << FILE << ":" << LINE << "): missing [" << contents << "] in trace:\n"; + DUMP(label); + } Passed = false; return false; } @@ -251,6 +253,14 @@ void split_label_contents(const string& s, string* label, string* contents) { } } +bool line_exists_anywhere(const string& label, const string& contents) { + for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { + if (label != p->label) continue; + if (contents == trim(p->contents)) return true; + } + return false; +} + int trace_count(string label) { |