3917
Redo commit 3905 to always shutdown cleanly on any error raised.
This commit is contained in:
parent
960e75d0c6
commit
1441e507b6
14
003trace.cc
14
003trace.cc
|
@ -165,11 +165,23 @@ int Trace_errors = 0; // used only when Trace_stream is NULL
|
|||
#define DUMP(label) if (Trace_stream) cerr << Trace_stream->readable_contents(label);
|
||||
|
||||
// Errors are a special layer.
|
||||
#define raise (!Trace_stream ? (++Trace_errors,cerr) /*do print*/ : Trace_stream->stream(Error_depth, "error"))
|
||||
#define raise (!Trace_stream ? (scroll_to_bottom_and_close_console(),++Trace_errors,cerr) /*do print*/ : Trace_stream->stream(Error_depth, "error"))
|
||||
// If we aren't yet sure how to deal with some corner case, use assert_for_now
|
||||
// to indicate that it isn't an inviolable invariant.
|
||||
#define assert_for_now assert
|
||||
|
||||
//: Automatically close the console in some situations.
|
||||
:(before "End One-time Setup")
|
||||
atexit(scroll_to_bottom_and_close_console);
|
||||
:(code)
|
||||
void scroll_to_bottom_and_close_console() {
|
||||
if (!tb_is_active()) return;
|
||||
// leave the screen in a relatively clean state
|
||||
tb_set_cursor(tb_width()-1, tb_height()-1);
|
||||
cout << "\r\n";
|
||||
tb_shutdown();
|
||||
}
|
||||
|
||||
// Inside tests, fail any tests that displayed (unexpected) errors.
|
||||
// Expected errors in tests should always be hidden and silently checked for.
|
||||
:(before "End Test Teardown")
|
||||
|
|
|
@ -189,7 +189,6 @@ case ASSERT: {
|
|||
:(before "End Primitive Recipe Implementations")
|
||||
case ASSERT: {
|
||||
if (!ingredients.at(0).at(0)) {
|
||||
// Begin ASSERT in Run
|
||||
if (is_literal_text(current_instruction().ingredients.at(1)))
|
||||
raise << current_instruction().ingredients.at(1).name << '\n' << end();
|
||||
else
|
||||
|
|
|
@ -65,20 +65,6 @@ case CLOSE_CONSOLE: {
|
|||
break;
|
||||
}
|
||||
|
||||
//: Automatically close the console in some situations.
|
||||
:(before "End One-time Setup")
|
||||
atexit(close_console_and_scroll_to_bottom);
|
||||
:(after "Begin ASSERT in Run")
|
||||
if (tb_is_active()) close_console_and_scroll_to_bottom();
|
||||
:(code)
|
||||
void close_console_and_scroll_to_bottom() {
|
||||
if (!tb_is_active()) return;
|
||||
// leave the screen in a relatively clean state
|
||||
tb_set_cursor(tb_width()-1, tb_height()-1);
|
||||
cout << "\r\n";
|
||||
tb_shutdown();
|
||||
}
|
||||
|
||||
:(before "End Primitive Recipe Declarations")
|
||||
CLEAR_DISPLAY,
|
||||
:(before "End Primitive Recipe Numbers")
|
||||
|
|
Loading…
Reference in New Issue