Am Dienstag, 27. Oktober 2015 um 14:33:59, schrieb Kornel Benko <[email protected]>
> Am Dienstag, 27. Oktober 2015 um 12:34:47, schrieb Kornel Benko 
> <[email protected]>
> > Am Dienstag, 27. Oktober 2015 um 11:48:20, schrieb Vincent van Ravesteijn 
> > <[email protected]>
> > > >>
> > > >> Well yes, there is no "env" command on Windows.
>
> ...
>
> I tried to remove 'env'. The attached still works for me.
>
> > > Vincent
> >

It looks like the relevant code to set environment for tests added by 
add_test() command
is in the cmake-sources at lest since february 2009. Searching the net, there 
are posts
mentioning cmake2.6 with this feature.

So I cannot imagine, why the patch should break anything on linux. But it may 
help for Windows.
(new file env_custom_command.cmake belongs to src/tex2lyx/test/ dir)

Scott, OK to commit?

        Kornel
# 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()

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}
 )

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to