From 16da3a6fe01de74eaebfd4750dabe27b3b7ab068 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 17 Oct 2016 23:56:39 +0200 Subject: [PATCH] test: system(): backgrounded shell command These tests are essentially affirming a regression vs Vim. In Vim, :echo system('cat - &', 'foo') returns "foo", because Vim internally wraps the command with shell-specific syntax to redirect the streams from /dev/null[1]. That can't work in Nvim because we use pipes directly (instead of temp files) and don't wrap the command with shell-specific redirection syntax. References #3529 References #5241 [1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_03_02 --- runtime/doc/vim_diff.txt | 1 + .../{shell => ex_cmds}/bang_filter_spec.lua | 0 .../{ => ex_cmds}/dict_notifications_spec.lua | 0 .../{shell => ex_cmds}/viml_system_spec.lua | 14 ++++++++++---- 4 files changed, 11 insertions(+), 4 deletions(-) rename test/functional/{shell => ex_cmds}/bang_filter_spec.lua (100%) rename test/functional/{ => ex_cmds}/dict_notifications_spec.lua (100%) rename test/functional/{shell => ex_cmds}/viml_system_spec.lua (97%) diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index f036b4427e..1598beaaa0 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -108,6 +108,7 @@ Options: Commands: |:CheckHealth| + |:drop| is available on all platforms |:Man| is available by default, with many improvements such as completion Functions: diff --git a/test/functional/shell/bang_filter_spec.lua b/test/functional/ex_cmds/bang_filter_spec.lua similarity index 100% rename from test/functional/shell/bang_filter_spec.lua rename to test/functional/ex_cmds/bang_filter_spec.lua diff --git a/test/functional/dict_notifications_spec.lua b/test/functional/ex_cmds/dict_notifications_spec.lua similarity index 100% rename from test/functional/dict_notifications_spec.lua rename to test/functional/ex_cmds/dict_notifications_spec.lua diff --git a/test/functional/shell/viml_system_spec.lua b/test/functional/ex_cmds/viml_system_spec.lua similarity index 97% rename from test/functional/shell/viml_system_spec.lua rename to test/functional/ex_cmds/viml_system_spec.lua index b8de7cc86f..b8f1f87f30 100644 --- a/test/functional/shell/viml_system_spec.lua +++ b/test/functional/ex_cmds/viml_system_spec.lua @@ -1,7 +1,3 @@ --- Specs for --- - `system()` --- - `systemlist()` - local helpers = require('test.functional.helpers')(after_each) local eq, clear, eval, feed, nvim = helpers.eq, helpers.clear, helpers.eval, helpers.feed, helpers.nvim @@ -120,12 +116,22 @@ describe('system()', function() it('returns the program output', function() eq("echoed", eval('system("echo -n echoed")')) end) + it('to backgrounded command does not crash', function() + -- This is indeterminate, just exercise the codepath. + eval('system("echo -n echoed &")') + eq(2, eval("1+1")) -- Still alive? + end) end) describe('passing input', function() it('returns the program output', function() eq("input", eval('system("cat -", "input")')) end) + it('to backgrounded command does not crash', function() + -- This is indeterminate, just exercise the codepath. + eval('system("cat - &", "input")') + eq(2, eval("1+1")) -- Still alive? + end) end) describe('passing a lot of input', function()