aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ex_cmds/write_spec.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2016-10-21 22:03:01 +0200
committerGitHub <noreply@github.com>2016-10-21 22:03:01 +0200
commit1ff162c0d99c67043e8b10704e2426192e4f2abf (patch)
tree237254885da93f3ab6089ca63e03047071e99c65 /test/functional/ex_cmds/write_spec.lua
parent82f30bfeda2f291d3b2f3d8fee79dd9ace42a9aa (diff)
downloadrneovim-1ff162c0d99c67043e8b10704e2426192e4f2abf.tar.gz
rneovim-1ff162c0d99c67043e8b10704e2426192e4f2abf.tar.bz2
rneovim-1ff162c0d99c67043e8b10704e2426192e4f2abf.zip
os_nodetype: open fd with O_NONBLOCK (#5515)
Closes #5267 Helped-by: oni-link <knil.ino@gmail.com>
Diffstat (limited to 'test/functional/ex_cmds/write_spec.lua')
-rw-r--r--test/functional/ex_cmds/write_spec.lua41
1 files changed, 33 insertions, 8 deletions
diff --git a/test/functional/ex_cmds/write_spec.lua b/test/functional/ex_cmds/write_spec.lua
index c1bc5d3140..4ac9f312ef 100644
--- a/test/functional/ex_cmds/write_spec.lua
+++ b/test/functional/ex_cmds/write_spec.lua
@@ -1,20 +1,26 @@
--- Specs for :write
-
local helpers = require('test.functional.helpers')(after_each)
-local eq, eval, clear, write_file, execute, source =
- helpers.eq, helpers.eval, helpers.clear, helpers.write_file,
- helpers.execute, helpers.source
+local eq, eval, clear, write_file, execute, source, insert =
+ helpers.eq, helpers.eval, helpers.clear, helpers.write_file,
+ helpers.execute, helpers.source, helpers.insert
if helpers.pending_win32(pending) then return end
describe(':write', function()
- after_each(function()
+ local function cleanup()
os.remove('test_bkc_file.txt')
os.remove('test_bkc_link.txt')
+ os.remove('test_fifo')
+ end
+ before_each(function()
+ clear()
+ cleanup()
+ end)
+ after_each(function()
+ cleanup()
end)
it('&backupcopy=auto preserves symlinks', function()
- clear('--cmd', 'set backupcopy=auto')
+ execute('set backupcopy=auto')
write_file('test_bkc_file.txt', 'content0')
execute("silent !ln -s test_bkc_file.txt test_bkc_link.txt")
source([[
@@ -27,7 +33,7 @@ describe(':write', function()
end)
it('&backupcopy=no replaces symlink with new file', function()
- clear('--cmd', 'set backupcopy=no')
+ execute('set backupcopy=no')
write_file('test_bkc_file.txt', 'content0')
execute("silent !ln -s test_bkc_file.txt test_bkc_link.txt")
source([[
@@ -38,4 +44,23 @@ describe(':write', function()
eq(eval("['content0']"), eval("readfile('test_bkc_file.txt')"))
eq(eval("['content1']"), eval("readfile('test_bkc_link.txt')"))
end)
+
+ it("appends FIFO file", function()
+ if eval("executable('mkfifo')") == 0 then
+ pending('missing "mkfifo" command', function()end)
+ return
+ end
+
+ local text = "some fifo text from write_spec"
+ assert(os.execute("mkfifo test_fifo"))
+ insert(text)
+
+ -- Blocks until a consumer reads the FIFO.
+ execute("write >> test_fifo")
+
+ -- Read the FIFO, this will unblock the :write above.
+ local fifo = assert(io.open("test_fifo"))
+ eq(text.."\n", fifo:read("*all"))
+ fifo:close()
+ end)
end)