diff options
author | Daniel Hahler <git@thequod.de> | 2019-07-03 22:49:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-03 22:49:13 +0200 |
commit | f6298aba82f5378f5c53ab746c3f976b645d0a98 (patch) | |
tree | 44213f1a6ab85f732486b82cf5c030093ae5e0e1 | |
parent | 0dc73b87f10b67f9a8648cbf8936ba5f76a41def (diff) | |
download | rneovim-f6298aba82f5378f5c53ab746c3f976b645d0a98.tar.gz rneovim-f6298aba82f5378f5c53ab746c3f976b645d0a98.tar.bz2 rneovim-f6298aba82f5378f5c53ab746c3f976b645d0a98.zip |
tests: shell-test: add INTERACT mode (#10405)
Use it to improve ls_spec: it should not use the user's real shell for
performance and other reasons.
-rw-r--r-- | test/functional/ex_cmds/ls_spec.lua | 4 | ||||
-rw-r--r-- | test/functional/fixtures/shell-test.c | 27 |
2 files changed, 30 insertions, 1 deletions
diff --git a/test/functional/ex_cmds/ls_spec.lua b/test/functional/ex_cmds/ls_spec.lua index 0ff6f2da8a..f7bacd7386 100644 --- a/test/functional/ex_cmds/ls_spec.lua +++ b/test/functional/ex_cmds/ls_spec.lua @@ -4,6 +4,8 @@ local command = helpers.command local eq = helpers.eq local eval = helpers.eval local feed = helpers.feed +local nvim = helpers.nvim +local nvim_dir = helpers.nvim_dir local retry = helpers.retry describe(':ls', function() @@ -12,6 +14,8 @@ describe(':ls', function() end) it('R, F for :terminal buffers', function() + nvim('set_option', 'shell', string.format('"%s" INTERACT', nvim_dir..'/shell-test')) + command('edit foo') command('set hidden') command('terminal') diff --git a/test/functional/fixtures/shell-test.c b/test/functional/fixtures/shell-test.c index a744d5df46..6a1f9226d2 100644 --- a/test/functional/fixtures/shell-test.c +++ b/test/functional/fixtures/shell-test.c @@ -40,6 +40,8 @@ static void help(void) puts(" ..."); puts(" 96: test"); puts(" will be printed because byte `a' is equal to 97."); + puts(" shell-test INTERACT"); + puts(" Prints \"interact $ \" to stderr, and waits for \"exit\" input."); } int main(int argc, char **argv) @@ -89,8 +91,31 @@ int main(int argc, char **argv) printf("3: \xc3\xa5\xcc"); wait(); printf("\xb2\n"); wait(); + } else if (strcmp(argv[1], "INTERACT") == 0) { + char input[256]; + char cmd[100]; + int arg; + int input_argc; + + while (1) { + fprintf(stderr, "interact $ "); + + if (fgets(input, sizeof(input), stdin) == NULL) { + break; // EOF + } + + input_argc = sscanf(input, "%s %d", cmd, &arg); + if(1 == input_argc) { + arg = 0; + } + if (strcmp(cmd, "exit") == 0) { + return arg; + } else { + fprintf(stderr, "command not found: %s\n", cmd); + } + } } else { - fprintf(stderr, "Unknown first argument\n"); + fprintf(stderr, "Unknown first argument: %s\n", argv[1]); return 3; } return 0; |