From c765f5162f159a233c776e7288f68d440f81b326 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Sun, 1 Jan 2012 21:30:39 -0600 Subject: fix crash bug rpt by nop head - 'use ' when x.scad doesnt exist diff --git a/src/parser.y b/src/parser.y index b0df50d..958ef89 100644 --- a/src/parser.y +++ b/src/parser.y @@ -588,13 +588,18 @@ AbstractModule *parse(const char *text, const char *path, int debug) if (!module) return NULL; - BOOST_FOREACH(Module::ModuleContainer::value_type &m, module->usedlibs) { + std::vector to_erase; + + BOOST_FOREACH(Module::ModuleContainer::value_type &m, module->usedlibs) { module->usedlibs[m.first] = Module::compile_library(m.first); if (!module->usedlibs[m.first]) { PRINTF("WARNING: Failed to compile library `%s'.", m.first.c_str()); - module->usedlibs.erase(m.first); + to_erase.push_back( m.first ); } } + BOOST_FOREACH( std::string s, to_erase ) { + module->usedlibs.erase( s ); + } parser_error_pos = -1; return module; -- cgit v0.10.1 From 597c5611072348d2d411d4f567fd8d0a46731628 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 3 Jan 2012 20:33:11 +0100 Subject: Ignore more generated files diff --git a/tests/.gitignore b/tests/.gitignore index ba02d4c..4dc4e40 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -19,4 +19,6 @@ out.png /echotest /opencsgtest /throwntogethertest -/yee_compare +/cgalstlsanitytest +/sysinfo.txt +/CTestCustom.cmake \ No newline at end of file -- cgit v0.10.1 From fac508c8cd3ceef0f0abf1edb7f48f866d8a1232 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 3 Jan 2012 20:34:31 +0100 Subject: Added use-tests, minimal change to include-tests diff --git a/testdata/scad/features/include-tests.scad b/testdata/scad/features/include-tests.scad index 36c04ca..fc4e9d0 100644 --- a/testdata/scad/features/include-tests.scad +++ b/testdata/scad/features/include-tests.scad @@ -7,7 +7,7 @@ include //Test with empty path include -//Test without preceeding space +//Test without preceding space include //Test with other strange character that is allowed @@ -34,7 +34,7 @@ module test1() translate([-2,-2,0]) test6(); //Just to give a top level object - translate([0,-2,0]) sphere(0.7, $fn=16); + translate([0,-2,0]) sphere(test2_variable, $fn=16); } test1(); diff --git a/testdata/scad/features/sub1/sub2/sub3/sub4/include-test2.scad b/testdata/scad/features/sub1/sub2/sub3/sub4/include-test2.scad index 140c4ed..c34632c 100644 --- a/testdata/scad/features/sub1/sub2/sub3/sub4/include-test2.scad +++ b/testdata/scad/features/sub1/sub2/sub3/sub4/include-test2.scad @@ -4,7 +4,9 @@ include //Test relative file location include <../include-test4.scad> -module test2 () +test2_variable = 0.7; + +module test2() { cube(center=true); } diff --git a/testdata/scad/features/sub1/sub2/sub3/sub4/use-test2.scad b/testdata/scad/features/sub1/sub2/sub3/sub4/use-test2.scad new file mode 100644 index 0000000..68013db --- /dev/null +++ b/testdata/scad/features/sub1/sub2/sub3/sub4/use-test2.scad @@ -0,0 +1,14 @@ +//Test nested use +use + +//Test relative file location +use <../use-test4.scad> + +test2_variable = 0.7; + +module test2() +{ + translate([2,0,0]) test3(); + translate([2,-2,0]) test4(); + cube(center=true); +} diff --git a/testdata/scad/features/sub1/sub2/sub3/sub4/use-test3.scad b/testdata/scad/features/sub1/sub2/sub3/sub4/use-test3.scad new file mode 100644 index 0000000..6e3537e --- /dev/null +++ b/testdata/scad/features/sub1/sub2/sub3/sub4/use-test3.scad @@ -0,0 +1,4 @@ +module test3() +{ + cylinder(r1=0.7, r2=0.2, center=true); +} diff --git a/testdata/scad/features/sub1/sub2/sub3/use-test4.scad b/testdata/scad/features/sub1/sub2/sub3/use-test4.scad new file mode 100644 index 0000000..c13368c --- /dev/null +++ b/testdata/scad/features/sub1/sub2/sub3/use-test4.scad @@ -0,0 +1,4 @@ +module test4() +{ + cylinder(r=0.5, $fn=10, center=true); +} diff --git a/testdata/scad/features/use test6.scad b/testdata/scad/features/use test6.scad new file mode 100644 index 0000000..0d96b26 --- /dev/null +++ b/testdata/scad/features/use test6.scad @@ -0,0 +1,7 @@ +module test6() +{ + difference() { + cube(center=true); + cylinder(r=0.4, h=2, center=true); + } +} diff --git a/testdata/scad/features/use-test5.scad b/testdata/scad/features/use-test5.scad new file mode 100644 index 0000000..e4393cb --- /dev/null +++ b/testdata/scad/features/use-test5.scad @@ -0,0 +1,4 @@ +module test5() +{ + sphere(r=0.5, $fn=8); +} diff --git a/testdata/scad/features/use-tests.scad b/testdata/scad/features/use-tests.scad new file mode 100644 index 0000000..64af692 --- /dev/null +++ b/testdata/scad/features/use-tests.scad @@ -0,0 +1,39 @@ +//Test that the entire path is pushed onto the stack upto the last '/' +use + +//Test that a non existent path/file doesn't screw things up +use + +//Test with empty path +use + +//Test without preceding space +use + +//Test with other strange character that is allowed +use>>>>> + +//Test that filenames with spaces work +use + +//Test with empty file +use + +//Test with empty path and file +use + +module test1() +{ + test2(); + // test3() and test4() are not directly included and thus not imported into + // this scope + translate([4,0,0]) test3(); + translate([4,-2,0]) test4(); + translate([-2,0,0]) test5(); + translate([-2,-2,0]) test6(); + + // test2_variable won't be visible + translate([0,-2,0]) sphere(test2_variable, $fn=16); +} + +test1(); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index cdcc0c0..13d3b37 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -547,7 +547,9 @@ file(GLOB FEATURES_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/features/*.scad) # Remove included files not to be used as tests list(REMOVE_ITEM FEATURES_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/features/include\ test6.scad - ${CMAKE_SOURCE_DIR}/../testdata/scad/features/include-test5.scad) + ${CMAKE_SOURCE_DIR}/../testdata/scad/features/include-test5.scad + ${CMAKE_SOURCE_DIR}/../testdata/scad/features/use\ test6.scad + ${CMAKE_SOURCE_DIR}/../testdata/scad/features/use-test5.scad) file(GLOB BUGS_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/*.scad) file(GLOB SCAD_DXF_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/dxf/*.scad) file(GLOB FUNCTION_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/functions/*.scad) -- cgit v0.10.1 From ef7ab1c27513fde693038dc7163836954a018df4 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 3 Jan 2012 20:35:14 +0100 Subject: Small clarification of Don's Windows parser crash fix diff --git a/src/parser.y b/src/parser.y index 958ef89..3dd933c 100644 --- a/src/parser.y +++ b/src/parser.y @@ -588,17 +588,15 @@ AbstractModule *parse(const char *text, const char *path, int debug) if (!module) return NULL; - std::vector to_erase; - - BOOST_FOREACH(Module::ModuleContainer::value_type &m, module->usedlibs) { - module->usedlibs[m.first] = Module::compile_library(m.first); - if (!module->usedlibs[m.first]) { - PRINTF("WARNING: Failed to compile library `%s'.", m.first.c_str()); - to_erase.push_back( m.first ); - } - } - BOOST_FOREACH( std::string s, to_erase ) { - module->usedlibs.erase( s ); + // Iterating manually since we want to modify the container while iterating + Module::ModuleContainer::iterator iter = module->usedlibs.begin(); + while (iter != module->usedlibs.end()) { + Module::ModuleContainer::iterator curr = iter++; + curr->second = Module::compile_library(curr->first); + if (!curr->second) { + PRINTF("WARNING: Failed to compile library `%s'.", curr->first.c_str()); + module->usedlibs.erase(curr); + } } parser_error_pos = -1; -- cgit v0.10.1 From 9f16204889c8e42785bf82d6a5db74c80e0027b6 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 3 Jan 2012 20:47:09 +0100 Subject: Added expected files for use-tests diff --git a/tests/regression/cgalpngtest/use-tests-expected.png b/tests/regression/cgalpngtest/use-tests-expected.png new file mode 100644 index 0000000..21747cc Binary files /dev/null and b/tests/regression/cgalpngtest/use-tests-expected.png differ diff --git a/tests/regression/dumptest/use-tests-expected.txt b/tests/regression/dumptest/use-tests-expected.txt new file mode 100644 index 0000000..7ba3ac5 --- /dev/null +++ b/tests/regression/dumptest/use-tests-expected.txt @@ -0,0 +1,34 @@ + group() { + group() { + multmatrix([[1, 0, 0, 2], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + group() { + cylinder($fn = 0, $fa = 12, $fs = 2, h = 1, r1 = 0.7, r2 = 0.2, center = true); + } + } + multmatrix([[1, 0, 0, 2], [0, 1, 0, -2], [0, 0, 1, 0], [0, 0, 0, 1]]) { + group() { + cylinder($fn = 10, $fa = 12, $fs = 2, h = 1, r1 = 0.5, r2 = 0.5, center = true); + } + } + cube(size = [1, 1, 1], center = true); + } + multmatrix([[1, 0, 0, 4], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]); + multmatrix([[1, 0, 0, 4], [0, 1, 0, -2], [0, 0, 1, 0], [0, 0, 0, 1]]); + multmatrix([[1, 0, 0, -2], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + group() { + sphere($fn = 8, $fa = 12, $fs = 2, r = 0.5); + } + } + multmatrix([[1, 0, 0, -2], [0, 1, 0, -2], [0, 0, 1, 0], [0, 0, 0, 1]]) { + group() { + difference() { + cube(size = [1, 1, 1], center = true); + cylinder($fn = 0, $fa = 12, $fs = 2, h = 2, r1 = 0.4, r2 = 0.4, center = true); + } + } + } + multmatrix([[1, 0, 0, 0], [0, 1, 0, -2], [0, 0, 1, 0], [0, 0, 0, 1]]) { + sphere($fn = 16, $fa = 12, $fs = 2, r = 1); + } + } + diff --git a/tests/regression/opencsgtest/use-tests-expected.png b/tests/regression/opencsgtest/use-tests-expected.png new file mode 100644 index 0000000..8a85ad5 Binary files /dev/null and b/tests/regression/opencsgtest/use-tests-expected.png differ diff --git a/tests/regression/throwntogethertest/use-tests-expected.png b/tests/regression/throwntogethertest/use-tests-expected.png new file mode 100644 index 0000000..e5bf382 Binary files /dev/null and b/tests/regression/throwntogethertest/use-tests-expected.png differ -- cgit v0.10.1