aboutsummaryrefslogtreecommitdiff
path: root/test/functional/fixtures
diff options
context:
space:
mode:
authorGregory Anders <greg@gpanders.com>2021-08-20 11:45:28 -0600
committerGitHub <noreply@github.com>2021-08-20 10:45:28 -0700
commit50b30de2007961718cc11811a30f6b0f35c3c793 (patch)
tree5bef15d7394ec3ccef0ced4c7e93d68bb11fa015 /test/functional/fixtures
parent599af74514d0d7083c0565005f255e59ecd7e2ad (diff)
downloadrneovim-50b30de2007961718cc11811a30f6b0f35c3c793.tar.gz
rneovim-50b30de2007961718cc11811a30f6b0f35c3c793.tar.bz2
rneovim-50b30de2007961718cc11811a30f6b0f35c3c793.zip
feat(terminal): TermClose: set exit code in v:event.status #15406
Closes #4713
Diffstat (limited to 'test/functional/fixtures')
-rw-r--r--test/functional/fixtures/shell-test.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/test/functional/fixtures/shell-test.c b/test/functional/fixtures/shell-test.c
index b95e563932..4196716799 100644
--- a/test/functional/fixtures/shell-test.c
+++ b/test/functional/fixtures/shell-test.c
@@ -19,7 +19,7 @@ static void flush_wait(void)
static void help(void)
{
- puts("A simple implementation of a shell for testing termopen().");
+ puts("Fake shell");
puts("");
puts("Usage:");
puts(" shell-test --help");
@@ -42,6 +42,8 @@ static void help(void)
puts(" 96: foo bar");
puts(" shell-test INTERACT");
puts(" Prints \"interact $ \" to stderr, and waits for \"exit\" input.");
+ puts(" shell-test EXIT {code}");
+ puts(" Exits immediately with exit code \"{code}\".");
}
int main(int argc, char **argv)
@@ -103,7 +105,6 @@ int main(int argc, char **argv)
char input[256];
char cmd[100];
int arg;
- int input_argc;
while (1) {
fprintf(stderr, "interact $ ");
@@ -112,8 +113,7 @@ int main(int argc, char **argv)
break; // EOF
}
- input_argc = sscanf(input, "%99s %d", cmd, &arg);
- if(1 == input_argc) {
+ if(1 == sscanf(input, "%99s %d", cmd, &arg)) {
arg = 0;
}
if (strcmp(cmd, "exit") == 0) {
@@ -122,6 +122,15 @@ int main(int argc, char **argv)
fprintf(stderr, "command not found: %s\n", cmd);
}
}
+ } else if (strcmp(argv[1], "EXIT") == 0) {
+ int code = 1;
+ if (argc >= 3) {
+ if (sscanf(argv[2], "%d", &code) != 1) {
+ fprintf(stderr, "Invalid exit code: %s\n", argv[2]);
+ return 2;
+ }
+ }
+ return code;
} else {
fprintf(stderr, "Unknown first argument: %s\n", argv[1]);
return 3;