tests: Fix repeated_popen_r usage, rename the function

This commit is contained in:
ZyX
2017-03-18 00:16:23 +03:00
parent 0e9286a19e
commit 3cd7bf31e2
3 changed files with 16 additions and 17 deletions

View File

@@ -9,7 +9,7 @@ local nvim_prog = helpers.nvim_prog
local write_file = helpers.write_file
local popen_w = global_helpers.popen_w
local repeated_popen_r = global_helpers.repeated_popen_r
local repeated_read_cmd = global_helpers.repeated_read_cmd
describe('Command-line option', function()
describe('-s', function()
@@ -48,10 +48,9 @@ describe('Command-line option', 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 = repeated_popen_r(
local stdout = repeated_read_cmd(
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)

View File

@@ -257,7 +257,7 @@ local function which(exe)
end
end
local function repeated_popen_r(...)
local function repeated_read_cmd(...)
for _ = 1, 10 do
local stream = popen_r(...)
local ret = stream:read('*a')
@@ -286,5 +286,5 @@ return {
argss_to_cmd = argss_to_cmd,
popen_r = popen_r,
popen_w = popen_w,
repeated_popen_r = repeated_popen_r,
repeated_read_cmd = repeated_read_cmd,
}

View File

@@ -5,7 +5,7 @@ local ffi = require("ffi")
local global_helpers = require('test.helpers')
local argss_to_cmd = global_helpers.argss_to_cmd
local repeated_popen_r = global_helpers.repeated_popen_r
local repeated_read_cmd = global_helpers.repeated_read_cmd
local ccs = {}
@@ -162,7 +162,7 @@ function Gcc:filter_standard_defines(defines)
local pseudoheader_fname = 'tmp_empty_pseudoheader.h'
local pseudoheader_file = io.open(pseudoheader_fname, 'w')
pseudoheader_file:close()
local standard_defines = repeated_popen_r(self.path,
local standard_defines = repeated_read_cmd(self.path,
self.preprocessor_extra_flags,
self.get_defines_extra_flags,
{pseudoheader_fname})
@@ -194,7 +194,7 @@ function Gcc:preprocess(previous_defines, ...)
pseudoheader_file:flush()
pseudoheader_file:close()
local defines = repeated_popen_r(self.path, self.preprocessor_extra_flags,
local defines = repeated_read_cmd(self.path, self.preprocessor_extra_flags,
self.get_defines_extra_flags,
{pseudoheader_fname})
defines = self:filter_standard_defines(defines)
@@ -205,7 +205,7 @@ function Gcc:preprocess(previous_defines, ...)
-- io.stderr\write("CWD: #{lfs.currentdir!}\n")
-- io.stderr\write("CMD: #{cmd}\n")
local declarations = repeated_popen_r(self.path,
local declarations = repeated_read_cmd(self.path,
self.preprocessor_extra_flags,
self.get_declarations_extra_flags,
{pseudoheader_fname})