test: write_file(): support append-mode

This commit is contained in:
Justin M. Keyes 2017-12-04 22:28:04 +01:00
parent 7f386b175c
commit 5f288220f9

View File

@ -334,8 +334,8 @@ local function feed_command(...)
end
-- Dedent the given text and write it to the file name.
local function write_file(name, text, dont_dedent)
local file = io.open(name, 'w')
local function write_file(name, text, no_dedent, append)
local file = io.open(name, (append and 'a' or 'w'))
if type(text) == 'table' then
-- Byte blob
local bytes = text
@ -343,7 +343,7 @@ local function write_file(name, text, dont_dedent)
for _, char in ipairs(bytes) do
text = ('%s%c'):format(text, char)
end
elseif not dont_dedent then
elseif not no_dedent then
text = dedent(text)
end
file:write(text)