diff options
| author | don bright <hugh.m.bright@gmail.com> | 2013-03-11 23:40:51 (GMT) | 
|---|---|---|
| committer | don bright <hugh.m.bright@gmail.com> | 2013-03-11 23:40:51 (GMT) | 
| commit | ea0bb94be9a748744942798e080bdbfd10e3c270 (patch) | |
| tree | fb23c498afc75c03df8f97f7c2eda466d1168c30 | |
| parent | 79ce1e47d0ff250aed46ddc3058ea4f694900bb0 (diff) | |
| parent | d9c4b779421b226d0ad1eed492611eb5ddb843ed (diff) | |
Merge branch 'master' of github.com:openscad/openscad into resize5
31 files changed, 388 insertions, 176 deletions
| diff --git a/openscad.pro b/openscad.pro index 6f3ddfb..d9442d4 100644 --- a/openscad.pro +++ b/openscad.pro @@ -55,20 +55,34 @@ else {    }  } -macx { -  # add CONFIG+=deploy to the qmake command-line to make a deployment build -  deploy { -    message("Building deployment version") +# add CONFIG+=deploy to the qmake command-line to make a deployment build +deploy { +  message("Building deployment version") +  DEFINES += OPENSCAD_DEPLOY +  macx {      CONFIG += x86 x86_64 +    LIBS += -framework Sparkle +    HEADERS += src/SparkleAutoUpdater.h +    OBJECTIVE_SOURCES += src/SparkleAutoUpdater.mm    } +} +macx {    TARGET = OpenSCAD    ICON = icons/OpenSCAD.icns    QMAKE_INFO_PLIST = Info.plist    APP_RESOURCES.path = Contents/Resources    APP_RESOURCES.files = OpenSCAD.sdef dsa_pub.pem icons/SCAD.icns    QMAKE_BUNDLE_DATA += APP_RESOURCES -  LIBS += -framework Cocoa -framework Sparkle +  LIBS += -framework Cocoa + +  # FIXME: Somehow, setting the deployment target to a lower version causes a +  # seldom crash in debug mode (e.g. the minkowski2-test): +  # frame #4: 0x00007fff8b7d5be5 libc++.1.dylib`std::runtime_error::~runtime_error() + 55 +  # frame #5: 0x0000000100150df5 OpenSCAD`CGAL::Uncertain_conversion_exception::~Uncertain_conversion_exception(this=0x0000000105044488) + 21 at Uncertain.h:78 +  # The reason for the crash appears to be linking with libgcc_s,  +  # but it's unclear what's really going on +  QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6  }  else {    TARGET = openscad @@ -357,11 +371,9 @@ SOURCES += src/cgalutils.cc \  macx {    HEADERS += src/AppleEvents.h \               src/EventFilter.h \ -             src/SparkleAutoUpdater.h \               src/CocoaUtils.h    SOURCES += src/AppleEvents.cc -  OBJECTIVE_SOURCES += src/SparkleAutoUpdater.mm \ -             src/CocoaUtils.mm +  OBJECTIVE_SOURCES += src/CocoaUtils.mm  }  isEmpty(PREFIX):PREFIX = /usr/local diff --git a/scripts/macosx-build-dependencies.sh b/scripts/macosx-build-dependencies.sh index e208fdd..11d9919 100755 --- a/scripts/macosx-build-dependencies.sh +++ b/scripts/macosx-build-dependencies.sh @@ -6,10 +6,11 @@  #   # This script must be run from the OpenSCAD source root directory  # -# Usage: macosx-build-dependencies.sh [-6l] +# Usage: macosx-build-dependencies.sh [-6lcd]  #  -6   Build only 64-bit binaries  #  -l   Force use of LLVM compiler  #  -c   Force use of clang compiler +#  -d   Build for deployment (if not specified, e.g. Sparkle won't be built)  #  # Prerequisites:  # - MacPorts: curl, cmake @@ -32,11 +33,12 @@ export QMAKESPEC=macx-g++  printUsage()  { -  echo "Usage: $0 [-6lc]" +  echo "Usage: $0 [-6lcd]"    echo    echo "  -6   Build only 64-bit binaries"    echo "  -l   Force use of LLVM compiler"    echo "  -c   Force use of clang compiler" +  echo "  -d   Build for deployment"  }  # FIXME: Support gcc/llvm/clang flags. Use -platform <whatever> to make this work? kintel 20130117 @@ -354,12 +356,13 @@ if [ ! -f $OPENSCADDIR/openscad.pro ]; then    exit 0  fi -while getopts '6lc' c +while getopts '6lcd' c  do    case $c in      6) OPTION_32BIT=false;;      l) OPTION_LLVM=true;;      c) OPTION_CLANG=true;; +    d) OPTION_DEPLOY=true;;    esac  done @@ -415,4 +418,6 @@ build_boost 1.53.0  build_cgal 4.1  build_glew 1.9.0  build_opencsg 1.3.2 -build_sparkle 0ed83cf9f2eeb425d4fdd141c01a29d843970c20 +if $OPTION_DEPLOY; then +  build_sparkle 0ed83cf9f2eeb425d4fdd141c01a29d843970c20 +fi diff --git a/scripts/release-common.sh b/scripts/release-common.sh index a30d43a..10a1c18 100755 --- a/scripts/release-common.sh +++ b/scripts/release-common.sh @@ -110,13 +110,12 @@ fi  echo "Building openscad-$VERSION ($VERSIONDATE) $CONFIGURATION..." +CONFIG=deploy  case $OS in      LINUX|MACOSX)  -        CONFIG=deploy          TARGET=          ;;      WIN)  -        unset CONFIG          export QTDIR=/c/devmingw/qt2009.03          export QTMAKESPEC=win32-g++          export PATH=$PATH:/c/devmingw/qt2009.03/bin:/c/devmingw/qt2009.03/qt/bin @@ -125,7 +124,6 @@ case $OS in          TARGET=release          ;;      LINXWIN)  -        unset CONFIG          . ./scripts/setenv-mingw-xbuild.sh          TARGET=release          ZIP="zip" diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index b793e9b..dc61f74 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -298,7 +298,7 @@ build_cgal()    if [ "`echo $2 | grep use-sys-libs`" ]; then      cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR -DWITH_CGAL_Qt3=OFF -DWITH_CGAL_Qt4=OFF -DWITH_CGAL_ImageIO=OFF -DCMAKE_BUILD_TYPE=$CGAL_BUILDTYPE ..    else -    cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR -DGMP_INCLUDE_DIR=$DEPLOYDIR/include -DGMP_LIBRARIES=$DEPLOYDIR/lib/libgmp.so -DGMPXX_LIBRARIES=$DEPLOYDIR/lib/libgmpxx.so -DGMPXX_INCLUDE_DIR=$DEPLOYDIR/include -DMPFR_INCLUDE_DIR=$DEPLOYDIR/include -DMPFR_LIBRARIES=$DEPLOYDIR/lib/libmpfr.so -DWITH_CGAL_Qt3=OFF -DWITH_CGAL_Qt4=OFF -DWITH_CGAL_ImageIO=OFF -DBOOST_ROOT=$DEPLOYDIR -DCMAKE_BUILD_TYPE=$CGAL_BUILD_TYPE .. +    cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR -DGMP_INCLUDE_DIR=$DEPLOYDIR/include -DGMP_LIBRARIES=$DEPLOYDIR/lib/libgmp.so -DGMPXX_LIBRARIES=$DEPLOYDIR/lib/libgmpxx.so -DGMPXX_INCLUDE_DIR=$DEPLOYDIR/include -DMPFR_INCLUDE_DIR=$DEPLOYDIR/include -DMPFR_LIBRARIES=$DEPLOYDIR/lib/libmpfr.so -DWITH_CGAL_Qt3=OFF -DWITH_CGAL_Qt4=OFF -DWITH_CGAL_ImageIO=OFF -DBOOST_ROOT=$DEPLOYDIR -DBoost_USE_MULTITHREADED=false -DCMAKE_BUILD_TYPE=$CGAL_BUILD_TYPE ..    fi    make -j$NUMCPU    make install diff --git a/src/context.cc b/src/context.cc index a2a8d13..97ea5b9 100644 --- a/src/context.cc +++ b/src/context.cc @@ -51,9 +51,8 @@ Context::Context(const Context *parent, const Module *library)  		this->functions_p = &library->functions;  		this->modules_p = &library->modules;  		this->usedlibs_p = &library->usedlibs; -		for (size_t j = 0; j < library->assignments_var.size(); j++) { -			this->set_variable(library->assignments_var[j],  -												 library->assignments_expr[j]->evaluate(this)); +		BOOST_FOREACH(const std::string &var, library->assignments_var) { +			this->set_variable(var, library->assignments.at(var)->evaluate(this));  		}  	}  	else { diff --git a/src/module.cc b/src/module.cc index cfd73cc..e6dcb57 100644 --- a/src/module.cc +++ b/src/module.cc @@ -136,7 +136,7 @@ std::vector<AbstractNode*> IfElseModuleInstantiation::evaluateElseChildren(const  Module::~Module()  { -	BOOST_FOREACH (Expression *v, assignments_expr) delete v; +	BOOST_FOREACH (const AssignmentContainer::value_type &v, assignments) delete v.second;  	BOOST_FOREACH (FunctionContainer::value_type &f, functions) delete f.second;  	BOOST_FOREACH (AbstractModuleContainer::value_type &m, modules) delete m.second;  	BOOST_FOREACH (ModuleInstantiation *v, children) delete v; @@ -158,8 +158,8 @@ AbstractNode *Module::evaluate(const Context *ctx, const ModuleInstantiation *in  	else  		c.usedlibs_p = NULL; -	for (size_t i = 0; i < assignments_var.size(); i++) { -		c.set_variable(assignments_var[i], assignments_expr[i]->evaluate(&c)); +	BOOST_FOREACH(const std::string &var, assignments_var) { +		c.set_variable(var, assignments.at(var)->evaluate(&c));  	}  	AbstractNode *node = new AbstractNode(inst); @@ -192,8 +192,8 @@ std::string Module::dump(const std::string &indent, const std::string &name) con  	BOOST_FOREACH(const AbstractModuleContainer::value_type &m, modules) {  		dump << m.second->dump(indent + tab, m.first);  	} -	for (size_t i = 0; i < assignments_var.size(); i++) { -		dump << indent << tab << assignments_var[i] << " = " << *assignments_expr[i] << ";\n"; +	BOOST_FOREACH(const std::string &var, assignments_var) { +		dump << indent << tab << var << " = " << *assignments.at(var) << ";\n";  	}  	for (size_t i = 0; i < children.size(); i++) {  		dump << children[i]->dump(indent + tab); diff --git a/src/module.h b/src/module.h index 879d249..cc82f81 100644 --- a/src/module.h +++ b/src/module.h @@ -74,8 +74,9 @@ public:  	bool is_handling_dependencies;  	bool handleDependencies(); -	std::vector<std::string> assignments_var; -	std::vector<Expression*> assignments_expr; +	std::list<std::string> assignments_var; +	typedef boost::unordered_map<std::string, Expression*> AssignmentContainer; +	AssignmentContainer assignments;  	typedef boost::unordered_map<std::string, class AbstractFunction*> FunctionContainer;  	FunctionContainer functions; diff --git a/src/openscad.cc b/src/openscad.cc index 75d7b9d..682ccb7 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -55,7 +55,9 @@  #ifdef Q_WS_MAC  #include "EventFilter.h"  #include "AppleEvents.h" -#include "SparkleAutoUpdater.h" +#ifdef OPENSCAD_DEPLOY +  #include "SparkleAutoUpdater.h" +#endif  #endif  #include "Camera.h" @@ -483,13 +485,11 @@ int main(int argc, char **argv)  		installAppleEventHandlers();  #endif		 -#ifndef DEBUG -#ifdef Q_WS_MAC +#if defined(OPENSCAD_DEPLOY) && defined(Q_WS_MAC)  		AutoUpdater *updater = new SparkleAutoUpdater;  		AutoUpdater::setUpdater(updater);  		if (updater->automaticallyChecksForUpdates()) updater->checkForUpdates();  #endif -#endif  		QString qfilename;  		if (filename) qfilename = QString::fromStdString(boosty::stringy(boosty::absolute(filename))); diff --git a/src/parser.y b/src/parser.y index 3e485ff..536f4ef 100644 --- a/src/parser.y +++ b/src/parser.y @@ -151,19 +151,10 @@ statement:  		}  	} |  	TOK_ID '=' expr ';' { -		bool add_new_assignment = true; -		for (size_t i = 0; i < currmodule->assignments_var.size(); i++) { -			if (currmodule->assignments_var[i] != $1) -				continue; -			delete currmodule->assignments_expr[i]; -			currmodule->assignments_expr[i] = $3; -			add_new_assignment = false; -		} -		if (add_new_assignment) { -			currmodule->assignments_var.push_back($1); -			currmodule->assignments_expr.push_back($3); -			free($1); -		} +          std::list<std::string>::iterator found = std::find(currmodule->assignments_var.begin(), currmodule->assignments_var.end(),$1); +          if (found != currmodule->assignments_var.end()) currmodule->assignments_var.erase(found); +          currmodule->assignments_var.push_back($1); +          currmodule->assignments[$1] = $3;  	} |  	TOK_MODULE TOK_ID '(' arguments_decl optional_commas ')' {  		Module *p = currmodule; diff --git a/testdata/scad/features/scale2D-tests.scad b/testdata/scad/features/scale2D-tests.scad new file mode 100644 index 0000000..87b2278 --- /dev/null +++ b/testdata/scad/features/scale2D-tests.scad @@ -0,0 +1,10 @@ +module obj2D() square([2,3], center=true); + +// 3 variants of 3D scale of 2D object +scale([2,4/3,2]) obj2D(); +translate([5,0,0]) scale([2,4/3]) obj2D(); +translate([10,0,0]) scale(2) obj2D(); + +// Scale by zero; 2D object +linear_extrude() scale([0,0]) obj2D(); +linear_extrude() scale([0,1]) obj2D(); diff --git a/testdata/scad/features/scale3D-tests.scad b/testdata/scad/features/scale3D-tests.scad new file mode 100644 index 0000000..c46aae6 --- /dev/null +++ b/testdata/scad/features/scale3D-tests.scad @@ -0,0 +1,11 @@ +module obj3D() cylinder(r=1, center=true, $fn=8); + +// 3 variants of 3D scale of 3D object +translate([0,0,0]) scale([1,2,3]) obj3D(); +translate([5,0,0]) scale([2,1]) obj3D(); +translate([10,0,0]) scale(2) obj3D(); + +// Scale by zero; 3D object +linear_extrude() scale([0,0,0]) obj3D(); +linear_extrude() scale([0,1,0]) obj3D(); +linear_extrude() scale([1,1,0]) obj3D(); diff --git a/testdata/scad/misc/value-reassignment-tests.scad b/testdata/scad/misc/value-reassignment-tests.scad new file mode 100644 index 0000000..475f78f --- /dev/null +++ b/testdata/scad/misc/value-reassignment-tests.scad @@ -0,0 +1,4 @@ +myval = 2; +i = 2; +myval = i * 2; +echo(myval); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9d8e26f..6a5ec74 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -7,6 +7,9 @@ if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSIO    cmake_policy(SET CMP0017 NEW)  endif() +# Needed for cmake < 2.8.3 +include(CMakeParseArguments.cmake) +  # Detect Lion and force gcc  IF (APPLE)     EXECUTE_PROCESS(COMMAND sw_vers -productVersion OUTPUT_VARIABLE MACOSX_VERSION) @@ -602,10 +605,6 @@ else()  endif()  if(EXISTS "${GUI_BINPATH}") -  add_executable(guicgalpngtest guicgalpngtest.cc) -  set_target_properties(guicgalpngtest PROPERTIES COMPILE_FLAGS "-DBINPATH=${GUI_BINPATH}") -  add_executable(guiopencsgtest guiopencsgtest.cc) -  set_target_properties(guiopencsgtest PROPERTIES COMPILE_FLAGS "-DBINPATH=${GUI_BINPATH}")    message(STATUS "Found OpenSCAD GUI binary: ${GUI_BINPATH}")  else()    message(STATUS "Couldn't find the OpenSCAD GUI binary: ${GUI_BINPATH}") @@ -674,19 +673,31 @@ endfunction()  #  # This functions adds cmd-line tests given files. -# Files are sent as the parameters following TESTSUFFIX  # -# Usage add_cmdline_test(TESTCMD TESTSUFFIX <test files>) +# Usage add_cmdline_test(testbasename [EXE <executable>] [ARGS <args to exe>] +#                        [EXPECTEDDIR <shared dir>] SUFFIX <suffix> FILES <test files>)  #  find_package(PythonInterp) -macro(add_cmdline_test TESTCMD TESTSUFFIX) -  get_filename_component(TESTCMD_NAME ${TESTCMD} NAME_WE) +function(add_cmdline_test TESTCMD_BASENAME) +  cmake_parse_arguments(TESTCMD "" "EXE;SUFFIX;EXPECTEDDIR" "FILES;ARGS" ${ARGN}) + +  # If sharing results with another test, pass on this to the python script +  if (TESTCMD_EXPECTEDDIR) +    set(EXTRA_OPTIONS -e ${TESTCMD_EXPECTEDDIR}) +  endif() + +  if (TESTCMD_EXE) +    set(TESTNAME_OPTION -t ${TESTCMD_BASENAME}) +  else() +    # If no executable was specified, assume it was built by us and resides here +    set(TESTCMD_EXE ${CMAKE_BINARY_DIR}/${TESTCMD_BASENAME}) +  endif()    # Add tests from args -  foreach (SCADFILE ${ARGN}) -    get_filename_component(TESTNAME ${SCADFILE} NAME_WE) -    string(REPLACE " " "_" TESTNAME ${TESTNAME}) # Test names cannot include spaces -    set(TEST_FULLNAME "${TESTCMD_NAME}_${TESTNAME}") +  foreach (SCADFILE ${TESTCMD_FILES}) +    get_filename_component(FILE_BASENAME ${SCADFILE} NAME_WE) +    string(REPLACE " " "_" FILE_BASENAME ${FILE_BASENAME}) # Test names cannot include spaces +    set(TEST_FULLNAME "${TESTCMD_BASENAME}_${FILE_BASENAME}")      list(FIND DISABLED_TESTS ${TEST_FULLNAME} DISABLED)      if (${DISABLED} EQUAL -1) @@ -705,11 +716,17 @@ macro(add_cmdline_test TESTCMD TESTSUFFIX)        if (MINGW_CROSS_ENV_DIR)          set( MINGW_CROSS_ARG "--mingw-cross-env" )        endif() -      add_test(NAME ${TEST_FULLNAME} ${CONFARG} ${CONFVAL} COMMAND ${PYTHON_EXECUTABLE} ${tests_SOURCE_DIR}/test_cmdline_tool.py ${MINGW_CROSS_ARG} --comparator=${COMPARATOR} -c ${ImageMagick_convert_EXECUTABLE} -s ${TESTSUFFIX} ${CMAKE_BINARY_DIR}/${TESTCMD} "${SCADFILE}") + +      # The python script cannot extract the testname when given extra parameters +      if (TESTCMD_ARGS) +        set(FILENAME_OPTION -f ${FILE_BASENAME}) +      endif() + +      add_test(NAME ${TEST_FULLNAME} ${CONFARG} ${CONFVAL} COMMAND ${PYTHON_EXECUTABLE} ${tests_SOURCE_DIR}/test_cmdline_tool.py ${MINGW_CROSS_ARG} --comparator=${COMPARATOR} -c ${ImageMagick_convert_EXECUTABLE} -s ${TESTCMD_SUFFIX} ${EXTRA_OPTIONS} ${TESTNAME_OPTION} ${FILENAME_OPTION} ${TESTCMD_EXE} "${SCADFILE}" ${TESTCMD_ARGS})        set_property(TEST ${TEST_FULLNAME} PROPERTY ENVIRONMENT "${CTEST_ENVIRONMENT}")      endif()    endforeach() -endmacro() +endfunction()  enable_testing() @@ -746,7 +763,8 @@ list(APPEND ECHO_FILES ${FUNCTION_FILES}              ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/string-indexing.scad              ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/vector-values.scad              ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/search-tests.scad -            ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/recursion-tests.scad) +            ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/recursion-tests.scad +            ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/value-reassignment-tests.scad)  list(APPEND DUMPTEST_FILES ${MINIMAL_FILES} ${FEATURES_FILES} ${EXAMPLE_FILES})  list(APPEND DUMPTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/escape-test.scad @@ -764,8 +782,8 @@ list(APPEND THROWNTOGETHERTEST_FILES ${OPENCSGTEST_FILES})  list(APPEND CGALSTLSANITYTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/normal-nan.scad) -list(APPEND GUICGALPNGTEST_FILES ${CGALPNGTEST_FILES}) -list(APPEND GUIOPENCSGTEST_FILES ${OPENCSGTEST_FILES}) +list(APPEND OPENSCAD-CGALPNG_FILES ${CGALPNGTEST_FILES}) +list(APPEND OPENSCAD-CSGPNG_FILES ${OPENCSGTEST_FILES})  # Disable tests which are known to cause floating point comparison issues  # Once we're capable of comparing these across platforms, we can put these back in @@ -791,19 +809,19 @@ disable_tests(dumptest_transform-tests  # FIXME: This test illustrates a weakness in child() combined with modifiers.  # Reenable it when this is improved  disable_tests(opencsgtest_child-background) -disable_tests(guiopencsgtest_child-background) +disable_tests(openscad-csgpng_child-background)  # FIXME: This single test takes over an hour to run on a 2.7 GHz P4  disable_tests(opencsgtest_example006 cgalpngtest_example006) -disable_tests(guiopencsgtest_example006 guicgalpngtest_example006) +disable_tests(openscad-csgpng_example006 openscad-cgalpng_example006)  # These tests only makes sense in OpenCSG mode  disable_tests(cgalpngtest_child-background                cgalpngtest_highlight-and-background-modifier                cgalpngtest_testcolornames -              guicgalpngtest_child-background -              guicgalpngtest_highlight-and-background-modifier -              guicgalpngtest_testcolornames +              openscad-cgalpng_child-background +              openscad-cgalpng_highlight-and-background-modifier +              openscad-cgalpng_testcolornames                throwntogethertest_child-background                throwntogethertest_highlight-and-background-modifier                throwntogethertest_testcolornames) @@ -812,8 +830,8 @@ disable_tests(cgalpngtest_child-background  set_test_config(Heavy opencsgtest_minkowski3-tests                        opencsgtest_projection-tests -                      guiopencsgtest_minkowski3-tests -                      guiopencsgtest_projection-tests +                      openscad-csgpng_minkowski3-tests +                      openscad-csgpng_projection-tests                        throwntogethertest_minkowski3-tests                        throwntogethertest_projection-tests                        cgalpngtest_projection-tests @@ -825,14 +843,14 @@ set_test_config(Heavy opencsgtest_minkowski3-tests                        cgalpngtest_for-nested-tests                        cgalpngtest_intersection-tests                        cgalpngtest_text-search-test -                      guicgalpngtest_projection-tests -                      guicgalpngtest_rotate_extrude-tests -                      guicgalpngtest_surface-tests -                      guicgalpngtest_sphere-tests -                      guicgalpngtest_minkowski3-tests -                      guicgalpngtest_for-tests -                      guicgalpngtest_for-nested-tests -                      guicgalpngtest_intersection-tests) +                      openscad-cgalpng_projection-tests +                      openscad-cgalpng_rotate_extrude-tests +                      openscad-cgalpng_surface-tests +                      openscad-cgalpng_sphere-tests +                      openscad-cgalpng_minkowski3-tests +                      openscad-cgalpng_for-tests +                      openscad-cgalpng_for-nested-tests +                      openscad-cgalpng_intersection-tests)  foreach(FILE ${EXAMPLE_FILES})    get_test_fullname(cgalpngtest ${FILE} TEST_FULLNAME) @@ -841,9 +859,9 @@ foreach(FILE ${EXAMPLE_FILES})    set_test_config(Examples ${TEST_FULLNAME})    get_test_fullname(throwntogethertest ${FILE} TEST_FULLNAME)    set_test_config(Examples ${TEST_FULLNAME}) -  get_test_fullname(guicgalpngtest ${FILE} TEST_FULLNAME) +  get_test_fullname(openscad-cgalpng ${FILE} TEST_FULLNAME)    set_test_config(Examples ${TEST_FULLNAME}) -  get_test_fullname(guiopencsgtest ${FILE} TEST_FULLNAME) +  get_test_fullname(openscad-csgpng ${FILE} TEST_FULLNAME)    set_test_config(Examples ${TEST_FULLNAME})  endforeach() @@ -890,19 +908,71 @@ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake ${TMP})  # Add tests -add_cmdline_test(echotest txt ${ECHO_FILES}) -add_cmdline_test(dumptest txt ${DUMPTEST_FILES}) -add_cmdline_test(csgtexttest txt ${MINIMAL_FILES}) -add_cmdline_test(csgtermtest txt ${MINIMAL_FILES}) -add_cmdline_test(cgalpngtest png ${CGALPNGTEST_FILES}) -add_cmdline_test(opencsgtest png ${OPENCSGTEST_FILES}) -add_cmdline_test(throwntogethertest png ${THROWNTOGETHERTEST_FILES}) -add_cmdline_test(guicgalpngtest png ${GUICGALPNGTEST_FILES}) -add_cmdline_test(guiopencsgtest png ${GUIOPENCSGTEST_FILES}) - +add_cmdline_test(echotest SUFFIX txt FILES ${ECHO_FILES}) +add_cmdline_test(dumptest SUFFIX txt FILES ${DUMPTEST_FILES}) +add_cmdline_test(csgtexttest SUFFIX txt FILES ${MINIMAL_FILES}) +add_cmdline_test(csgtermtest SUFFIX txt FILES ${MINIMAL_FILES}) +add_cmdline_test(cgalpngtest SUFFIX png FILES ${CGALPNGTEST_FILES}) +add_cmdline_test(opencsgtest SUFFIX png FILES ${OPENCSGTEST_FILES}) +add_cmdline_test(throwntogethertest SUFFIX png FILES ${THROWNTOGETHERTEST_FILES})  # FIXME: We don't actually need to compare the output of cgalstlsanitytest  # with anything. It's self-contained and returns != 0 on error -add_cmdline_test(cgalstlsanitytest txt ${CGALSTLSANITYTEST_FILES}) +add_cmdline_test(cgalstlsanitytest SUFFIX txt FILES ${CGALSTLSANITYTEST_FILES}) + +# Tests using the actual OpenSCAD binary +add_cmdline_test(openscad-cgalpng EXE ${GUI_BINPATH} ARGS --render -o  +                 EXPECTEDDIR cgalpngtest SUFFIX png  +                 FILES ${OPENSCAD-CGALPNG_FILES}) +add_cmdline_test(openscad-csgpng EXE ${GUI_BINPATH} ARGS -o  +                 EXPECTEDDIR opencsgtest SUFFIX png  +                 FILES ${OPENSCAD-CGALPNG_FILES}) + +add_cmdline_test(openscad-imgsize EXE ${GUI_BINPATH} +                 ARGS --imgsize 100,100 -o  +                 SUFFIX png  +                 FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad) +add_cmdline_test(openscad-imgstretch EXE ${GUI_BINPATH} +                 ARGS --imgsize 500,100 -o  +                 SUFFIX png  +                 FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad) +add_cmdline_test(openscad-imgstretch2 EXE ${GUI_BINPATH} +                 ARGS --imgsize 100,500 -o  +                 SUFFIX png  +                 FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad) +add_cmdline_test(openscad-camdist EXE ${GUI_BINPATH}  +                 ARGS --imgsize=500,500 --camera=0,0,0,0,0,0,300  examples/example001.scad -o +                 SUFFIX png +                 FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad) +add_cmdline_test(openscad-camrot EXE ${GUI_BINPATH} +                 ARGS --imgsize=500,500 --camera=0,0,0,10,22.5,45,300  examples/example001.scad -o +                 SUFFIX png +                 FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad) +add_cmdline_test(openscad-camtrans EXE ${GUI_BINPATH} +                 ARGS --imgsize=500,500 --camera=20,100,10,0,0,0,300  examples/example001.scad -o +                 SUFFIX png +                 FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad) +add_cmdline_test(openscad-camortho EXE ${GUI_BINPATH} +                 ARGS --imgsize=500,500 --camera=20,100,10,0,0,0,300  examples/example001.scad --projection=o -o +                 SUFFIX png +                 FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad) +add_cmdline_test(openscad-cameye EXE ${GUI_BINPATH} +                 ARGS --imgsize=500,500 --camera=60,40,30,0,0,0  examples/example001.scad -o +                 SUFFIX png +                 FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad) +add_cmdline_test(openscad-cameye2 EXE ${GUI_BINPATH} +                 ARGS --imgsize=500,500 --camera=160,140,130,0,0,0  examples/example001.scad -o +                 SUFFIX png +                 FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad) +add_cmdline_test(openscad-cameyeortho EXE ${GUI_BINPATH} +                 ARGS --imgsize=500,500 --camera=160,140,130,0,0,0  examples/example001.scad --projection=o -o  +                 SUFFIX png +                 FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad) +add_cmdline_test(openscad-camcenter EXE ${GUI_BINPATH} +                 ARGS --imgsize=500,500 --camera=60,40,30,20,10,30  -o +                 SUFFIX png +                 FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad) + +  message("Available test configurations: ${TEST_CONFIGS}")  #foreach(CONF ${TEST_CONFIGS}) diff --git a/tests/CMakeParseArguments.cmake b/tests/CMakeParseArguments.cmake new file mode 100644 index 0000000..406780e --- /dev/null +++ b/tests/CMakeParseArguments.cmake @@ -0,0 +1,138 @@ +# CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords> <multi_value_keywords> args...) +# +# CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions for +# parsing the arguments given to that macro or function. +# It processes the arguments and defines a set of variables which hold the +# values of the respective options. +# +# The <options> argument contains all options for the respective macro, +# i.e. keywords which can be used when calling the macro without any value +# following, like e.g. the OPTIONAL keyword of the install() command. +# +# The <one_value_keywords> argument contains all keywords for this macro +# which are followed by one value, like e.g. DESTINATION keyword of the +# install() command. +# +# The <multi_value_keywords> argument contains all keywords for this macro +# which can be followed by more than one value, like e.g. the TARGETS or +# FILES keywords of the install() command. +# +# When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the +# keywords listed in <options>, <one_value_keywords> and +# <multi_value_keywords> a variable composed of the given <prefix> +# followed by "_" and the name of the respective keyword. +# These variables will then hold the respective value from the argument list. +# For the <options> keywords this will be TRUE or FALSE. +# +# All remaining arguments are collected in a variable +# <prefix>_UNPARSED_ARGUMENTS, this can be checked afterwards to see whether +# your macro was called with unrecognized parameters. +# +# As an example here a my_install() macro, which takes similar arguments as the +# real install() command: +# +#   function(MY_INSTALL) +#     set(options OPTIONAL FAST) +#     set(oneValueArgs DESTINATION RENAME) +#     set(multiValueArgs TARGETS CONFIGURATIONS) +#     cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) +#     ... +# +# Assume my_install() has been called like this: +#   my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub) +# +# After the cmake_parse_arguments() call the macro will have set the following +# variables: +#   MY_INSTALL_OPTIONAL = TRUE +#   MY_INSTALL_FAST = FALSE (this option was not used when calling my_install() +#   MY_INSTALL_DESTINATION = "bin" +#   MY_INSTALL_RENAME = "" (was not used) +#   MY_INSTALL_TARGETS = "foo;bar" +#   MY_INSTALL_CONFIGURATIONS = "" (was not used) +#   MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL" +# +# You can the continue and process these variables. +# +# Keywords terminate lists of values, e.g. if directly after a one_value_keyword +# another recognized keyword follows, this is interpreted as the beginning of +# the new option. +# E.g. my_install(TARGETS foo DESTINATION OPTIONAL) would result in +# MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION would +# be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor. + +#============================================================================= +# Copyright 2010 Alexander Neundorf <neundorf@kde.org> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +#  License text for the above reference.) + + +if(__CMAKE_PARSE_ARGUMENTS_INCLUDED) +  return() +endif() +set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE) + + +function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames) +  # first set all result variables to empty/FALSE +  foreach(arg_name ${_singleArgNames} ${_multiArgNames}) +    set(${prefix}_${arg_name}) +  endforeach() + +  foreach(option ${_optionNames}) +    set(${prefix}_${option} FALSE) +  endforeach() + +  set(${prefix}_UNPARSED_ARGUMENTS) + +  set(insideValues FALSE) +  set(currentArgName) + +  # now iterate over all arguments and fill the result variables +  foreach(currentArg ${ARGN}) +    list(FIND _optionNames "${currentArg}" optionIndex)  # ... then this marks the end of the arguments belonging to this keyword +    list(FIND _singleArgNames "${currentArg}" singleArgIndex)  # ... then this marks the end of the arguments belonging to this keyword +    list(FIND _multiArgNames "${currentArg}" multiArgIndex)  # ... then this marks the end of the arguments belonging to this keyword + +    if(${optionIndex} EQUAL -1  AND  ${singleArgIndex} EQUAL -1  AND  ${multiArgIndex} EQUAL -1) +      if(insideValues) +        if("${insideValues}" STREQUAL "SINGLE") +          set(${prefix}_${currentArgName} ${currentArg}) +          set(insideValues FALSE) +        elseif("${insideValues}" STREQUAL "MULTI") +          list(APPEND ${prefix}_${currentArgName} ${currentArg}) +        endif() +      else() +        list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg}) +      endif() +    else() +      if(NOT ${optionIndex} EQUAL -1) +        set(${prefix}_${currentArg} TRUE) +        set(insideValues FALSE) +      elseif(NOT ${singleArgIndex} EQUAL -1) +        set(currentArgName ${currentArg}) +        set(${prefix}_${currentArgName}) +        set(insideValues "SINGLE") +      elseif(NOT ${multiArgIndex} EQUAL -1) +        set(currentArgName ${currentArg}) +        set(${prefix}_${currentArgName}) +        set(insideValues "MULTI") +      endif() +    endif() + +  endforeach() + +  # propagate the result variables to the caller: +  foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames}) +    set(${prefix}_${arg_name}  ${${prefix}_${arg_name}} PARENT_SCOPE) +  endforeach() +  set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE) + +endfunction() diff --git a/tests/guicgalpngtest.cc b/tests/guicgalpngtest.cc deleted file mode 100644 index 0a63ae8..0000000 --- a/tests/guicgalpngtest.cc +++ /dev/null @@ -1,28 +0,0 @@ -// Wrapper around openscad gui binary, so it can act like a 'test' - -#include <unistd.h> -#include <stdio.h> -#ifndef BINPATH -#error please define BINPATH=/some/path/openscad when compiling -#endif -#define PREQUOTE(x) #x -#define QUOTE(x) PREQUOTE(x) -int main( int argc, char * argv[] ) -{ -	fprintf(stderr,"%s: wrapper for OpenSCAD at %s\n", argv[0], QUOTE( BINPATH ) ); -	if ( argc != 3 ) { -		fprintf(stderr,"%s: bad number of arguments: %i\n", argv[0], argc); -		return 1; -	} -	char *newargs[6]; -	char *scadfilename = argv[1]; -	char *pngfilename = argv[2]; -	newargs[0] = const_cast<char *>(QUOTE( BINPATH )); -	newargs[1] = scadfilename; -	newargs[2] = const_cast<char *>("-o"); -	newargs[3] = pngfilename; -	newargs[4] = const_cast<char *>("--render"); -	newargs[5] = NULL; -	return execv( newargs[0], newargs ); -} - diff --git a/tests/guiopencsgtest.cc b/tests/guiopencsgtest.cc deleted file mode 100644 index 75e6abd..0000000 --- a/tests/guiopencsgtest.cc +++ /dev/null @@ -1,27 +0,0 @@ -// Wrapper around openscad gui binary, so it can act like a 'test' - -#include <unistd.h> -#include <stdio.h> -#ifndef BINPATH -#error please define BINPATH=/some/path/openscad when compiling -#endif -#define PREQUOTE(x) #x -#define QUOTE(x) PREQUOTE(x) -int main( int argc, char * argv[] ) -{ -	fprintf(stderr,"%s: wrapper for OpenSCAD at %s\n", argv[0], QUOTE( BINPATH ) ); -	if ( argc != 3 ) { -		fprintf(stderr,"%s: bad number of arguments: %i\n", argv[0], argc); -		return 1; -	} -	char *newargs[6]; -	char *scadfilename = argv[1]; -	char *pngfilename = argv[2]; -	newargs[0] = const_cast<char *>(QUOTE( BINPATH )); -	newargs[1] = scadfilename; -	newargs[2] = const_cast<char *>("-o"); -	newargs[3] = pngfilename; -	newargs[4] = NULL; -	return execv( newargs[0], newargs ); -} - diff --git a/tests/regression/dumptest/scale2D-tests-expected.txt b/tests/regression/dumptest/scale2D-tests-expected.txt index aa1eca2..6d4c096 100644 --- a/tests/regression/dumptest/scale2D-tests-expected.txt +++ b/tests/regression/dumptest/scale2D-tests-expected.txt @@ -1,10 +1,10 @@ -	multmatrix([[2, 0, 0, 0], [0, 1.33333, 0, 0], [0, 0, 2, 0], [0, 0, 0, 1]]) { +	multmatrix([[2, 0, 0, 0], [0, 1.33333333333, 0, 0], [0, 0, 2, 0], [0, 0, 0, 1]]) {  		group() {  			square(size = [2, 3], center = true);  		}  	}  	multmatrix([[1, 0, 0, 5], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { -		multmatrix([[2, 0, 0, 0], [0, 1.33333, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { +		multmatrix([[2, 0, 0, 0], [0, 1.33333333333, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {  			group() {  				square(size = [2, 3], center = true);  			} diff --git a/tests/regression/echotest/value-reassignment-tests-expected.txt b/tests/regression/echotest/value-reassignment-tests-expected.txt new file mode 100644 index 0000000..05a6741 --- /dev/null +++ b/tests/regression/echotest/value-reassignment-tests-expected.txt @@ -0,0 +1 @@ +ECHO: 4 diff --git a/tests/regression/openscad-camcenter/example001-expected.png b/tests/regression/openscad-camcenter/example001-expected.pngBinary files differ new file mode 100644 index 0000000..5cdada7 --- /dev/null +++ b/tests/regression/openscad-camcenter/example001-expected.png diff --git a/tests/regression/openscad-camdist/example001-expected.png b/tests/regression/openscad-camdist/example001-expected.pngBinary files differ new file mode 100644 index 0000000..363cc50 --- /dev/null +++ b/tests/regression/openscad-camdist/example001-expected.png diff --git a/tests/regression/openscad-cameye/example001-expected.png b/tests/regression/openscad-cameye/example001-expected.pngBinary files differ new file mode 100644 index 0000000..ad7a8b0 --- /dev/null +++ b/tests/regression/openscad-cameye/example001-expected.png diff --git a/tests/regression/openscad-cameye2/example001-expected.png b/tests/regression/openscad-cameye2/example001-expected.pngBinary files differ new file mode 100644 index 0000000..0315799 --- /dev/null +++ b/tests/regression/openscad-cameye2/example001-expected.png diff --git a/tests/regression/openscad-cameyeortho/example001-expected.png b/tests/regression/openscad-cameyeortho/example001-expected.pngBinary files differ new file mode 100644 index 0000000..0de38bd --- /dev/null +++ b/tests/regression/openscad-cameyeortho/example001-expected.png diff --git a/tests/regression/openscad-camortho/example001-expected.png b/tests/regression/openscad-camortho/example001-expected.pngBinary files differ new file mode 100644 index 0000000..29c1083 --- /dev/null +++ b/tests/regression/openscad-camortho/example001-expected.png diff --git a/tests/regression/openscad-camrot/example001-expected.png b/tests/regression/openscad-camrot/example001-expected.pngBinary files differ new file mode 100644 index 0000000..ecfd698 --- /dev/null +++ b/tests/regression/openscad-camrot/example001-expected.png diff --git a/tests/regression/openscad-camtrans/example001-expected.png b/tests/regression/openscad-camtrans/example001-expected.pngBinary files differ new file mode 100644 index 0000000..1117751 --- /dev/null +++ b/tests/regression/openscad-camtrans/example001-expected.png diff --git a/tests/regression/openscad-imgsize/example001-expected.png b/tests/regression/openscad-imgsize/example001-expected.pngBinary files differ new file mode 100644 index 0000000..52fb547 --- /dev/null +++ b/tests/regression/openscad-imgsize/example001-expected.png diff --git a/tests/regression/openscad-imgstretch/example001-expected.png b/tests/regression/openscad-imgstretch/example001-expected.pngBinary files differ new file mode 100644 index 0000000..9d704c8 --- /dev/null +++ b/tests/regression/openscad-imgstretch/example001-expected.png diff --git a/tests/regression/openscad-imgstretch2/example001-expected.png b/tests/regression/openscad-imgstretch2/example001-expected.pngBinary files differ new file mode 100644 index 0000000..92a93b6 --- /dev/null +++ b/tests/regression/openscad-imgstretch2/example001-expected.png diff --git a/tests/test_cmdline_tool.py b/tests/test_cmdline_tool.py index 5314921..eb01abd 100755 --- a/tests/test_cmdline_tool.py +++ b/tests/test_cmdline_tool.py @@ -28,22 +28,31 @@ import shutil  import platform  import string -share_expected_imgs = {} -share_expected_imgs["guicgalpngtest"] = "cgalpngtest" -share_expected_imgs["guiopencsgtest"] = "opencsgtest" -  def initialize_environment():      if not options.generate: options.generate = bool(os.getenv("TEST_GENERATE"))      return True -def init_expected_filename(testname, cmd): +def init_expected_filename():      global expecteddir, expectedfilename -    testbinary_filename = os.path.split(cmd)[1] -    if testbinary_filename in share_expected_imgs: -      testbinary_filename = share_expected_imgs[testbinary_filename] -    expecteddir = os.path.join(options.regressiondir, testbinary_filename ) -    expectedfilename = os.path.join(expecteddir, testname + "-expected." + options.suffix) -    expectedfilename = os.path.normpath( expectedfilename ) + +    expected_testname = options.testname + +    if hasattr(options, "expecteddir"): +        expected_dirname = options.expecteddir +    else: +        expected_dirname = expected_testname + +    expecteddir = os.path.join(options.regressiondir, expected_dirname) +    expectedfilename = os.path.join(expecteddir, options.filename + "-expected." + options.suffix) +    expectedfilename = os.path.normpath(expectedfilename) + +def init_actual_filename(): +    global actualdir, actualfilename + +    cmdname = os.path.split(options.cmd)[1] +    actualdir = os.path.join(os.getcwd(), options.testname + "-output") +    actualfilename = os.path.join(actualdir, options.filename + "-actual." + options.suffix) +    actualfilename = os.path.normpath(actualfilename)  def verify_test(testname, cmd):      global expectedfilename @@ -108,7 +117,7 @@ def compare_png(resultfilename):      msg += '\n expected image: ' + expectedfilename + '\n'      print >> sys.stderr, msg      if not resultfilename: -        print >> sys.stderr, "Error: OpenSCAD error during test image generation" +        print >> sys.stderr, "Error: Error during test image generation"          return False      print >> sys.stderr, ' actual image: ', resultfilename @@ -135,25 +144,24 @@ def compare_with_expected(resultfilename):  def run_test(testname, cmd, args):      cmdname = os.path.split(options.cmd)[1] -    outputdir = os.path.join(os.getcwd(), cmdname + "-output") -    actualfilename = os.path.join(outputdir, testname + "-actual." + options.suffix) -    actualfilename = os.path.normpath(actualfilename) -      if options.generate:           if not os.path.exists(expecteddir): os.makedirs(expecteddir)          outputname = expectedfilename      else: -        if not os.path.exists(outputdir): os.makedirs(outputdir) +        if not os.path.exists(actualdir): os.makedirs(actualdir)          outputname = actualfilename -    outputname = os.path.normpath( outputname ) +    outputname = os.path.normpath(outputname)      outfile = open(outputname, "wb")      try:          if os.path.isfile(cmd+'.exe') and options.mingw_cross_env:              cmdline = ['wine']+[cmd+'.exe'] + args + [outputname] +        elif cmd[-4:].lower() == '.exe' and options.mingw_cross_env: +            cmdline = ['wine']+[cmd] + args + [outputname]          else:              cmdline = [cmd] + args + [outputname] +        print cmdline          proc = subprocess.Popen(cmdline, stdout=subprocess.PIPE, stderr=subprocess.PIPE)          errtext = proc.communicate()[1]          if errtext != None and len(errtext) > 0: @@ -179,15 +187,18 @@ class Options:  def usage():      print >> sys.stderr, "Usage: " + sys.argv[0] + " [<options>] <cmdline-tool> <argument>"      print >> sys.stderr, "Options:" -    print >> sys.stderr, "  -g, --generate        Generate expected output for the given tests" -    print >> sys.stderr, "  -s, --suffix=<suffix> Write -expected and -actual files with the given suffix instead of .txt" -    print >> sys.stderr, "  -t, --test=<name>     Specify test name instead of deducting it from the argument" -    print >> sys.stderr, "  -c, --convexec=<name> Path to ImageMagick 'convert' executable" -    print >> sys.stderr, "  -x, --mingw-cross-env Mingw-cross-env cross compilation" +    print >> sys.stderr, "  -g, --generate           Generate expected output for the given tests" +    print >> sys.stderr, "  -s, --suffix=<suffix>    Write -expected and -actual files with the given suffix instead of .txt" +    print >> sys.stderr, "  -e, --expected-dir=<dir> Use -expected files from the given dir (to share files between test drivers)" +    print >> sys.stderr, "  -t, --test=<name>        Specify test name instead of deducting it from the argument (defaults to basename <exe>)" +    print >> sys.stderr, "  -f, --file=<name>        Specify test file instead of deducting it from the argument (default to basename <first arg>)" +    print >> sys.stderr, "  -c, --convexec=<name>    Path to ImageMagick 'convert' executable" +    print >> sys.stderr, "  -x, --mingw-cross-env    Mingw-cross-env cross compilation" +  if __name__ == '__main__':      # Handle command-line arguments      try: -        opts, args = getopt.getopt(sys.argv[1:], "gs:c:t:m:x", ["generate", "convexec=", "suffix=", "test=", "comparator=", "mingw-cross-env"]) +        opts, args = getopt.getopt(sys.argv[1:], "gs:e:c:t:f:m:x", ["generate", "convexec=", "suffix=", "expected_dir=", "test=", "file=", "comparator=", "mingw-cross-env"])      except getopt.GetoptError, err:          usage()          sys.exit(2) @@ -197,14 +208,19 @@ if __name__ == '__main__':      options.regressiondir = os.path.join(os.path.split(sys.argv[0])[0], "regression")      options.generate = False      options.suffix = "txt" +    options.comparator = ""      for o, a in opts:          if o in ("-g", "--generate"): options.generate = True          elif o in ("-s", "--suffix"):              if a[0] == '.': options.suffix = a[1:]              else: options.suffix = a +        elif o in ("-e", "--expected-dir"): +            options.expecteddir = a          elif o in ("-t", "--test"):              options.testname = a +        elif o in ("-f", "--file"): +            options.filename = a          elif o in ("-c", "--convexec"):               options.convert_exec = os.path.normpath( a )          elif o in ("-m", "--comparator"): @@ -221,16 +237,20 @@ if __name__ == '__main__':      # If only one test file, we can usually deduct the test name from the file      if len(args) == 2:          basename = os.path.splitext(args[1])[0] -        path, options.testname = os.path.split(basename) +        path, options.filename = os.path.split(basename) -    if not hasattr(options, "testname"): -        print >> sys.stderr, "Test name cannot be deducted from arguments. Specify test name using the -t option" +    if not hasattr(options, "filename"): +        print >> sys.stderr, "Filename cannot be deducted from arguments. Specify test filename using the -f option"          sys.exit(2) +    if not hasattr(options, "testname"): +        options.testname = os.path.split(args[0])[1] +      # Initialize and verify run-time environment      if not initialize_environment(): sys.exit(1) -    init_expected_filename(options.testname, options.cmd) +    init_expected_filename() +    init_actual_filename()      # Verify test environment      verification = verify_test(options.testname, options.cmd) diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 54b0f92..3f4f1c9 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -312,14 +312,21 @@ TESTLOG  def png_encode64( fname, width=250 ):  	# en.wikipedia.org/wiki/Data_URI_scheme -	f = open( fname, "rb" ) -	data = f.read() +	try: +		f = open( fname, "rb" ) +		data = f.read() +	except: +		data = ''  	data_uri = data.encode("base64").replace("\n","")  	tag  = '<img' +	tag += ' style="border:1px solid gray"'  	tag += ' src="data:image/png;base64,'  	tag +=   data_uri + '"'  	tag += ' width="'+str(width)+'"' -	tag += ' alt="openscad_test_image"' +	if data =='': +		tag += ' alt="error: no image generated"' +	else: +		tag += ' alt="openscad_test_image"'  	tag += ' />\n'  	return tag | 
