From 2c85142b2a6ff19cb07c3299f35f3c3b3413bc90 Mon Sep 17 00:00:00 2001 From: nick black Date: Wed, 2 Dec 2020 13:40:37 -0500 Subject: [PATCH] notcurses_init: don't treat setup_signals as fatal error #1168 --- src/lib/notcurses.c | 3 ++- tests/main.cpp | 13 +++---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index 09e79d4ab..1420fe1ae 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -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){ diff --git a/tests/main.cpp b/tests/main.cpp index 34747c6c3..2544c5a7b 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -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){