diff options
author | Michael Reed <Pyrohh@users.noreply.github.com> | 2015-07-06 04:07:23 -0400 |
---|---|---|
committer | Michael Reed <Pyrohh@users.noreply.github.com> | 2015-07-06 04:07:23 -0400 |
commit | 1b78ad1c4d1533fe3089b9744a5306616e562f3e (patch) | |
tree | 19a6e6c0de104ad0d88031e7d255c0c05d3da080 /test/functional/helpers.lua | |
parent | deab194413af1475f8f4d8657500c1250521059e (diff) | |
parent | 8f4e3a68a88a7c98afa3ff8c53e98d7ceb32fc15 (diff) | |
download | rneovim-1b78ad1c4d1533fe3089b9744a5306616e562f3e.tar.gz rneovim-1b78ad1c4d1533fe3089b9744a5306616e562f3e.tar.bz2 rneovim-1b78ad1c4d1533fe3089b9744a5306616e562f3e.zip |
Merge pull request #2932 from lucc/helpers/write_file
[RDY] tests: Add write_file helper function
Reviewed-by: Florian Walch <florian@fwalch.com>
Reviewed-by: Michael Reed <m.reed@mykolab.com>
Diffstat (limited to 'test/functional/helpers.lua')
-rw-r--r-- | test/functional/helpers.lua | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index 3d02aa7fdd..33d04616a0 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -207,12 +207,17 @@ local function execute(...) end end +-- Dedent the given text and write it to the file name. +local function write_file(name, text) + local file = io.open(name, 'w') + file:write(dedent(text)) + file:flush() + file:close() +end + local function source(code) local tmpname = os.tmpname() - local tmpfile = io.open(tmpname, "w") - tmpfile:write(code) - tmpfile:flush() - tmpfile:close() + write_file(tmpname, code) nvim_command('source '..tmpname) os.remove(tmpname) end @@ -315,5 +320,6 @@ return { curtab = curtab, curbuf_contents = curbuf_contents, wait = wait, - set_session = set_session + set_session = set_session, + write_file = write_file } |