notcurses_init: don't treat setup_signals as fatal error #1168

This commit is contained in:
nick black 2020-12-02 13:40:37 -05:00
parent 186b3a2a5e
commit 2c85142b2a
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
2 changed files with 5 additions and 11 deletions

View File

@ -1061,7 +1061,8 @@ notcurses* notcurses_init(const notcurses_options* opts, FILE* outfp){
if(setup_signals(ret,
(opts->flags & NCOPTION_NO_QUIT_SIGHANDLERS),
(opts->flags & NCOPTION_NO_WINCH_SIGHANDLER))){
goto err;
// don't treat failure here as an error. it screws up unit tests, and one
// day we'll need support multiple notcurses contexts. FIXME
}
int termerr;
if(setupterm(opts->termtype, ret->ttyfd, &termerr) != OK){

View File

@ -43,7 +43,7 @@ handle_opts(const char** argv){
}
// reset the terminal in the event of early exit (notcurses_init() presumably
// ran, but we don't have the notcurses struct to destroy. so just do it raw.
// ran, but we don't have the notcurses struct to destroy, so just do it raw).
static void
reset_terminal(){
int fd = open("/dev/tty", O_RDWR|O_CLOEXEC);
@ -103,22 +103,15 @@ auto main(int argc, const char **argv) -> int {
std::cout << "Running with TERM=" << term << std::endl;
doctest::Context context;
context.setOption("order-by", "name"); // sort the test cases by their name
context.setOption("order-by", "name"); // sort the test cases by their name
context.applyCommandLine(argc, argv);
// overrides
context.setOption("no-breaks", true); // don't break in the debugger when assertions fail
context.setOption("no-breaks", true); // don't break in the debugger when assertions fail
dt_removed args(argv);
handle_opts(argv);
int res = context.run(); // run
if(context.shouldExit()){ // important - query flags (and --exit) rely on the user doing this
return res; // propagate the result of the tests
}
// if we exited via REQUIRE(), we likely left the terminal in an invalid
// state. go ahead and reset it manually.
if(res){