diff options
| -rw-r--r-- | doc/testing.txt | 19 | ||||
| -rw-r--r-- | tests/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | tests/CMingw-env-cross.cmake | 40 | ||||
| -rw-r--r-- | tests/FindGLEW.cmake | 2 | ||||
| -rw-r--r-- | tests/dumptest.cc | 4 | ||||
| -rw-r--r-- | tests/echotest.cc | 2 | ||||
| -rwxr-xr-x | tests/test_cmdline_tool.py | 18 | 
7 files changed, 56 insertions, 32 deletions
| diff --git a/doc/testing.txt b/doc/testing.txt index c0edc6f..0ec5649 100644 --- a/doc/testing.txt +++ b/doc/testing.txt @@ -24,11 +24,16 @@ Then, from the QT command prompt:  Cross compiling Linux->Windows: +Additional prerequisities: wine, mingw-cross-env + +Note: CTest harness will only run under Wine under *nix, not under Win32. +  Follow the instructions for cross-compiling with qmake at  -http://en.wikibooks.org/wiki/OpenSCAD_User_Manual +http://en.wikibooks.org/wiki/OpenSCAD_User_Manual , especially the part  +about including the cross-compiler in your PATH. Then:  $ cd tests -$ cmake . -DMINGW_CROSS_ENV_DIR=<mingw dir> -DCMAKE_TOOLCHAIN_FILE=CMingw-env-cross.cmake +$ cmake . -DMINGW_CROSS_ENV_DIR=<mingw-dir> -DCMAKE_TOOLCHAIN_FILE=CMingw-env-cross.cmake  $ make  B) Running tests @@ -89,11 +94,7 @@ A pretty-printed index.html is in a subdir of tests/build/Testing/Temporary  Expected results are found in tests/regression/*  Actual results are found in tests/build/testname-output/* -3. Cross-compiling  - -Cross-compiling of tests has not been automated nor tested - -4. Image-based tests takes a long time, they fail, and the log says 'return -11' +3. Image-based tests takes a long time, they fail, and the log says 'return -11'  Imagemagick may have crashed while comparing the expected images to the   test-run generated (actual) images. You can try using the alternate  @@ -101,12 +102,12 @@ ImageMagick comparison method by by erasing CMakeCache, and re-running  cmake with -DCOMPARATOR=ncc. This will enable the Normalized Cross   Comparison method. -5. Testing images fails with 'morphology not found" for ImageMagick in the log +4. Testing images fails with 'morphology not found" for ImageMagick in the log  Your version of imagemagick is old. Upgrade, or pass -DCOMPARATOR=old to   cmake. The comparison will be of lowered reliability. -6. Other issues +5. Other issues  The OpenSCAD User Manual has a section on buildling. Please check there   for updates: diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4f11a7e..e03c39a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -536,6 +536,9 @@ enable_testing()  # set up custom pretty printing of results  set(INFOCMD "execute_process(COMMAND ${CMAKE_CURRENT_BINARY_DIR}/opencsgtest --info OUTPUT_FILE sysinfo.txt)") +if (MINGW_CROSS_ENV_DIR) +  set(INFOCMD "execute_process(COMMAND wine ${CMAKE_CURRENT_BINARY_DIR}/opencsgtest --info OUTPUT_FILE sysinfo.txt)") +endif()  set(PRETTYCMD "\"${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_pretty_print.py --builddir=${CMAKE_CURRENT_BINARY_DIR}\"")  set(CTEST_CUSTOM_FILE ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake)  set(CTEST_CUSTOM_TXT "\n diff --git a/tests/CMingw-env-cross.cmake b/tests/CMingw-env-cross.cmake index f13fa8c..fc5c912 100644 --- a/tests/CMingw-env-cross.cmake +++ b/tests/CMingw-env-cross.cmake @@ -8,31 +8,38 @@  #  3. make should proceed as normal.   #  # see also +#  +# http://mingw-cross-env.nongnu.org/#requirements  # http://www.vtk.org/Wiki/CMake_Cross_Compiling  # https://bitbucket.org/muellni/mingw-cross-env-cmake/src/2067fcf2d52e/src/cmake-1-toolchain-file.patch  # http://code.google.com/p/qtlobby/source/browse/trunk/toolchain-mingw.cmake  # http://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Link-Options.html  # output of qmake   # -# this file released into public domain by Don Bright 2011  #  # cross-compiler  # -  -set(CMAKE_SYSTEM_NAME Windows)  set(MINGW_CROSS_ENV_DIR $ENV{MINGW_CROSS_ENV_DIR}) -set(CMAKE_C_COMPILER ${MINGW_CROSS_ENV_DIR}/usr/bin/i686-pc-mingw32-gcc) -set(CMAKE_CXX_COMPILER ${MINGW_CROSS_ENV_DIR}/usr/bin/i686-pc-mingw32-g++) -set(CMAKE_RC_COMPILER i686-pc-mingw32-windres) -set(CMAKE_FIND_ROOT_PATH ${MINGW_CROSS_ENV_DIR}/usr/i686-pc-mingw32) +set(BUILD_SHARED_LIBS OFF) +set(CMAKE_SYSTEM_NAME Windows) +set(MSYS 1) +xset(CMAKE_FIND_ROOT_PATH ${MINGW_CROSS_ENV_DIR}/usr/i686-pc-mingw32)  set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)  set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)  set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_C_COMPILER ${MINGW_CROSS_ENV_DIR}/usr/bin/i686-pc-mingw32-gcc) +set(CMAKE_CXX_COMPILER ${MINGW_CROSS_ENV_DIR}/usr/bin/i686-pc-mingw32-g++) +set(CMAKE_RC_COMPILER ${MINGW_CROSS_ENV_DIR}/usr/bin/i686-pc-mingw32-windres) +set(PKG_CONFIG_EXECUTABLE ${MINGW_CROSS_ENV_DIR}/usr/bin/i686-pc-mingw32-pkg-config) +set(QT_QMAKE_EXECUTABLE ${MINGW_CROSS_ENV_DIR}/usr/bin/i686-pc-mingw32-qmake) +set(CMAKE_INSTALL_PREFIX ${MINGW_CROSS_ENV_DIR}/usr/i686-pc-mingw32 CACHE PATH "Installation Prefix") +set(CMAKE_BUILD_TYPE Release CACHE STRING "Debug|Release|RelWithDebInfo|MinSizeRel") +  #  # libraries  # @@ -47,6 +54,7 @@ set( EIGEN2_DIR ${CMAKE_FIND_ROOT_PATH} )  set( CGAL_DIR ${CMAKE_FIND_ROOT_PATH}/lib/CGAL )  set( GLEW_DIR ${CMAKE_FIND_ROOT_PATH} )  set( SKIP_IMAGEMAGICK TRUE ) +set( ImageMagick_convert_EXECUTABLE /usr/bin/convert )  #  # QT @@ -57,9 +65,13 @@ set(QT_MOC_EXECUTABLE ${MINGW_CROSS_ENV_DIR}/usr/bin/i686-pc-mingw32-moc)  set(QT_UIC_EXECUTABLE ${MINGW_CROSS_ENV_DIR}/usr/bin/i686-pc-mingw32-uic)  # -# Cmake fails at mingw-cross. Here we copy the flags and libraries from -# from looking at "qmake && make VERBOSE=1" as well as examining -# the .prl files in mingw-cross-env/usr/i686-pc-mingw32/lib & google +# There are various problems introduced to cmake's linking by the large +# number of libraries needed by OpenSCAD and the complicated build system. +# +# Here we copy the flags and libraries from from looking at  +# "qmake && make VERBOSE=1" as well as examining +# the .prl files in mingw-cross-env/usr/i686-pc-mingw32/lib & using google +# Another good resource are the files under usr/i686-pc-mingw32/mkspecs  #  if (NOT MINGW_CROSS_FLAGS_SET) @@ -76,7 +88,7 @@ endfunction()  function(mingw_cross_env_add_missing_libs)    # mingw_cross_env_info() -  set(mingw_cross_libs msvcr80 imm32 winmm ws2_32 glu32 opengl32 mng lcms tiff jpeg png z) +  set(mingw_cross_libs imm32 winmm ws2_32 glu32 opengl32 mng lcms tiff jpeg png z)    target_link_libraries(opencsgtest ${mingw_cross_libs})    target_link_libraries(csgtermtest ${mingw_cross_libs})    target_link_libraries(csgtexttest ${mingw_cross_libs}) @@ -99,9 +111,9 @@ if( NOT CROSS_DEFS_SET )    add_definitions( -DBOOST_THREAD_USE_LIB )    add_definitions( -DUNICODE ) -  # for TWO_DIGIT_EXPONENT. see stdio.h from mingw-env/usr/i686-pc-mingw32/include -  add_definitions( -D__MSVCRT_VERSION__=0x800 )  -    set(CROSS_DEFS_SET 1) +  endif() + + diff --git a/tests/FindGLEW.cmake b/tests/FindGLEW.cmake index 42b06ff..286fae8 100644 --- a/tests/FindGLEW.cmake +++ b/tests/FindGLEW.cmake @@ -17,7 +17,7 @@ IF (WIN32 AND MSVC)  	ELSE ()  		SET(GLEW_LIB_SEARCH_NAME glew32.lib) # other. untested with OpenSCAD  	ENDIF() -ELSEIF () # GCC +ELSE () # GCC  	SET(GLEW_LIB_SEARCH_NAME "libglew32s.a")  ENDIF () diff --git a/tests/dumptest.cc b/tests/dumptest.cc index f7179d7..f83a993 100644 --- a/tests/dumptest.cc +++ b/tests/dumptest.cc @@ -45,7 +45,6 @@  #include <iostream>  #include <sstream>  #include <fstream> -#include <stdio.h>  using std::string; @@ -66,10 +65,9 @@ string dumptree(const Tree &tree, const AbstractNode &node)  int main(int argc, char **argv)  { -#ifdef WIN32 +#ifdef _MSC_VER    _set_output_format(_TWO_DIGIT_EXPONENT);  #endif -  	if (argc != 3) {  		fprintf(stderr, "Usage: %s <file.scad> <output.txt>\n", argv[0]);  		exit(1); diff --git a/tests/echotest.cc b/tests/echotest.cc index afa3d03..8f145b0 100644 --- a/tests/echotest.cc +++ b/tests/echotest.cc @@ -59,7 +59,7 @@ static void outfile_handler(const std::string &msg, void *userdata) {  int main(int argc, char **argv)  { -#ifdef WIN32 +#ifdef _MSC_VER    _set_output_format(_TWO_DIGIT_EXPONENT);  #endif diff --git a/tests/test_cmdline_tool.py b/tests/test_cmdline_tool.py index 4538984..ef10a19 100755 --- a/tests/test_cmdline_tool.py +++ b/tests/test_cmdline_tool.py @@ -61,7 +61,11 @@ def execute_and_redirect(cmd, params, outfile):      else: return retval  def get_normalized_text(filename): -    text = open(filename).read() +    try:  +        f = open(filename) +        text = f.read() +    except:  +        text = ''      return text.strip("\r\n").replace("\r\n", "\n") + "\n"  def compare_text(expected, actual): @@ -71,8 +75,9 @@ def compare_default(resultfilename):      print >> sys.stderr, 'diff text compare: '      print >> sys.stderr, ' expected textfile: ', expectedfilename      print >> sys.stderr, ' actual textfile: ', resultfilename -    if not compare_text(expectedfilename, resultfilename):  -        execute_and_redirect("diff", [expectedfilename, resultfilename], sys.stderr) +    if not compare_text(expectedfilename, resultfilename): +	if resultfilename:  +            execute_and_redirect("diff", [expectedfilename, resultfilename], sys.stderr)          return False      return True @@ -136,8 +141,13 @@ def run_test(testname, cmd, args):      outputname = os.path.normpath( outputname )      outfile = open(outputname, "wb") +      try: -        proc = subprocess.Popen([cmd] + args + [outputname], stdout=subprocess.PIPE, stderr=subprocess.PIPE) +        if os.path.isfile(cmd+'.exe'): +            cmdline = ['wine']+[cmd+'.exe'] + args + [outputname] +        else: +            cmdline = [cmd] + args + [outputname] +        proc = subprocess.Popen(cmdline, stdout=subprocess.PIPE, stderr=subprocess.PIPE)          errtext = proc.communicate()[1]          if errtext != None and len(errtext) > 0:              print >> sys.stderr, "Error output: " + errtext | 
