aboutsummaryrefslogtreecommitdiff
path: root/test/functional/core/main_spec.lua
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2017-03-17 00:04:03 +0300
committerZyX <kp-pav@yandex.ru>2017-03-19 14:13:21 +0300
commit0320a58082f922b54cb36ce57064c07a9e781aa8 (patch)
tree74f18e6450124946c5e7b1c8708232241fe55f01 /test/functional/core/main_spec.lua
parent65c41e6c2b5015ff0b0485aadd362c0883a02a85 (diff)
downloadrneovim-0320a58082f922b54cb36ce57064c07a9e781aa8.tar.gz
rneovim-0320a58082f922b54cb36ce57064c07a9e781aa8.tar.bz2
rneovim-0320a58082f922b54cb36ce57064c07a9e781aa8.zip
functests: Check that `-s` works as expected
Diffstat (limited to 'test/functional/core/main_spec.lua')
-rw-r--r--test/functional/core/main_spec.lua60
1 files changed, 60 insertions, 0 deletions
diff --git a/test/functional/core/main_spec.lua b/test/functional/core/main_spec.lua
new file mode 100644
index 0000000000..50c6009b53
--- /dev/null
+++ b/test/functional/core/main_spec.lua
@@ -0,0 +1,60 @@
+local lfs = require('lfs')
+local helpers = require('test.functional.helpers')(after_each)
+local global_helpers = require('test.helpers')
+
+local eq = helpers.eq
+local neq = helpers.neq
+local sleep = helpers.sleep
+local nvim_prog = helpers.nvim_prog
+local write_file = helpers.write_file
+
+local popen_w = global_helpers.popen_w
+local popen_r = global_helpers.popen_r
+
+describe('Command-line option', function()
+ describe('-s', function()
+ local fname = 'Xtest-functional-core-main-s'
+ local dollar_fname = '$' .. fname
+ before_each(function()
+ os.remove(fname)
+ os.remove(dollar_fname)
+ end)
+ after_each(function()
+ os.remove(fname)
+ os.remove(dollar_fname)
+ end)
+ it('treats - as stdin', function()
+ eq(nil, lfs.attributes(fname))
+ local pipe = popen_w(
+ nvim_prog, '-u', 'NONE', '-i', 'NONE', '--headless', '-s', '-',
+ fname)
+ pipe:write(':call setline(1, "42")\n')
+ pipe:write(':wqall!\n')
+ pipe:close()
+ local max_sec = 10
+ while max_sec > 0 do
+ local attrs = lfs.attributes(fname)
+ if attrs then
+ eq(#('42\n'), attrs.size)
+ break
+ else
+ max_sec = max_sec - 1
+ sleep(1000)
+ end
+ end
+ neq(0, max_sec)
+ end)
+ it('does not expand $VAR', function()
+ eq(nil, lfs.attributes(fname))
+ eq(true, not not dollar_fname:find('%$%w+'))
+ write_file(dollar_fname, ':call setline(1, "100500")\n:wqall!\n')
+ local pipe = popen_r(
+ nvim_prog, '-u', 'NONE', '-i', 'NONE', '--headless', '-s', dollar_fname,
+ fname)
+ local stdout = pipe:read('*a')
+ eq('', stdout)
+ local attrs = lfs.attributes(fname)
+ eq(#('100500\n'), attrs.size)
+ end)
+ end)
+end)