commit 1d98034bec23a98dae48660d895840b6f6403d93 from: Mark Jamsek via: Thomas Adam date: Fri Apr 14 16:28:09 2023 UTC release tog_io regress mock term resources in main() ok stsp@ commit - ffa5bcf7b7aede7ffd71ddaea07ad9eae5b3c13d commit + 1d98034bec23a98dae48660d895840b6f6403d93 blob - ca273f088abf440f2971a8633e52b3f2fe3bb8c9 blob + d3eaae2c29a0159a5edc80578ff93091d1b60976 --- tog/tog.c +++ tog/tog.c @@ -4193,10 +4193,7 @@ init_mock_term(const char *test_script_path) goto done; } - /* - * XXX Perhaps we should define "xterm" as the terminal - * type for standardised testing instead of using $TERM? - */ + /* use local TERM so we test in different environments */ if (newterm(NULL, tog_io.cout, tog_io.cin) == NULL) err = got_error_msg(GOT_ERR_IO, "newterm: failed to initialise curses"); @@ -4278,7 +4275,7 @@ get_in_repo_path_from_argv0(char **in_repo_path, int a static const struct got_error * cmd_log(int argc, char *argv[]) { - const struct got_error *io_err, *error; + const struct got_error *error; struct got_repository *repo = NULL; struct got_worktree *worktree = NULL; struct got_object_id *start_id = NULL; @@ -4416,11 +4413,6 @@ done: if (error == NULL) error = pack_err; } - if (using_mock_io) { - io_err = tog_io_close(); - if (error == NULL) - error = io_err; - } tog_free_refs(); return error; } @@ -5790,7 +5782,7 @@ input_diff_view(struct tog_view **new_view, struct tog static const struct got_error * cmd_diff(int argc, char *argv[]) { - const struct got_error *io_err, *error; + const struct got_error *error; struct got_repository *repo = NULL; struct got_worktree *worktree = NULL; struct got_object_id *id1 = NULL, *id2 = NULL; @@ -5916,11 +5908,6 @@ done: if (error == NULL) error = pack_err; } - if (using_mock_io) { - io_err = tog_io_close(); - if (error == NULL) - error = io_err; - } tog_free_refs(); return error; } @@ -6895,7 +6882,7 @@ reset_blame_view(struct tog_view *view) static const struct got_error * cmd_blame(int argc, char *argv[]) { - const struct got_error *io_err, *error; + const struct got_error *error; struct got_repository *repo = NULL; struct got_worktree *worktree = NULL; char *cwd = NULL, *repo_path = NULL, *in_repo_path = NULL; @@ -7032,11 +7019,6 @@ done: if (error == NULL) error = pack_err; } - if (using_mock_io) { - io_err = tog_io_close(); - if (error == NULL) - error = io_err; - } tog_free_refs(); return error; } @@ -7869,7 +7851,7 @@ usage_tree(void) static const struct got_error * cmd_tree(int argc, char *argv[]) { - const struct got_error *io_err, *error; + const struct got_error *error; struct got_repository *repo = NULL; struct got_worktree *worktree = NULL; char *cwd = NULL, *repo_path = NULL, *in_repo_path = NULL; @@ -8009,11 +7991,6 @@ done: if (error == NULL) error = pack_err; } - if (using_mock_io) { - io_err = tog_io_close(); - if (error == NULL) - error = io_err; - } tog_free_refs(); return error; } @@ -8761,7 +8738,7 @@ usage_ref(void) static const struct got_error * cmd_ref(int argc, char *argv[]) { - const struct got_error *io_err, *error; + const struct got_error *error; struct got_repository *repo = NULL; struct got_worktree *worktree = NULL; char *cwd = NULL, *repo_path = NULL; @@ -8855,11 +8832,6 @@ done: if (error == NULL) error = pack_err; } - if (using_mock_io) { - io_err = tog_io_close(); - if (error == NULL) - error = io_err; - } tog_free_refs(); return error; } @@ -9726,7 +9698,7 @@ done: int main(int argc, char *argv[]) { - const struct got_error *error = NULL; + const struct got_error *io_err, *error = NULL; const struct tog_cmd *cmd = NULL; int ch, hflag = 0, Vflag = 0; char **cmd_argv = NULL; @@ -9825,6 +9797,11 @@ main(int argc, char *argv[]) error = cmd->cmd_main(argc, cmd_argv ? cmd_argv : argv); } + if (using_mock_io) { + io_err = tog_io_close(); + if (error == NULL) + error = io_err; + } endwin(); if (cmd_argv) { int i;