summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt160
-rw-r--r--tests/CMakeParseArguments.cmake138
-rw-r--r--tests/guicgalpngtest.cc28
-rw-r--r--tests/guiopencsgtest.cc27
-rw-r--r--tests/regression/dumptest/scale2D-tests-expected.txt4
-rw-r--r--tests/regression/echotest/value-reassignment-tests-expected.txt1
-rw-r--r--tests/regression/openscad-camcenter/example001-expected.pngbin0 -> 11662 bytes
-rw-r--r--tests/regression/openscad-camdist/example001-expected.pngbin0 -> 16360 bytes
-rw-r--r--tests/regression/openscad-cameye/example001-expected.pngbin0 -> 17829 bytes
-rw-r--r--tests/regression/openscad-cameye2/example001-expected.pngbin0 -> 11180 bytes
-rw-r--r--tests/regression/openscad-cameyeortho/example001-expected.pngbin0 -> 25997 bytes
-rw-r--r--tests/regression/openscad-camortho/example001-expected.pngbin0 -> 10309 bytes
-rw-r--r--tests/regression/openscad-camrot/example001-expected.pngbin0 -> 22427 bytes
-rw-r--r--tests/regression/openscad-camtrans/example001-expected.pngbin0 -> 13161 bytes
-rw-r--r--tests/regression/openscad-imgsize/example001-expected.pngbin0 -> 2503 bytes
-rw-r--r--tests/regression/openscad-imgstretch/example001-expected.pngbin0 -> 3441 bytes
-rw-r--r--tests/regression/openscad-imgstretch2/example001-expected.pngbin0 -> 3881 bytes
-rwxr-xr-xtests/test_cmdline_tool.py76
-rwxr-xr-xtests/test_pretty_print.py13
19 files changed, 314 insertions, 133 deletions
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.png
new file mode 100644
index 0000000..5cdada7
--- /dev/null
+++ b/tests/regression/openscad-camcenter/example001-expected.png
Binary files differ
diff --git a/tests/regression/openscad-camdist/example001-expected.png b/tests/regression/openscad-camdist/example001-expected.png
new file mode 100644
index 0000000..363cc50
--- /dev/null
+++ b/tests/regression/openscad-camdist/example001-expected.png
Binary files differ
diff --git a/tests/regression/openscad-cameye/example001-expected.png b/tests/regression/openscad-cameye/example001-expected.png
new file mode 100644
index 0000000..ad7a8b0
--- /dev/null
+++ b/tests/regression/openscad-cameye/example001-expected.png
Binary files differ
diff --git a/tests/regression/openscad-cameye2/example001-expected.png b/tests/regression/openscad-cameye2/example001-expected.png
new file mode 100644
index 0000000..0315799
--- /dev/null
+++ b/tests/regression/openscad-cameye2/example001-expected.png
Binary files differ
diff --git a/tests/regression/openscad-cameyeortho/example001-expected.png b/tests/regression/openscad-cameyeortho/example001-expected.png
new file mode 100644
index 0000000..0de38bd
--- /dev/null
+++ b/tests/regression/openscad-cameyeortho/example001-expected.png
Binary files differ
diff --git a/tests/regression/openscad-camortho/example001-expected.png b/tests/regression/openscad-camortho/example001-expected.png
new file mode 100644
index 0000000..29c1083
--- /dev/null
+++ b/tests/regression/openscad-camortho/example001-expected.png
Binary files differ
diff --git a/tests/regression/openscad-camrot/example001-expected.png b/tests/regression/openscad-camrot/example001-expected.png
new file mode 100644
index 0000000..ecfd698
--- /dev/null
+++ b/tests/regression/openscad-camrot/example001-expected.png
Binary files differ
diff --git a/tests/regression/openscad-camtrans/example001-expected.png b/tests/regression/openscad-camtrans/example001-expected.png
new file mode 100644
index 0000000..1117751
--- /dev/null
+++ b/tests/regression/openscad-camtrans/example001-expected.png
Binary files differ
diff --git a/tests/regression/openscad-imgsize/example001-expected.png b/tests/regression/openscad-imgsize/example001-expected.png
new file mode 100644
index 0000000..52fb547
--- /dev/null
+++ b/tests/regression/openscad-imgsize/example001-expected.png
Binary files differ
diff --git a/tests/regression/openscad-imgstretch/example001-expected.png b/tests/regression/openscad-imgstretch/example001-expected.png
new file mode 100644
index 0000000..9d704c8
--- /dev/null
+++ b/tests/regression/openscad-imgstretch/example001-expected.png
Binary files differ
diff --git a/tests/regression/openscad-imgstretch2/example001-expected.png b/tests/regression/openscad-imgstretch2/example001-expected.png
new file mode 100644
index 0000000..92a93b6
--- /dev/null
+++ b/tests/regression/openscad-imgstretch2/example001-expected.png
Binary files differ
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
contact: Jan Huwald // Impressum