From: Aaron Traas Date: Wed, 28 Jun 2017 16:25:59 +0000 (-0400) Subject: Test coverage: make LCOV ignore code unreachable without interactive shell X-Git-Tag: 1.1~45 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=60847652aa39476bd21e7ec0a339b99abd73845d;p=open-adventure.git Test coverage: make LCOV ignore code unreachable without interactive shell --- diff --git a/misc.c b/misc.c index 81f8e2b..0b28f00 100644 --- a/misc.c +++ b/misc.c @@ -252,7 +252,10 @@ char* get_input() input = NULL; size_t n = 0; if (isatty(0)) + // LCOV_EXCL_START + // Should be unreachable in tests, as they will use a non-interactive shell. printf("%s", input_prompt); + // LCOV_EXCL_STOP IGNORE(getline(&input, &n, stdin)); } @@ -289,10 +292,13 @@ bool yes(const char* question, const char* yes_response, const char* no_response speak(question); reply = get_input(); - if (reply == NULL) { - linenoiseFree(reply); - exit(EXIT_SUCCESS); - } + if (reply == NULL) { + // LCOV_EXCL_START + // Should be unreachable. Reply should never be NULL + linenoiseFree(reply); + exit(EXIT_SUCCESS); + // LCOV_EXCL_STOP + } char* firstword = (char*) xmalloc(strlen(reply)+1); sscanf(reply, "%s", firstword);