Test coverage: make LCOV ignore code unreachable without interactive shell
This commit is contained in:
parent
6521d49c07
commit
60847652aa
1 changed files with 10 additions and 4 deletions
14
misc.c
14
misc.c
|
@ -252,7 +252,10 @@ char* get_input()
|
||||||
input = NULL;
|
input = NULL;
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
if (isatty(0))
|
if (isatty(0))
|
||||||
|
// LCOV_EXCL_START
|
||||||
|
// Should be unreachable in tests, as they will use a non-interactive shell.
|
||||||
printf("%s", input_prompt);
|
printf("%s", input_prompt);
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
IGNORE(getline(&input, &n, stdin));
|
IGNORE(getline(&input, &n, stdin));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,10 +292,13 @@ bool yes(const char* question, const char* yes_response, const char* no_response
|
||||||
speak(question);
|
speak(question);
|
||||||
|
|
||||||
reply = get_input();
|
reply = get_input();
|
||||||
if (reply == NULL) {
|
if (reply == NULL) {
|
||||||
linenoiseFree(reply);
|
// LCOV_EXCL_START
|
||||||
exit(EXIT_SUCCESS);
|
// Should be unreachable. Reply should never be NULL
|
||||||
}
|
linenoiseFree(reply);
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
|
}
|
||||||
|
|
||||||
char* firstword = (char*) xmalloc(strlen(reply)+1);
|
char* firstword = (char*) xmalloc(strlen(reply)+1);
|
||||||
sscanf(reply, "%s", firstword);
|
sscanf(reply, "%s", firstword);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue