Merge pull request #797 from openscad/csg-import-tests

Csg import tests
master
Marius Kintel 2014-05-23 16:44:58 -04:00
commit 147685d2c8
5 changed files with 61 additions and 31 deletions

View File

@ -99,16 +99,18 @@ std::string OffsetNode::toString() const
{
std::stringstream stream;
stream << this->name()
stream << this->name()
<< "(delta = " << std::dec << this->delta
<< ", join_type = "
<< ", join_type = \""
<< (this->join_type == ClipperLib::jtSquare
? "bevel"
: this->join_type == ClipperLib::jtRound
? "round"
: "miter")
<< ", miter_limit = " << this->miter_limit
<< ", $fn = " << this->fn
: "miter") << "\"";
if (this->join_type == ClipperLib::jtMiter) {
stream << ", miter_limit = " << this->miter_limit;
}
stream << ", $fn = " << this->fn
<< ", $fa = " << this->fa
<< ", $fs = " << this->fs << ")";

View File

@ -827,11 +827,12 @@ endfunction()
# This functions adds cmd-line tests given files.
#
# Usage add_cmdline_test(testbasename [EXE <executable>] [ARGS <args to exe>]
# [SCRIPT <script>]
# [EXPECTEDDIR <shared dir>] SUFFIX <suffix> FILES <test files>)
#
find_package(PythonInterp)
function(add_cmdline_test TESTCMD_BASENAME)
cmake_parse_arguments(TESTCMD "" "EXE;SUFFIX;EXPECTEDDIR" "FILES;ARGS" ${ARGN})
cmake_parse_arguments(TESTCMD "" "EXE;SCRIPT;SUFFIX;EXPECTEDDIR" "FILES;ARGS" ${ARGN})
# If sharing results with another test, pass on this to the python script
if (TESTCMD_EXPECTEDDIR)
@ -870,7 +871,7 @@ function(add_cmdline_test TESTCMD_BASENAME)
set(FILENAME_OPTION -f ${FILE_BASENAME})
endif()
add_test(NAME ${TEST_FULLNAME} ${CONFARG} ${CONFVAL} COMMAND ${PYTHON_EXECUTABLE} ${tests_SOURCE_DIR}/test_cmdline_tool.py --comparator=${COMPARATOR} -c ${ImageMagick_convert_EXECUTABLE} -s ${TESTCMD_SUFFIX} ${EXTRA_OPTIONS} ${TESTNAME_OPTION} ${FILENAME_OPTION} ${TESTCMD_EXE} "${SCADFILE}" ${TESTCMD_ARGS})
add_test(NAME ${TEST_FULLNAME} ${CONFARG} ${CONFVAL} COMMAND ${PYTHON_EXECUTABLE} ${tests_SOURCE_DIR}/test_cmdline_tool.py --comparator=${COMPARATOR} -c ${ImageMagick_convert_EXECUTABLE} -s ${TESTCMD_SUFFIX} ${EXTRA_OPTIONS} ${TESTNAME_OPTION} ${FILENAME_OPTION} ${TESTCMD_EXE} ${TESTCMD_SCRIPT} "${SCADFILE}" ${TESTCMD_ARGS})
set_property(TEST ${TEST_FULLNAME} PROPERTY ENVIRONMENT "${CTEST_ENVIRONMENT}")
endif()
endforeach()
@ -955,17 +956,24 @@ disable_tests(opencsgtest_child-background)
disable_tests(cgalpngtest_child-background
cgalpngtest_highlight-and-background-modifier
cgalpngtest_testcolornames
openscad-cgalpng_child-background
openscad-cgalpng_highlight-and-background-modifier
openscad-cgalpng_testcolornames
csgpngtest_child-background
csgpngtest_highlight-and-background-modifier
csgpngtest_testcolornames
throwntogethertest_testcolornames)
# The inf/nan tests fail when exporting CSG and rendering that output again
# as currently inf/nan is written directly to the CSG file (e.g. r = inf)
# which is not valid or even misleading in case a variable inf exists.
# FIXME: define export behavior for inf/nan when exporting CSG files
disable_tests(csgpngtest_primitive-inf-tests csgpngtest_transform-nan-inf-tests)
# Test config handling
# Heavy tests are tests taking more than 10 seconds on a development computer
set_test_config(Heavy cgalpngtest_rotate_extrude-tests
cgalpngtest_sphere-tests
csgpngtest_rotate_extrude-tests
cgalpngtest_for-nested-tests
csgpngtest_for-nested-tests
cgalpngtest_resize-tests
cgalpngtest_text-search-test
cgalpngtest_text-font-direction-tests
@ -978,8 +986,13 @@ set_test_config(Heavy cgalpngtest_rotate_extrude-tests
throwntogethertest_text-font-tests
throwntogethertest_text-font-alignment-tests
cgalpngtest_fractal
csgpngtest_fractal
cgalpngtest_iteration
cgalpngtest_linear_extrude-scale-zero-tests)
csgpngtest_iteration
cgalpngtest_linear_extrude-scale-zero-tests
csgpngtest_linear_extrude-scale-zero-tests
cgalpngtest_sphere-tests
csgpngtest_resize-tests)
# Bugs
@ -1003,6 +1016,8 @@ foreach(FILE ${BUGS_FILES})
set_test_config(Bugs ${TEST_FULLNAME})
get_test_fullname(cgalpngtest ${FILE} TEST_FULLNAME)
set_test_config(Bugs ${TEST_FULLNAME})
get_test_fullname(csgpngtest ${FILE} TEST_FULLNAME)
set_test_config(Bugs ${TEST_FULLNAME})
endforeach()
# Examples
@ -1014,9 +1029,7 @@ 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(openscad-cgalpng ${FILE} TEST_FULLNAME)
set_test_config(Examples ${TEST_FULLNAME})
get_test_fullname(openscad-csgpng ${FILE} TEST_FULLNAME)
get_test_fullname(csgpngtest ${FILE} TEST_FULLNAME)
set_test_config(Examples ${TEST_FULLNAME})
endforeach()
@ -1082,6 +1095,7 @@ add_cmdline_test(dumptest EXE ${OPENSCAD_BINPATH} ARGS -o SUFFIX csg FILES ${DUM
add_cmdline_test(dumptest-examples EXE ${OPENSCAD_BINPATH} ARGS -o SUFFIX csg FILES ${EXAMPLE_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(csgpngtest EXE ${PYTHON_EXECUTABLE} SCRIPT csg-import-test.py ARGS ${OPENSCAD_BINPATH} EXPECTEDDIR cgalpngtest SUFFIX png FILES ${CGALPNGTEST_FILES})
add_cmdline_test(throwntogethertest EXE ${OPENSCAD_BINPATH} ARGS --preview=throwntogether -o 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

14
tests/csg-import-test.py Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env python
import sys, os, re, subprocess
scad = sys.argv[1]
bin = sys.argv[2]
png = sys.argv[3]
csg = re.sub(r"\.scad$", ".csg", scad)
print(bin, scad, csg, png);
subprocess.call([bin, scad, '-o', csg])
subprocess.call([bin, csg, '--render', '-o', png])
os.remove(csg);

View File

@ -1,7 +1,7 @@
group() {
group();
linear_extrude(height = 20, center = false, convexity = 1, scale = [0.5, 0.5], $fn = 40, $fa = 12, $fs = 2) {
offset(delta = 10, join_type = round, miter_limit = 2, $fn = 40, $fa = 12, $fs = 2) {
offset(delta = 10, join_type = "round", $fn = 40, $fa = 12, $fs = 2) {
square(size = [50, 50], center = true);
}
}
@ -9,12 +9,12 @@ group() {
linear_extrude(height = 20, center = false, convexity = 1, scale = [1, 1], $fn = 40, $fa = 12, $fs = 2) {
group() {
difference() {
offset(delta = 1, join_type = miter, miter_limit = 2, $fn = 40, $fa = 12, $fs = 2) {
offset(delta = 1, join_type = "miter", miter_limit = 2, $fn = 40, $fa = 12, $fs = 2) {
group() {
circle($fn = 40, $fa = 12, $fs = 2, r = 15);
}
}
offset(delta = -1, join_type = miter, miter_limit = 2, $fn = 40, $fa = 12, $fs = 2) {
offset(delta = -1, join_type = "miter", miter_limit = 2, $fn = 40, $fa = 12, $fs = 2) {
group() {
circle($fn = 40, $fa = 12, $fs = 2, r = 15);
}

View File

@ -1,5 +1,5 @@
group() {
offset(delta = -1, join_type = miter, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
offset(delta = -1, join_type = "miter", miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, -50], [0, 1, 0, 100], [0, 0, 1, 0], [0, 0, 0, 1]]) {
polygon(points = [[-15, 80], [15, 80], [0, -15], [-8, 60], [8, 60], [0, 5]], paths = [[0, 1, 2], [3, 4, 5]], convexity = 1);
@ -11,42 +11,42 @@ group() {
polygon(points = [[-15, 80], [15, 80], [0, -15], [-8, 60], [8, 60], [0, 5]], paths = [[0, 1, 2], [3, 4, 5]], convexity = 1);
}
}
offset(delta = 1, join_type = miter, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
offset(delta = 1, join_type = "miter", miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, 50], [0, 1, 0, 100], [0, 0, 1, 0], [0, 0, 0, 1]]) {
polygon(points = [[-15, 80], [15, 80], [0, -15], [-8, 60], [8, 60], [0, 5]], paths = [[0, 1, 2], [3, 4, 5]], convexity = 1);
}
}
}
offset(delta = -1, join_type = miter, miter_limit = 10, $fn = 0, $fa = 12, $fs = 2) {
offset(delta = -1, join_type = "miter", miter_limit = 10, $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, 100], [0, 1, 0, 100], [0, 0, 1, 0], [0, 0, 0, 1]]) {
polygon(points = [[-15, 80], [15, 80], [0, -15], [-8, 60], [8, 60], [0, 5]], paths = [[0, 1, 2], [3, 4, 5]], convexity = 1);
}
}
}
offset(delta = 1, join_type = miter, miter_limit = 10, $fn = 0, $fa = 12, $fs = 2) {
offset(delta = 1, join_type = "miter", miter_limit = 10, $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, 150], [0, 1, 0, 100], [0, 0, 1, 0], [0, 0, 0, 1]]) {
polygon(points = [[-15, 80], [15, 80], [0, -15], [-8, 60], [8, 60], [0, 5]], paths = [[0, 1, 2], [3, 4, 5]], convexity = 1);
}
}
}
offset(delta = -1, join_type = bevel, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
offset(delta = -1, join_type = "bevel", $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, 100], [0, 1, 0, -50], [0, 0, 1, 0], [0, 0, 0, 1]]) {
polygon(points = [[-15, 80], [15, 80], [0, -15], [-8, 60], [8, 60], [0, 5]], paths = [[0, 1, 2], [3, 4, 5]], convexity = 1);
}
}
}
offset(delta = 1, join_type = bevel, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
offset(delta = 1, join_type = "bevel", $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, 150], [0, 1, 0, -50], [0, 0, 1, 0], [0, 0, 0, 1]]) {
polygon(points = [[-15, 80], [15, 80], [0, -15], [-8, 60], [8, 60], [0, 5]], paths = [[0, 1, 2], [3, 4, 5]], convexity = 1);
}
}
}
offset(delta = -5, join_type = round, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
offset(delta = -5, join_type = "round", $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, -50], [0, 1, 0, 50], [0, 0, 1, 0], [0, 0, 0, 1]]) {
difference() {
@ -64,7 +64,7 @@ group() {
}
}
}
offset(delta = 5, join_type = round, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
offset(delta = 5, join_type = "round", $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, 50], [0, 1, 0, 50], [0, 0, 1, 0], [0, 0, 0, 1]]) {
difference() {
@ -74,7 +74,7 @@ group() {
}
}
}
offset(delta = -4, join_type = miter, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
offset(delta = -4, join_type = "miter", miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, -50], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
difference() {
@ -92,7 +92,7 @@ group() {
}
}
}
offset(delta = 4, join_type = miter, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
offset(delta = 4, join_type = "miter", miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, 50], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
difference() {
@ -102,7 +102,7 @@ group() {
}
}
}
offset(delta = -5, join_type = miter, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
offset(delta = -5, join_type = "miter", miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, 100], [0, 1, 0, 50], [0, 0, 1, 0], [0, 0, 0, 1]]) {
difference() {
@ -120,7 +120,7 @@ group() {
}
}
}
offset(delta = 5, join_type = miter, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
offset(delta = 5, join_type = "miter", miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, 50], [0, 1, 0, -50], [0, 0, 1, 0], [0, 0, 0, 1]]) {
difference() {
@ -132,7 +132,7 @@ group() {
}
multmatrix([[1, 0, 0, -50], [0, 1, 0, -50], [0, 0, 1, 0], [0, 0, 0, 1]]) {
multmatrix([[25, 0, 0, 0], [0, 25, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
offset(delta = 0.9, join_type = round, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
offset(delta = 0.9, join_type = "round", $fn = 0, $fa = 12, $fs = 2) {
square(size = [0.1, 0.1], center = false);
}
}