summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDon Bright <hugh.m.bright@gmail.com>2013-09-21 05:12:42 (GMT)
committerDon Bright <hugh.m.bright@gmail.com>2013-09-21 05:12:42 (GMT)
commit47ed2f1b1262c0bda78153c9cebf576b571a7bb4 (patch)
treec52cf024811cad90cbf31dde086eda5f59d3a9e5
parent5f36117b8ff7e14ae450e770cdaa67e60561672d (diff)
moving towards making tests work on bsd again
-rw-r--r--scripts/setenv-unibuild.sh19
-rwxr-xr-xscripts/uni-build-dependencies.sh8
-rw-r--r--src/openscad.cc27
-rw-r--r--tests/CMakeLists.txt46
-rwxr-xr-xtests/dumptest12
-rwxr-xr-xtests/echotest8
-rwxr-xr-xtests/test_cmdline_tool.py1
7 files changed, 78 insertions, 43 deletions
diff --git a/scripts/setenv-unibuild.sh b/scripts/setenv-unibuild.sh
index cb0b0a0..d5ccb75 100644
--- a/scripts/setenv-unibuild.sh
+++ b/scripts/setenv-unibuild.sh
@@ -51,6 +51,9 @@ setenv_freebsd()
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 +78,19 @@ setenv_linux_clang()
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
@@ -127,6 +143,9 @@ elif [ "`uname | grep -i freebsd`" ]; then
setenv_freebsd
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 6596c8a..f55e195 100755
--- a/scripts/uni-build-dependencies.sh
+++ b/scripts/uni-build-dependencies.sh
@@ -282,6 +282,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"
@@ -289,7 +290,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;
@@ -298,6 +299,7 @@ build_cgal()
download_cmd=vernull;
fi
+ eval echo "$"$download_cmd
`eval echo "$"$download_cmd`
zipper=gzip
@@ -563,7 +565,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
@@ -592,7 +594,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 5a219ac..d8ce112 100644
--- a/src/openscad.cc
+++ b/src/openscad.cc
@@ -83,6 +83,16 @@ using std::vector;
using boost::lexical_cast;
using boost::is_any_of;
+static void echotest_output_handler( const std::string &msg, void *userdata )
+{
+ std::ofstream *outstream = static_cast<std::ofstream *>(userdata);
+ if (!outstream->is_open()) {
+ fprintf(stderr,"Error writing outstream\n" );
+ return;
+ }
+ *outstream << msg;
+}
+
static void help(const char *progname)
{
int tab = int(strlen(progname))+8;
@@ -191,7 +201,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 *echotest_output_file = NULL;
std::string suffix = boosty::extension_str( output_file );
boost::algorithm::to_lower( suffix );
@@ -203,7 +213,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 == ".echotest") echotest_output_file = output_file;
else {
fprintf(stderr, "Unknown suffix for output file %s\n", output_file);
return 1;
@@ -216,6 +226,15 @@ int cmdline( const char* deps_output_file, const char* filename, Camera &camera,
top_ctx.dump(NULL, NULL);
#endif
+ if (echotest_output_file) {
+ std::ofstream fstream( echotest_output_file );
+ if (!fstream.is_open()) {
+ PRINTB("Can't open file \"%s\" for export", csg_output_file);
+ } else {
+ set_output_handler( echotest_output_handler, fstream );
+ }
+ }
+
FileModule *root_module;
ModuleInstantiation root_inst("group");
AbstractNode *root_node;
@@ -301,8 +320,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 ((echotest_output_file || png_output_file) && !(renderer==Render::CGAL)) {
+ // echotest 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 387d6ee..4c4bf9f 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
@@ -115,12 +117,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).
-
- # message(STATUS "inclusion ${user_set_path} ${found_paths}")
- # message(STATUS "inclusion ${${user_set_path}} ${${found_paths}}")
+ # 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.
+
+ 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}}.*)
@@ -129,10 +134,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()
@@ -330,6 +339,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)
@@ -558,9 +574,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
@@ -587,9 +603,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()
#
@@ -869,8 +885,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
@@ -883,6 +897,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 echotest FILES ${ECHO_FILES})
+add_cmdline_test(dumptest EXE ${OPENSCAD_BINPATH} ARGS -o dump 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 f9247c7..0000000
--- 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 a2302ff..0000000
--- 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/test_cmdline_tool.py b/tests/test_cmdline_tool.py
index 470be1e..6977a88 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
contact: Jan Huwald // Impressum