diff --git a/doc/testing.txt b/doc/testing.txt index f609b653..ee560a57 100644 --- a/doc/testing.txt +++ b/doc/testing.txt @@ -69,11 +69,9 @@ This is almost the same as adding a new regression test: Migration away from dedicated regression tests: ----------------------------------------------- -Two tests still need an intermediate script that mangles away timestamps and +This test still needs an intermediate script that mangles away timestamps and near-zero floating point numbers: -* dumptest -* echotest * cgalstlsanitytest Some tests are yet to be converted: @@ -85,15 +83,6 @@ These look like tests, but are not actually in use: * modulecachetest * cgalcachetest -In the course of migration, the possibilities of using the OPENSCAD_TESTING -compile time flag go away; that flag used to strip timestamps out of files, -to unify float output, and to tweak the file inclusion paths. With that flag -unused, we get better coverage of the primary code paths, at the cost of -having to do some normalization in the unit testing process (thus the dumptest -and echo test scripts). Especially, having a nonstandard MCAD library in the -user include path can now break things -- but so can having misbehaving -programs in your PATH. - Troubleshooting: ------------------------------ diff --git a/scripts/setenv-unibuild.sh b/scripts/setenv-unibuild.sh index cb0b0a03..cfcf23d7 100644 --- a/scripts/setenv-unibuild.sh +++ b/scripts/setenv-unibuild.sh @@ -43,14 +43,23 @@ setenv_common() setenv_freebsd() { + echo .... freebsd detected. + echo .... if you have freebsd >9, it is advisable to install + echo .... the clang compiler and re-run this script as + echo .... '. ./scripts/setenv-unibuild.sh clang' setenv_common QMAKESPEC=freebsd-g++ QTDIR=/usr/local/share/qt4 + export QMAKESPEC + export QTDIR } setenv_netbsd() { setenv_common + echo --- netbsd build situation is complex. it comes with gcc4.5 + echo --- which is incompatable with updated CGAL. + echo --- you may need to hack with newer gcc to make it work QMAKESPEC=netbsd-g++ QTDIR=/usr/pkg/qt4 PATH=/usr/pkg/qt4/bin:$PATH @@ -75,6 +84,30 @@ setenv_linux_clang() echo QMAKESPEC has been modified: $QMAKESPEC } +setenv_freebsd_clang() +{ + export CC=clang + export CXX=clang++ + export QMAKESPEC=freebsd-clang + + echo CC has been modified: $CC + echo CXX has been modified: $CXX + echo QMAKESPEC has been modified: $QMAKESPEC +} + +setenv_netbsd_clang() +{ + echo --------------------- this is not yet supported. netbsd 6 lacks + echo --------------------- certain things needed for clang support + export CC=clang + export CXX=clang++ + export QMAKESPEC=./patches/mkspecs/netbsd-clang + + echo CC has been modified: $CC + echo CXX has been modified: $CXX + echo QMAKESPEC has been modified: $QMAKESPEC +} + clean_note() { if [ $QT5_SETUP ]; then @@ -125,8 +158,14 @@ if [ "`uname | grep -i 'linux\|debian'`" ]; then fi elif [ "`uname | grep -i freebsd`" ]; then setenv_freebsd + if [ "`echo $* | grep clang`" ]; then + setenv_freebsd_clang + fi elif [ "`uname | grep -i netbsd`" ]; then setenv_netbsd + if [ "`echo $* | grep clang`" ]; then + setenv_netbsd_clang + fi else # guess setenv_common diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index bc2b1798..48f162a0 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -292,6 +292,7 @@ build_cgal() echo "Building CGAL" $version "..." cd $BASEDIR/src rm -rf CGAL-$version + ver4_2="curl --insecure -O https://gforge.inria.fr/frs/download.php/32360/CGAL-4.2.tar.bz2" ver4_1="curl --insecure -O https://gforge.inria.fr/frs/download.php/31640/CGAL-4.1.tar.bz2" ver4_0_2="curl --insecure -O https://gforge.inria.fr/frs/download.php/31174/CGAL-4.0.2.tar.bz2" ver4_0="curl --insecure -O https://gforge.inria.fr/frs/download.php/30387/CGAL-4.0.tar.gz" @@ -299,7 +300,7 @@ build_cgal() ver3_8="curl --insecure -O https://gforge.inria.fr/frs/download.php/28500/CGAL-3.8.tar.gz" ver3_7="curl --insecure -O https://gforge.inria.fr/frs/download.php/27641/CGAL-3.7.tar.gz" vernull="echo already downloaded..skipping" - download_cmd=ver`echo $version | sed s/"\."/"_"/` + download_cmd=ver`echo $version | sed s/"\."/"_"/ | sed s/"\."/"_"/` if [ -e CGAL-$version.tar.gz ]; then download_cmd=vernull; @@ -308,6 +309,7 @@ build_cgal() download_cmd=vernull; fi + eval echo "$"$download_cmd `eval echo "$"$download_cmd` zipper=gzip @@ -574,7 +576,7 @@ if [ $1 ]; then exit $? fi if [ $1 = "cgal" ]; then - build_cgal 4.1 use-sys-libs + build_cgal 4.0.2 use-sys-libs exit $? fi if [ $1 = "opencsg" ]; then @@ -605,7 +607,7 @@ build_gmp 5.0.5 build_mpfr 3.1.1 build_boost 1.53.0 # NB! For CGAL, also update the actual download URL in the function -build_cgal 4.1 +build_cgal 4.0.2 build_glew 1.9.0 build_opencsg 1.3.2 diff --git a/src/openscad.cc b/src/openscad.cc index 5a219acb..49ec31cc 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -83,6 +83,21 @@ using std::vector; using boost::lexical_cast; using boost::is_any_of; +class Echostream : public std::ofstream +{ +public: + Echostream( const char * filename ) : std::ofstream( filename ) { + set_output_handler( &Echostream::output, this ); + } + static void output( const std::string &msg, void *userdata ) { + Echostream *thisp = static_cast(userdata); + *thisp << msg << "\n"; + } + ~Echostream() { + this->close(); + } +}; + static void help(const char *progname) { int tab = int(strlen(progname))+8; @@ -191,7 +206,7 @@ int cmdline( const char* deps_output_file, const char* filename, Camera &camera, const char *png_output_file = NULL; const char *ast_output_file = NULL; const char *term_output_file = NULL; - bool null_output = false; + const char *echo_output_file = NULL; std::string suffix = boosty::extension_str( output_file ); boost::algorithm::to_lower( suffix ); @@ -203,7 +218,7 @@ int cmdline( const char* deps_output_file, const char* filename, Camera &camera, else if (suffix == ".png") png_output_file = output_file; else if (suffix == ".ast") ast_output_file = output_file; else if (suffix == ".term") term_output_file = output_file; - else if (strcmp(output_file, "null") == 0) null_output = true; + else if (suffix == ".echo") echo_output_file = output_file; else { fprintf(stderr, "Unknown suffix for output file %s\n", output_file); return 1; @@ -215,6 +230,9 @@ int cmdline( const char* deps_output_file, const char* filename, Camera &camera, #if 0 && DEBUG top_ctx.dump(NULL, NULL); #endif + shared_ptr echostream; + if (echo_output_file) + echostream.reset( new Echostream( echo_output_file ) ); FileModule *root_module; ModuleInstantiation root_inst("group"); @@ -301,8 +319,8 @@ int cmdline( const char* deps_output_file, const char* filename, Camera &camera, } else { #ifdef ENABLE_CGAL - if ((null_output || png_output_file) && !(renderer==Render::CGAL)) { - // null output or OpenCSG png -> don't necessarily need CGALMesh evaluation + if ((echo_output_file || png_output_file) && !(renderer==Render::CGAL)) { + // echo or OpenCSG png -> don't necessarily need CGALMesh evaluation } else { root_N = cgalevaluator.evaluateCGALMesh(*tree.root()); } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5405d04b..8e082049 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,5 +1,7 @@ # instructions - see ../doc/testing.txt +set(DEBUG_OSCD 1) # print debug info during cmake + cmake_minimum_required(VERSION 2.8) if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER 2.8.3) # Explicitly use new include policy to avoid globally shadowing included modules @@ -38,6 +40,7 @@ set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}") # Build debug build as default if(NOT CMAKE_BUILD_TYPE) +<<<<<<< HEAD # set(CMAKE_BUILD_TYPE Release) if(CMAKE_COMPILER_IS_GNUCXX) execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) @@ -49,6 +52,10 @@ if(NOT CMAKE_BUILD_TYPE) else() set(CMAKE_BUILD_TYPE RelWithDebInfo) endif() +======= + set(CMAKE_BUILD_TYPE RelWithDebInfo) +# set(CMAKE_BUILD_TYPE Release) +>>>>>>> 4ebd8136a83325e67be7a39c9349ec8812aa05c1 endif() if(CMAKE_COMPILER_IS_GNUCXX) @@ -124,12 +131,15 @@ endif() # function(inclusion user_set_path found_paths) - # If user_set_path indicates an env. variable was specifically - # set by the user, then found_paths become an include priority (prepend); - # otherwise found_paths are stuck on the end of the include flags (append). + # Set up compiler include paths with prepend/append rules. Input is + # a path and a set of paths. If user_set_path matches anything in found_paths + # then we prepend the found_paths because we assume the user wants + # their set_paths to be a priority. - # message(STATUS "inclusion ${user_set_path} ${found_paths}") - # message(STATUS "inclusion ${${user_set_path}} ${${found_paths}}") + if (DEBUG_OSCD) + message(STATUS "inclusion ${user_set_path} ${found_paths}") + message(STATUS "inclusion ${${user_set_path}} ${${found_paths}}") + endif() set( inclusion_match 0 ) foreach( found_path ${${found_paths}} ) if (${found_path} MATCHES ${${user_set_path}}.*) @@ -138,10 +148,14 @@ function(inclusion user_set_path found_paths) endforeach() if (user_set_path AND inclusion_match) include_directories(BEFORE ${${found_paths}}) - # message(STATUS "inclusion prepend ${${found_paths}} for ${user_set_path}") + if (DEBUG_OSCD) + message(STATUS "inclusion prepend ${${found_paths}} for ${user_set_path}") + endif() else() include_directories(AFTER ${${found_paths}}) - # message(STATUS "inclusion append ${${found_paths}} for ${user_set_path}") + if (DEBUG_OSCD) + message(STATUS "inclusion append ${${found_paths}} for ${user_set_path}") + endif() endif() set( inclusion_match 0 ) endfunction() @@ -339,6 +353,13 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") set(FLEX_EXECUTABLE /usr/local/bin/flex) endif() +# prepend the dir where deps were built +if (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "") + set(OSCAD_DEPS "") + set(OSCAD_DEPS_PATHS $ENV{OPENSCAD_LIBRARIES}/include) + inclusion(OSCAD_DEPS OSCAD_DEPS_PATHS) +endif() + if(${CMAKE_SYSTEM_NAME} MATCHES "NetBSD") include_directories( /usr/pkg/include /usr/X11R7/include ) set(FLEX_EXECUTABLE /usr/pkg/bin/flex) @@ -567,9 +588,9 @@ target_link_libraries(cgalcachetest tests-cgal ${TESTS-CGAL-LIBRARIES} ${GLEW_LI # # openscad no-qt # -add_executable(openscad ../src/openscad.cc) -set_target_properties(openscad PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing -DEIGEN_DONT_ALIGN -DENABLE_CGAL -DENABLE_OPENCSG ${CGAL_CXX_FLAGS_INIT}") -target_link_libraries(openscad tests-offscreen tests-cgal tests-nocgal ${TESTS-CORE-LIBRARIES} ${TESTS-CGAL-LIBRARIES} ${GLEW_LIBRARY} ${Boost_LIBRARIES} ${OPENCSG_LIBRARY} ${COCOA_LIBRARY} ) +add_executable(openscad_nogui ../src/openscad.cc) +set_target_properties(openscad_nogui PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing -DEIGEN_DONT_ALIGN -DENABLE_CGAL -DENABLE_OPENCSG ${CGAL_CXX_FLAGS_INIT}") +target_link_libraries(openscad_nogui tests-offscreen tests-cgal tests-nocgal ${TESTS-CORE-LIBRARIES} ${TESTS-CGAL-LIBRARIES} ${GLEW_LIBRARY} ${Boost_LIBRARIES} ${OPENCSG_LIBRARY} ${COCOA_LIBRARY} ) # # GUI binary tests @@ -596,9 +617,9 @@ target_link_libraries(openscad tests-offscreen tests-cgal tests-nocgal ${TESTS-C #endif() if(WIN32) - set(OPENSCAD_BINPATH "${CMAKE_CURRENT_BINARY_DIR}/openscad.exe") + set(OPENSCAD_BINPATH "${CMAKE_CURRENT_BINARY_DIR}/openscad_nogui.exe") else() - set(OPENSCAD_BINPATH "${CMAKE_CURRENT_BINARY_DIR}/openscad") + set(OPENSCAD_BINPATH "${CMAKE_CURRENT_BINARY_DIR}/openscad_nogui") endif() # @@ -878,8 +899,6 @@ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake ${TMP}) # Add tests -add_cmdline_test(echotest EXE ${CMAKE_SOURCE_DIR}/echotest SUFFIX txt ARGS ${OPENSCAD_BINPATH} FILES ${ECHO_FILES}) -add_cmdline_test(dumptest EXE ${CMAKE_SOURCE_DIR}/dumptest SUFFIX csg ARGS ${OPENSCAD_BINPATH} FILES ${DUMPTEST_FILES}) add_cmdline_test(moduledumptest EXE ${OPENSCAD_BINPATH} ARGS -o SUFFIX ast FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/allmodules.scad ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/allfunctions.scad @@ -892,6 +911,8 @@ add_cmdline_test(csgtermtest EXE ${OPENSCAD_BINPATH} ARGS -o SUFFIX term FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/allexpressions.scad ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/allfunctions.scad ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/allmodules.scad) +add_cmdline_test(echotest EXE ${OPENSCAD_BINPATH} ARGS -o SUFFIX echo FILES ${ECHO_FILES}) +add_cmdline_test(dumptest EXE ${OPENSCAD_BINPATH} ARGS -o SUFFIX csg FILES ${DUMPTEST_FILES}) add_cmdline_test(cgalpngtest EXE ${OPENSCAD_BINPATH} ARGS --render -o SUFFIX png FILES ${CGALPNGTEST_FILES}) add_cmdline_test(opencsgtest EXE ${OPENSCAD_BINPATH} ARGS -o SUFFIX png FILES ${OPENCSGTEST_FILES}) add_cmdline_test(throwntogethertest EXE ${OPENSCAD_BINPATH} ARGS --preview=throwntogether -o SUFFIX png FILES ${THROWNTOGETHERTEST_FILES}) diff --git a/tests/dumptest b/tests/dumptest deleted file mode 100755 index f9247c75..00000000 --- a/tests/dumptest +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env python - -import re, sys, subprocess - -subprocess.check_call([sys.argv[2], sys.argv[1], '-o', sys.argv[3]]) - -result = open(sys.argv[3]).read() - -result = re.sub(r', timestamp = [0-9]*', '', result) -result = re.sub(r'-?[0-9].[0-9]*e-[0-9]{2,}', '0', result) - -open(sys.argv[3], 'w').write(result) diff --git a/tests/echotest b/tests/echotest deleted file mode 100755 index a2302ffa..00000000 --- a/tests/echotest +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env python - -import re, sys, subprocess - -result = subprocess.Popen([sys.argv[2], sys.argv[1], '-o', 'null'], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[1] -result = re.sub(r'-?[0-9].[0-9]*e-[0-9]{2,}', '0', result) - -open(sys.argv[3], 'w').write(result) diff --git a/tests/regression/echotest/builtin-tests-expected.txt b/tests/regression/echotest/builtin-tests-expected.echo similarity index 100% rename from tests/regression/echotest/builtin-tests-expected.txt rename to tests/regression/echotest/builtin-tests-expected.echo diff --git a/tests/regression/echotest/dim-all-expected.txt b/tests/regression/echotest/dim-all-expected.echo similarity index 100% rename from tests/regression/echotest/dim-all-expected.txt rename to tests/regression/echotest/dim-all-expected.echo diff --git a/tests/regression/echotest/echo-expected.txt b/tests/regression/echotest/echo-expected.echo similarity index 100% rename from tests/regression/echotest/echo-expected.txt rename to tests/regression/echotest/echo-expected.echo diff --git a/tests/regression/echotest/echo-tests-expected.txt b/tests/regression/echotest/echo-tests-expected.echo similarity index 100% rename from tests/regression/echotest/echo-tests-expected.txt rename to tests/regression/echotest/echo-tests-expected.echo diff --git a/tests/regression/echotest/escape-test-expected.txt b/tests/regression/echotest/escape-test-expected.echo similarity index 100% rename from tests/regression/echotest/escape-test-expected.txt rename to tests/regression/echotest/escape-test-expected.echo diff --git a/tests/regression/echotest/expression-shortcircuit-tests-expected.txt b/tests/regression/echotest/expression-shortcircuit-tests-expected.echo similarity index 100% rename from tests/regression/echotest/expression-shortcircuit-tests-expected.txt rename to tests/regression/echotest/expression-shortcircuit-tests-expected.echo diff --git a/tests/regression/echotest/inf-tests-expected.txt b/tests/regression/echotest/inf-tests-expected.echo similarity index 100% rename from tests/regression/echotest/inf-tests-expected.txt rename to tests/regression/echotest/inf-tests-expected.echo diff --git a/tests/regression/echotest/len-tests-expected.txt b/tests/regression/echotest/len-tests-expected.echo similarity index 100% rename from tests/regression/echotest/len-tests-expected.txt rename to tests/regression/echotest/len-tests-expected.echo diff --git a/tests/regression/echotest/lookup-tests-expected.txt b/tests/regression/echotest/lookup-tests-expected.echo similarity index 100% rename from tests/regression/echotest/lookup-tests-expected.txt rename to tests/regression/echotest/lookup-tests-expected.echo diff --git a/tests/regression/echotest/parser-tests-expected.txt b/tests/regression/echotest/parser-tests-expected.echo similarity index 100% rename from tests/regression/echotest/parser-tests-expected.txt rename to tests/regression/echotest/parser-tests-expected.echo diff --git a/tests/regression/echotest/rands-expected.txt b/tests/regression/echotest/rands-expected.echo similarity index 100% rename from tests/regression/echotest/rands-expected.txt rename to tests/regression/echotest/rands-expected.echo diff --git a/tests/regression/echotest/recursion-tests-expected.txt b/tests/regression/echotest/recursion-tests-expected.echo similarity index 100% rename from tests/regression/echotest/recursion-tests-expected.txt rename to tests/regression/echotest/recursion-tests-expected.echo diff --git a/tests/regression/echotest/search-tests-expected.txt b/tests/regression/echotest/search-tests-expected.echo similarity index 100% rename from tests/regression/echotest/search-tests-expected.txt rename to tests/regression/echotest/search-tests-expected.echo diff --git a/tests/regression/echotest/string-indexing-expected.txt b/tests/regression/echotest/string-indexing-expected.echo similarity index 100% rename from tests/regression/echotest/string-indexing-expected.txt rename to tests/regression/echotest/string-indexing-expected.echo diff --git a/tests/regression/echotest/string-test-expected.txt b/tests/regression/echotest/string-test-expected.echo similarity index 100% rename from tests/regression/echotest/string-test-expected.txt rename to tests/regression/echotest/string-test-expected.echo diff --git a/tests/regression/echotest/value-reassignment-tests-expected.txt b/tests/regression/echotest/value-reassignment-tests-expected.echo similarity index 100% rename from tests/regression/echotest/value-reassignment-tests-expected.txt rename to tests/regression/echotest/value-reassignment-tests-expected.echo diff --git a/tests/regression/echotest/value-reassignment-tests2-expected.txt b/tests/regression/echotest/value-reassignment-tests2-expected.echo similarity index 100% rename from tests/regression/echotest/value-reassignment-tests2-expected.txt rename to tests/regression/echotest/value-reassignment-tests2-expected.echo diff --git a/tests/regression/echotest/variable-scope-tests-expected.txt b/tests/regression/echotest/variable-scope-tests-expected.echo similarity index 100% rename from tests/regression/echotest/variable-scope-tests-expected.txt rename to tests/regression/echotest/variable-scope-tests-expected.echo diff --git a/tests/regression/echotest/vector-values-expected.txt b/tests/regression/echotest/vector-values-expected.echo similarity index 100% rename from tests/regression/echotest/vector-values-expected.txt rename to tests/regression/echotest/vector-values-expected.echo diff --git a/tests/test_cmdline_tool.py b/tests/test_cmdline_tool.py index 470be1e4..6977a88a 100755 --- a/tests/test_cmdline_tool.py +++ b/tests/test_cmdline_tool.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # # Regression test driver for cmd-line tools