diff options
| -rw-r--r-- | src/lexer.l | 25 | ||||
| -rw-r--r-- | testdata/scad/misc/include test6.scad (renamed from testdata/scad/features/include test6.scad) | 0 | ||||
| -rw-r--r-- | testdata/scad/misc/include-test5.scad (renamed from testdata/scad/features/include-test5.scad) | 0 | ||||
| -rw-r--r-- | testdata/scad/misc/include-tests-template.scad (renamed from testdata/scad/features/include-tests.scad) | 5 | ||||
| -rw-r--r-- | testdata/scad/misc/sub1/sub2/sub3/include-test4.scad (renamed from testdata/scad/features/sub1/sub2/sub3/include-test4.scad) | 0 | ||||
| -rw-r--r-- | testdata/scad/misc/sub1/sub2/sub3/sub4/include-test2.scad (renamed from testdata/scad/features/sub1/sub2/sub3/sub4/include-test2.scad) | 0 | ||||
| -rw-r--r-- | testdata/scad/misc/sub1/sub2/sub3/sub4/include-test3.scad (renamed from testdata/scad/features/sub1/sub2/sub3/sub4/include-test3.scad) | 0 | ||||
| -rw-r--r-- | testdata/scad/misc/sub1/sub2/sub3/sub4/use-test2.scad (renamed from testdata/scad/features/sub1/sub2/sub3/sub4/use-test2.scad) | 0 | ||||
| -rw-r--r-- | testdata/scad/misc/sub1/sub2/sub3/sub4/use-test3.scad (renamed from testdata/scad/features/sub1/sub2/sub3/sub4/use-test3.scad) | 0 | ||||
| -rw-r--r-- | testdata/scad/misc/sub1/sub2/sub3/use-test4.scad (renamed from testdata/scad/features/sub1/sub2/sub3/use-test4.scad) | 0 | ||||
| -rw-r--r-- | testdata/scad/misc/sub2/test7.scad | 4 | ||||
| -rw-r--r-- | testdata/scad/misc/use test6.scad (renamed from testdata/scad/features/use test6.scad) | 0 | ||||
| -rw-r--r-- | testdata/scad/misc/use-test5.scad (renamed from testdata/scad/features/use-test5.scad) | 0 | ||||
| -rw-r--r-- | testdata/scad/misc/use-tests-template.scad (renamed from testdata/scad/features/use-tests.scad) | 4 | ||||
| -rw-r--r-- | tests/CMakeLists.txt | 18 | ||||
| -rw-r--r-- | tests/regression/cgalpngtest/include-tests-expected.png | bin | 11444 -> 10582 bytes | |||
| -rw-r--r-- | tests/regression/cgalpngtest/use-tests-expected.png | bin | 10852 -> 10586 bytes | |||
| -rw-r--r-- | tests/regression/dumptest/include-tests-expected.txt | 5 | ||||
| -rw-r--r-- | tests/regression/dumptest/use-tests-expected.txt | 5 | ||||
| -rw-r--r-- | tests/regression/opencsgtest/include-tests-expected.png | bin | 11994 -> 11304 bytes | |||
| -rw-r--r-- | tests/regression/opencsgtest/use-tests-expected.png | bin | 11165 -> 11050 bytes | |||
| -rw-r--r-- | tests/regression/throwntogethertest/include-tests-expected.png | bin | 8317 -> 11420 bytes | |||
| -rw-r--r-- | tests/regression/throwntogethertest/use-tests-expected.png | bin | 11618 -> 11432 bytes | 
23 files changed, 50 insertions, 16 deletions
| diff --git a/src/lexer.l b/src/lexer.l index 459f92d..718874f 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -108,12 +108,18 @@ use[ \t\r\n>]*"<"	{ BEGIN(cond_use); }  [^\t\r\n>]+	{ filename = yytext; }   ">"		{   	BEGIN(INITIAL);  -	fs::path usepath = fs::path(parser_source_path) / filename; -        if (!fs::exists(usepath)) { -          usepath = fs::path(librarydir) / filename; -	} -	handle_dep(fs::absolute(usepath).string()); -	parserlval.text = strdup(fs::absolute(usepath).string().c_str()); +        fs::path usepath; +        if (fs::path(filename).is_absolute()) { +          usepath = filename; +        } +        else { +          usepath = fs::path(parser_source_path) / filename; +          if (!fs::exists(usepath)) { +            usepath = fs::absolute(fs::path(librarydir) / filename); +          } +        } +	handle_dep(usepath.string()); +	parserlval.text = strdup(usepath.string().c_str());  	return TOK_USE;   }  } @@ -192,7 +198,12 @@ void includefile()    fs::path dirinfo = sourcepath();    if (!filepath.empty()) { -    dirinfo /= filepath; +    if (fs::path(filepath).is_absolute()) { +      dirinfo = filepath; +    } +    else { +      dirinfo /= filepath; +    }    }    fs::path finfo = dirinfo / filename; diff --git a/testdata/scad/features/include test6.scad b/testdata/scad/misc/include test6.scad index 0d96b26..0d96b26 100644 --- a/testdata/scad/features/include test6.scad +++ b/testdata/scad/misc/include test6.scad diff --git a/testdata/scad/features/include-test5.scad b/testdata/scad/misc/include-test5.scad index e4393cb..e4393cb 100644 --- a/testdata/scad/features/include-test5.scad +++ b/testdata/scad/misc/include-test5.scad diff --git a/testdata/scad/features/include-tests.scad b/testdata/scad/misc/include-tests-template.scad index fc4e9d0..6724a6d 100644 --- a/testdata/scad/features/include-tests.scad +++ b/testdata/scad/misc/include-tests-template.scad @@ -22,8 +22,8 @@ include<test/>  //Test with empty path and file  include </> -//Test with empty -include <> +//Test with absolute path +include <@CMAKE_SOURCE_DIR@/../testdata/scad/misc/sub2/test7.scad>  module test1()  { @@ -32,6 +32,7 @@ module test1()  	translate([2,-2,0]) test4();  	translate([-2,0,0]) test5();  	translate([-2,-2,0]) test6(); +	translate([0,2,0]) test7();  	//Just to give a top level object  	translate([0,-2,0]) sphere(test2_variable, $fn=16); diff --git a/testdata/scad/features/sub1/sub2/sub3/include-test4.scad b/testdata/scad/misc/sub1/sub2/sub3/include-test4.scad index c13368c..c13368c 100644 --- a/testdata/scad/features/sub1/sub2/sub3/include-test4.scad +++ b/testdata/scad/misc/sub1/sub2/sub3/include-test4.scad diff --git a/testdata/scad/features/sub1/sub2/sub3/sub4/include-test2.scad b/testdata/scad/misc/sub1/sub2/sub3/sub4/include-test2.scad index c34632c..c34632c 100644 --- a/testdata/scad/features/sub1/sub2/sub3/sub4/include-test2.scad +++ b/testdata/scad/misc/sub1/sub2/sub3/sub4/include-test2.scad diff --git a/testdata/scad/features/sub1/sub2/sub3/sub4/include-test3.scad b/testdata/scad/misc/sub1/sub2/sub3/sub4/include-test3.scad index 6e3537e..6e3537e 100644 --- a/testdata/scad/features/sub1/sub2/sub3/sub4/include-test3.scad +++ b/testdata/scad/misc/sub1/sub2/sub3/sub4/include-test3.scad diff --git a/testdata/scad/features/sub1/sub2/sub3/sub4/use-test2.scad b/testdata/scad/misc/sub1/sub2/sub3/sub4/use-test2.scad index 68013db..68013db 100644 --- a/testdata/scad/features/sub1/sub2/sub3/sub4/use-test2.scad +++ b/testdata/scad/misc/sub1/sub2/sub3/sub4/use-test2.scad diff --git a/testdata/scad/features/sub1/sub2/sub3/sub4/use-test3.scad b/testdata/scad/misc/sub1/sub2/sub3/sub4/use-test3.scad index 6e3537e..6e3537e 100644 --- a/testdata/scad/features/sub1/sub2/sub3/sub4/use-test3.scad +++ b/testdata/scad/misc/sub1/sub2/sub3/sub4/use-test3.scad diff --git a/testdata/scad/features/sub1/sub2/sub3/use-test4.scad b/testdata/scad/misc/sub1/sub2/sub3/use-test4.scad index c13368c..c13368c 100644 --- a/testdata/scad/features/sub1/sub2/sub3/use-test4.scad +++ b/testdata/scad/misc/sub1/sub2/sub3/use-test4.scad diff --git a/testdata/scad/misc/sub2/test7.scad b/testdata/scad/misc/sub2/test7.scad new file mode 100644 index 0000000..12ff245 --- /dev/null +++ b/testdata/scad/misc/sub2/test7.scad @@ -0,0 +1,4 @@ +module test7() +{ +  cube([0.5,0.5,1], center=true); +} diff --git a/testdata/scad/features/use test6.scad b/testdata/scad/misc/use test6.scad index 0d96b26..0d96b26 100644 --- a/testdata/scad/features/use test6.scad +++ b/testdata/scad/misc/use test6.scad diff --git a/testdata/scad/features/use-test5.scad b/testdata/scad/misc/use-test5.scad index e4393cb..e4393cb 100644 --- a/testdata/scad/features/use-test5.scad +++ b/testdata/scad/misc/use-test5.scad diff --git a/testdata/scad/features/use-tests.scad b/testdata/scad/misc/use-tests-template.scad index 64af692..c39efce 100644 --- a/testdata/scad/features/use-tests.scad +++ b/testdata/scad/misc/use-tests-template.scad @@ -22,6 +22,9 @@ use<test/>  //Test with empty path and file  use </> +//Test with absolute path +include <@CMAKE_SOURCE_DIR@/../testdata/scad/misc/sub2/test7.scad> +  module test1()  {    test2(); @@ -31,6 +34,7 @@ module test1()    translate([4,-2,0]) test4();    translate([-2,0,0]) test5();    translate([-2,-2,0]) test6(); +  translate([0,2,0]) test7();    // test2_variable won't be visible    translate([0,-2,0]) sphere(test2_variable, $fn=16); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3b379d6..9d5e24e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -588,15 +588,15 @@ endforeach()  set_directory_properties(PROPERTIES TEST_INCLUDE_FILE "${CMAKE_SOURCE_DIR}/EnforceConfig.cmake") +# Subst files +configure_file(${CMAKE_SOURCE_DIR}/../testdata/scad/misc/include-tests-template.scad +               ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/include-tests.scad) +configure_file(${CMAKE_SOURCE_DIR}/../testdata/scad/misc/use-tests-template.scad +               ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/use-tests.scad) +  # Find all scad files  file(GLOB MINIMAL_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/minimal/*.scad)  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/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) @@ -613,9 +613,13 @@ list(APPEND ECHO_FILES ${FUNCTION_FILES}              ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/string-indexing.scad)  list(APPEND DUMPTEST_FILES ${MINIMAL_FILES} ${FEATURES_FILES} ${EXAMPLE_FILES}) -list(APPEND DUMPTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/escape-test.scad) +list(APPEND DUMPTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/escape-test.scad +                           ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/include-tests.scad +                           ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/use-tests.scad)  list(APPEND CGALPNGTEST_FILES ${FEATURES_FILES} ${SCAD_DXF_FILES} ${EXAMPLE_FILES}) +list(APPEND CGALPNGTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/include-tests.scad +                           ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/use-tests.scad)  list(APPEND OPENCSGTEST_FILES ${CGALPNGTEST_FILES})  list(APPEND OPENCSGTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/bbox-transform-bug.scad)  list(APPEND THROWNTOGETHERTEST_FILES ${OPENCSGTEST_FILES}) diff --git a/tests/regression/cgalpngtest/include-tests-expected.png b/tests/regression/cgalpngtest/include-tests-expected.pngBinary files differ index 99ebcc7..031dcda 100644 --- a/tests/regression/cgalpngtest/include-tests-expected.png +++ b/tests/regression/cgalpngtest/include-tests-expected.png diff --git a/tests/regression/cgalpngtest/use-tests-expected.png b/tests/regression/cgalpngtest/use-tests-expected.pngBinary files differ index 21747cc..5afa74e 100644 --- a/tests/regression/cgalpngtest/use-tests-expected.png +++ b/tests/regression/cgalpngtest/use-tests-expected.png diff --git a/tests/regression/dumptest/include-tests-expected.txt b/tests/regression/dumptest/include-tests-expected.txt index d4b5065..00e7beb 100644 --- a/tests/regression/dumptest/include-tests-expected.txt +++ b/tests/regression/dumptest/include-tests-expected.txt @@ -25,6 +25,11 @@  				}  			}  		} +		multmatrix([[1, 0, 0, 0], [0, 1, 0, 2], [0, 0, 1, 0], [0, 0, 0, 1]]) { +			group() { +				cube(size = [0.5, 0.5, 1], 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 = 0.7);  		} diff --git a/tests/regression/dumptest/use-tests-expected.txt b/tests/regression/dumptest/use-tests-expected.txt index 7ba3ac5..c320af6 100644 --- a/tests/regression/dumptest/use-tests-expected.txt +++ b/tests/regression/dumptest/use-tests-expected.txt @@ -27,6 +27,11 @@  				}  			}  		} +		multmatrix([[1, 0, 0, 0], [0, 1, 0, 2], [0, 0, 1, 0], [0, 0, 0, 1]]) { +			group() { +				cube(size = [0.5, 0.5, 1], 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/include-tests-expected.png b/tests/regression/opencsgtest/include-tests-expected.pngBinary files differ index 62be03c..c1e780b 100644 --- a/tests/regression/opencsgtest/include-tests-expected.png +++ b/tests/regression/opencsgtest/include-tests-expected.png diff --git a/tests/regression/opencsgtest/use-tests-expected.png b/tests/regression/opencsgtest/use-tests-expected.pngBinary files differ index 8a85ad5..5141b37 100644 --- a/tests/regression/opencsgtest/use-tests-expected.png +++ b/tests/regression/opencsgtest/use-tests-expected.png diff --git a/tests/regression/throwntogethertest/include-tests-expected.png b/tests/regression/throwntogethertest/include-tests-expected.pngBinary files differ index 5b1857b..b6dc00e 100644 --- a/tests/regression/throwntogethertest/include-tests-expected.png +++ b/tests/regression/throwntogethertest/include-tests-expected.png diff --git a/tests/regression/throwntogethertest/use-tests-expected.png b/tests/regression/throwntogethertest/use-tests-expected.pngBinary files differ index e5bf382..7e2f702 100644 --- a/tests/regression/throwntogethertest/use-tests-expected.png +++ b/tests/regression/throwntogethertest/use-tests-expected.png | 
