aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/includes/CMakeLists.txt15
-rw-r--r--test/includes/Makefile11
-rw-r--r--test/unit/helpers.moon12
3 files changed, 25 insertions, 13 deletions
diff --git a/test/includes/CMakeLists.txt b/test/includes/CMakeLists.txt
new file mode 100644
index 0000000000..a139683b42
--- /dev/null
+++ b/test/includes/CMakeLists.txt
@@ -0,0 +1,15 @@
+file(GLOB_RECURSE PRE_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} pre/*.h)
+
+foreach(hfile ${PRE_HEADERS})
+ string(REGEX REPLACE ^pre/ post/ post_hfile ${hfile})
+ get_filename_component(hdir ${CMAKE_CURRENT_BINARY_DIR}/${post_hfile} PATH)
+ file(MAKE_DIRECTORY ${hdir})
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${post_hfile}
+ COMMAND ${CMAKE_C_COMPILER} -std=c99 -E -P
+ ${CMAKE_CURRENT_SOURCE_DIR}/${hfile}
+ -o ${CMAKE_CURRENT_BINARY_DIR}/${post_hfile})
+ list(APPEND POST_HEADERS ${post_hfile})
+endforeach()
+
+add_custom_target(unittest-headers DEPENDS ${POST_HEADERS})
diff --git a/test/includes/Makefile b/test/includes/Makefile
deleted file mode 100644
index 740d571504..0000000000
--- a/test/includes/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-POST = $(shell find pre -name '*.h' | sed 's/^pre/post/')
-
-all: $(POST)
-
-$(POST): post/%: pre/%
- @echo GEN $*
- @mkdir -p $(@D)
- @cc -std=c99 -E -P $< -o $@
-
-clean:
- rm -rf post
diff --git a/test/unit/helpers.moon b/test/unit/helpers.moon
index d41a7465d6..77d491a008 100644
--- a/test/unit/helpers.moon
+++ b/test/unit/helpers.moon
@@ -1,7 +1,11 @@
ffi = require 'ffi'
-- load neovim shared library
-libnvim = ffi.load './build/src/libnvim-test.so'
+testlib = os.getenv 'NVIM_TEST_LIB'
+unless testlib
+ testlib = './build/src/libnvim-test.so'
+
+libnvim = ffi.load testlib
-- Luajit ffi parser doesn't understand preprocessor directives, so
-- this helper function removes common directives before passing it the to ffi.
@@ -22,8 +26,12 @@ cimport = (path) ->
return libnvim
+testinc = os.getenv 'TEST_INCLUDES'
+unless testinc
+ testinc = './build/test/includes/post'
+
cppimport = (path) ->
- return cimport './test/includes/post/' .. path
+ return cimport testinc .. '/' .. path
cimport './src/types.h'