aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikolai Aleksandrovich Pavlov <kp-pav@yandex.ru>2017-02-15 03:21:06 +0300
committerJustin M. Keyes <justinkz@gmail.com>2017-02-15 01:21:06 +0100
commit64c375c589437b811027c5602ecd3969edc162cb (patch)
tree1bb30ef404f25edcdfef280836864f421d47e52f
parent2a50ff7e2fa724fc748068ba19012239886b74dd (diff)
downloadrneovim-64c375c589437b811027c5602ecd3969edc162cb.tar.gz
rneovim-64c375c589437b811027c5602ecd3969edc162cb.tar.bz2
rneovim-64c375c589437b811027c5602ecd3969edc162cb.zip
unittest: Filter out standard defines so that they do not spam stderr (#6113)
-rw-r--r--test/unit/preprocess.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/unit/preprocess.lua b/test/unit/preprocess.lua
index 1c9b290462..4d819e5f23 100644
--- a/test/unit/preprocess.lua
+++ b/test/unit/preprocess.lua
@@ -185,6 +185,30 @@ local function repeated_call(...)
return nil
end
+function Gcc:filter_standard_defines(defines)
+ if not self.standard_defines then
+ local pseudoheader_fname = 'tmp_empty_pseudoheader.h'
+ local pseudoheader_file = io.open(pseudoheader_fname, 'w')
+ pseudoheader_file:close()
+ local standard_defines = repeated_call(self.path,
+ self.preprocessor_extra_flags,
+ self.get_defines_extra_flags,
+ {pseudoheader_fname})
+ os.remove(pseudoheader_fname)
+ self.standard_defines = {}
+ for line in standard_defines:gmatch('[^\n]+') do
+ self.standard_defines[line] = true
+ end
+ end
+ local ret = {}
+ for line in defines:gmatch('[^\n]+') do
+ if not self.standard_defines[line] then
+ ret[#ret + 1] = line
+ end
+ end
+ return table.concat(ret, "\n")
+end
+
-- returns a stream representing a preprocessed form of the passed-in headers.
-- Don't forget to close the stream by calling the close() method on it.
function Gcc:preprocess(previous_defines, ...)
@@ -201,6 +225,7 @@ function Gcc:preprocess(previous_defines, ...)
local defines = repeated_call(self.path, self.preprocessor_extra_flags,
self.get_defines_extra_flags,
{pseudoheader_fname})
+ defines = self:filter_standard_defines(defines)
-- lfs = require("lfs")
-- print("CWD: #{lfs.currentdir!}")