commit e430586ec36e2bb1646191682f434e45fb871d26
Author: Kornel Benko <[email protected]>
Date:   Wed Oct 28 17:59:28 2015 +0100

    Cmake tests: Get rid of use of command 'env', which is not available under 
Windows.

diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index bfbcdfd..afcceb5 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -38,11 +38,11 @@ foreach(bns ${layout_files} ${module_files})
   if("${_checktype}" STREQUAL "module")
     file(WRITE "${LYX_TESTS_USERDIR}/layouts/test${bn}.layout" "#% Do not 
delete the line below; configure depends on this\n")
     file(APPEND "${LYX_TESTS_USERDIR}/layouts/test${bn}.layout" "#  
\\DeclareLaTeXClass{test${bn}}\n")
-
     file(APPEND "${LYX_TESTS_USERDIR}/layouts/test${bn}.layout" "Format 55\n")
     file(APPEND "${LYX_TESTS_USERDIR}/layouts/test${bn}.layout" "Input 
${bns}\n")
     add_test(NAME "check_layout/${bns}"
-      COMMAND env LYX_USERDIR_22x=${LYX_TESTS_USERDIR} 
$<TARGET_FILE:check_layout> "${LYX_TESTS_USERDIR}/layouts/test${bn}" 
"${CMAKE_CURRENT_BINARY_DIR}/${bn}.out${_checktype}")
+      COMMAND $<TARGET_FILE:check_layout> 
"${LYX_TESTS_USERDIR}/layouts/test${bn}" 
"${CMAKE_CURRENT_BINARY_DIR}/${bn}.out${_checktype}")
+    set_tests_properties("check_layout/${bns}" PROPERTIES ENVIRONMENT 
${LYX_USERDIR_VER}=${LYX_TESTS_USERDIR})
   else()
     add_test(NAME "check_layout/${bns}"
       COMMAND check_layout "${TOP_SRC_DIR}/lib/layouts/${bn}" 
"${CMAKE_CURRENT_BINARY_DIR}/${bn}.out${_checktype}")
diff --git a/src/tex2lyx/test/CMakeLists.txt b/src/tex2lyx/test/CMakeLists.txt
index c513d6e..304e162 100644
--- a/src/tex2lyx/test/CMakeLists.txt
+++ b/src/tex2lyx/test/CMakeLists.txt
@@ -64,8 +64,11 @@ add_dependencies(lyx_run_tests ${_tex2lyx} ${_lyx})
 add_custom_command(
   OUTPUT LyxTestFiles
   COMMAND ${CMAKE_COMMAND} -E touch LyxTestFiles
-  COMMAND env LYX_USERDIR_VER=${LYX_USERDIR_VER} 
-    ${LYX_PYTHON_EXECUTABLE} "${runtestsScript}" $<TARGET_FILE:${_tex2lyx}> 
"${scriptDir}" "${CMAKE_CURRENT_SOURCE_DIR}"
+  COMMAND ${CMAKE_COMMAND}
+    -DENVIRON="${LYX_USERDIR_VER}=${LYX_TESTS_USERDIR}"
+    -DCOMMAND="${LYX_PYTHON_EXECUTABLE}"
+    
-DPARAMS="${runtestsScript}'$<TARGET_FILE:${_tex2lyx}>'${scriptDir}'${CMAKE_CURRENT_SOURCE_DIR}"
+    -P ${TOP_SRC_DIR}/src/tex2lyx/test/env_custom_command.cmake
   WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
   DEPENDS ${_tex2lyx} ${_lyx}
 )
diff --git a/src/tex2lyx/test/env_custom_command.cmake 
b/src/tex2lyx/test/env_custom_command.cmake
new file mode 100644
index 0000000..24acaae
--- /dev/null
+++ b/src/tex2lyx/test/env_custom_command.cmake
@@ -0,0 +1,40 @@
+# This file is part of LyX, the document processor.
+# Licence details can be found in the file COPYING.
+#
+# Copyright (c) 2015 Kornel Benko <[email protected]>
+#
+# Environ and parameter strings are separated by "'"
+# Script should be called like:
+#   add_custom_command(
+#     COMMAND ${CMAKE_COMMAND}
+#     -DENVIRON="${LYX_USERDIR_VER}=${LYX_TESTS_USERDIR}" \
+#     -DCOMMAND="${LYX_PYTHON_EXECUTABLE}" \
+#     
-DPARAMS="${runtestsScript}'$<TARGET_FILE:${_tex2lyx}>'${scriptDir}'${CMAKE_CURRENT_SOURCE_DIR}"
+#     -P ${TOP_SRC_DIR}/src/tex2lyx/test/env_custom_command.cmake
+#     WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
+#     DEPENDS ...
+#     )
+
+string(REGEX MATCHALL "[^']+" ENVIRON_LIST "${ENVIRON}")
+foreach(_env ${ENVIRON_LIST})
+  if (_env MATCHES "^\([^=]+\)=\(.*\)$")
+    set(ENV{${CMAKE_MATCH_1}} ${CMAKE_MATCH_2})
+    #message(STATUS "setting env ${CMAKE_MATCH_1}=${CMAKE_MATCH_2}")
+  else()
+    message(FATAL_ERROR "Wrong environment string \"${_env}\"")
+  endif()
+endforeach()
+
+string(REGEX MATCHALL "[^']+" parameters "${PARAMS}")
+execute_process(COMMAND "${COMMAND}" ${parameters}
+  RESULT_VARIABLE _err
+  OUTPUT_VARIABLE _out)
+
+message(STATUS ${_out})
+#message(STATUS "Error output of \"${COMMAND}\" " ${parameters} " = ${_err}")
+string(COMPARE NOTEQUAL  ${_err} 0 _erg)
+
+if(_erg)
+  message(FATAL_ERROR "\"${COMMAND}\" ${parameters} failed")
+endif()
+

Reply via email to