summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordon bright <hugh.m.bright@gmail.com>2013-01-31 02:42:33 (GMT)
committerdon bright <hugh.m.bright@gmail.com>2013-01-31 02:42:33 (GMT)
commitd0de384a7e1642d09726579fdd75f1588cfaada7 (patch)
tree39d7ddda525b128194d451da520d311d95ecb39f
parent961dd79d9d920e011d5381d199abfc9638fd437e (diff)
translate shell script wrapper into C++ code, for portability
-rw-r--r--tests/CMakeLists.txt27
-rwxr-xr-xtests/guicgalpngtest17
-rw-r--r--tests/guicgalpngtest.cc28
3 files changed, 42 insertions, 30 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 0375700..c606d22 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -554,6 +554,20 @@ set_target_properties(throwntogethertest PROPERTIES COMPILE_FLAGS "-DENABLE_OPEN
target_link_libraries(throwntogethertest tests-offscreen tests-cgal ${OPENCSG_LIBRARY} ${TESTS-CGAL-LIBRARIES} ${GLEW_LIBRARY} ${COCOA_LIBRARY})
#
+# gui tests (simple wrappers around the GUI binary built by qmake)
+#
+if(APPLE)
+ set(GUI_BINPATH "${CMAKE_CURRENT_SOURCE_DIR}/../OpenSCAD.app/Contents/MacOS/OpenSCAD")
+elseif(WIN32)
+ set(GUI_BINPATH "${CMAKE_CURRENT_SOURCE_DIR}/../Release/openscad.exe")
+else()
+ set(GUI_BINPATH "${CMAKE_CURRENT_SOURCE_DIR}/../openscad")
+endif()
+
+add_executable(guicgalpngtest guicgalpngtest.cc)
+set_target_properties(guicgalpngtest PROPERTIES COMPILE_FLAGS "-DBINPATH=${GUI_BINPATH}")
+
+#
# Tags tests as disabled. This is more convenient than removing them manually
# from the lists of filenames
#
@@ -790,19 +804,6 @@ foreach(FILE ${EXAMPLE_FILES})
set_test_config(Examples ${TEST_FULLNAME})
endforeach()
-# GUI test
-
-message(STATUS "copying openscad GUI binary...")
-file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/guicgalpngtest
- DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
-IF (APPLE)
- file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/../OpenSCAD.app
- DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
-ELSE()
- file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/../openscad
- DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
-ENDIF()
-
# Add tests
add_cmdline_test(echotest txt ${ECHO_FILES})
diff --git a/tests/guicgalpngtest b/tests/guicgalpngtest
deleted file mode 100755
index 0ba7fc2..0000000
--- a/tests/guicgalpngtest
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh
-
-# $2 = png filename
-# $1 = scad filename
-
-# Handle Mac binaries specially - somewhat hackish..
-EXE=./OpenSCAD.app/Contents/MacOS/OpenSCAD
-if [ ! -e $EXE ]; then
- EXE=./openscad
- if [ ! -e $EXE ]; then
- echo "OpenSCAD binary not found"
- exit 1
- fi
-fi
-
-$EXE $1 -o $2 --render
-
diff --git a/tests/guicgalpngtest.cc b/tests/guicgalpngtest.cc
new file mode 100644
index 0000000..8c4f6de
--- /dev/null
+++ b/tests/guicgalpngtest.cc
@@ -0,0 +1,28 @@
+// 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[] )
+{
+ printf("%s: wrapper for OpenSCAD at %s\n", argv[0], QUOTE( BINPATH ) );
+ if (argc<2 || argc>2) {
+ printf("%s: bad number of arguments: %i\n", argv[0], argc);
+ return 1;
+ }
+ char *newargs[6];
+ char *scadfilename = argv[1];
+ char *pngfile = argv[2];
+ newargs[0] = argv[0];
+ newargs[1] = scadfilename;
+ newargs[2] = const_cast<char *>("-o");
+ newargs[3] = pngfile;
+ newargs[4] = const_cast<char *>("--render");
+ newargs[5] = NULL;
+ return execv( QUOTE( BINPATH ), newargs );
+}
+
contact: Jan Huwald // Impressum