diff options
author | Don Bright <hugh.m.bright@gmail.com> | 2013-09-21 14:04:01 (GMT) |
---|---|---|
committer | Don Bright <hugh.m.bright@gmail.com> | 2013-09-21 14:04:01 (GMT) |
commit | efc6731774ca6e0da4453921ab0daeadc44ee8bc (patch) | |
tree | 8ef49291f9e31734fd60cb66e91cbea71f87bdc2 | |
parent | 47ed2f1b1262c0bda78153c9cebf576b571a7bb4 (diff) |
make echotest work on BSD, by adding .echo as recognized extension
-rw-r--r-- | doc/testing.txt | 10 | ||||
-rw-r--r-- | src/openscad.cc | 39 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/regression/echotest/builtin-tests-expected.echo (renamed from tests/regression/echotest/builtin-tests-expected.txt) | 0 | ||||
-rw-r--r-- | tests/regression/echotest/dim-all-expected.echo (renamed from tests/regression/echotest/dim-all-expected.txt) | 0 | ||||
-rw-r--r-- | tests/regression/echotest/echo-expected.echo (renamed from tests/regression/echotest/echo-expected.txt) | 0 | ||||
-rw-r--r-- | tests/regression/echotest/echo-tests-expected.echo (renamed from tests/regression/echotest/echo-tests-expected.txt) | 0 | ||||
-rw-r--r-- | tests/regression/echotest/escape-test-expected.echo (renamed from tests/regression/echotest/escape-test-expected.txt) | 0 | ||||
-rw-r--r-- | tests/regression/echotest/expression-shortcircuit-tests-expected.echo (renamed from tests/regression/echotest/expression-shortcircuit-tests-expected.txt) | 0 | ||||
-rw-r--r-- | tests/regression/echotest/inf-tests-expected.echo (renamed from tests/regression/echotest/inf-tests-expected.txt) | 0 | ||||
-rw-r--r-- | tests/regression/echotest/len-tests-expected.echo (renamed from tests/regression/echotest/len-tests-expected.txt) | 0 | ||||
-rw-r--r-- | tests/regression/echotest/lookup-tests-expected.echo (renamed from tests/regression/echotest/lookup-tests-expected.txt) | 0 | ||||
-rw-r--r-- | tests/regression/echotest/parser-tests-expected.echo (renamed from tests/regression/echotest/parser-tests-expected.txt) | 0 | ||||
-rw-r--r-- | tests/regression/echotest/rands-expected.echo (renamed from tests/regression/echotest/rands-expected.txt) | 0 | ||||
-rw-r--r-- | tests/regression/echotest/recursion-tests-expected.echo (renamed from tests/regression/echotest/recursion-tests-expected.txt) | 0 | ||||
-rw-r--r-- | tests/regression/echotest/search-tests-expected.echo (renamed from tests/regression/echotest/search-tests-expected.txt) | 0 | ||||
-rw-r--r-- | tests/regression/echotest/string-indexing-expected.echo (renamed from tests/regression/echotest/string-indexing-expected.txt) | 0 | ||||
-rw-r--r-- | tests/regression/echotest/string-test-expected.echo (renamed from tests/regression/echotest/string-test-expected.txt) | 0 | ||||
-rw-r--r-- | tests/regression/echotest/value-reassignment-tests-expected.echo (renamed from tests/regression/echotest/value-reassignment-tests-expected.txt) | 0 | ||||
-rw-r--r-- | tests/regression/echotest/value-reassignment-tests2-expected.echo (renamed from tests/regression/echotest/value-reassignment-tests2-expected.txt) | 0 | ||||
-rw-r--r-- | tests/regression/echotest/variable-scope-tests-expected.echo (renamed from tests/regression/echotest/variable-scope-tests-expected.txt) | 0 | ||||
-rw-r--r-- | tests/regression/echotest/vector-values-expected.echo (renamed from tests/regression/echotest/vector-values-expected.txt) | 0 |
22 files changed, 20 insertions, 31 deletions
diff --git a/doc/testing.txt b/doc/testing.txt index f609b65..5617e61 100644 --- a/doc/testing.txt +++ b/doc/testing.txt @@ -73,7 +73,6 @@ Two tests still need an intermediate script that mangles away timestamps and near-zero floating point numbers: * dumptest -* echotest * cgalstlsanitytest Some tests are yet to be converted: @@ -85,15 +84,6 @@ These look like tests, but are not actually in use: * modulecachetest * cgalcachetest -In the course of migration, the possibilities of using the OPENSCAD_TESTING -compile time flag go away; that flag used to strip timestamps out of files, -to unify float output, and to tweak the file inclusion paths. With that flag -unused, we get better coverage of the primary code paths, at the cost of -having to do some normalization in the unit testing process (thus the dumptest -and echo test scripts). Especially, having a nonstandard MCAD library in the -user include path can now break things -- but so can having misbehaving -programs in your PATH. - Troubleshooting: ------------------------------ diff --git a/src/openscad.cc b/src/openscad.cc index d8ce112..82afc16 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -83,15 +83,18 @@ using std::vector; using boost::lexical_cast; using boost::is_any_of; -static void echotest_output_handler( const std::string &msg, void *userdata ) +class Echostream : public std::ofstream { - std::ofstream *outstream = static_cast<std::ofstream *>(userdata); - if (!outstream->is_open()) { - fprintf(stderr,"Error writing outstream\n" ); - return; +public: + Echostream( const char * filename ) : std::ofstream( filename ) + { + set_output_handler( &Echostream::output, this ); } - *outstream << msg; -} + static void output( const std::string &msg, void *userdata ) { + Echostream *thisp = static_cast<Echostream*>(userdata); + *thisp << msg << "\n"; + } +}; static void help(const char *progname) { @@ -186,7 +189,7 @@ Camera get_camera( po::variables_map vm ) return camera; } -int cmdline( const char* deps_output_file, const char* filename, Camera &camera, const char *output_file, fs::path original_path, Render::type renderer, char ** argv ) +int cmdline( const char* deps_output_file, const char* filename, Camera &camera, const char *output_file, fs::path original_path, Render::type renderer, char ** argv, bool echo ) { parser_init(boosty::stringy(boost::filesystem::path( argv[0] ).parent_path())); Tree tree; @@ -201,7 +204,7 @@ int cmdline( const char* deps_output_file, const char* filename, Camera &camera, const char *png_output_file = NULL; const char *ast_output_file = NULL; const char *term_output_file = NULL; - const char *echotest_output_file = NULL; + const char *echo_output_file = NULL; std::string suffix = boosty::extension_str( output_file ); boost::algorithm::to_lower( suffix ); @@ -213,7 +216,7 @@ int cmdline( const char* deps_output_file, const char* filename, Camera &camera, else if (suffix == ".png") png_output_file = output_file; else if (suffix == ".ast") ast_output_file = output_file; else if (suffix == ".term") term_output_file = output_file; - else if (suffix == ".echotest") echotest_output_file = output_file; + else if (suffix == ".echo") echo_output_file = output_file; else { fprintf(stderr, "Unknown suffix for output file %s\n", output_file); return 1; @@ -226,14 +229,8 @@ int cmdline( const char* deps_output_file, const char* filename, Camera &camera, top_ctx.dump(NULL, NULL); #endif - if (echotest_output_file) { - std::ofstream fstream( echotest_output_file ); - if (!fstream.is_open()) { - PRINTB("Can't open file \"%s\" for export", csg_output_file); - } else { - set_output_handler( echotest_output_handler, fstream ); - } - } + Echostream *echostream; + if (echo_output_file) echostream = new Echostream( echo_output_file ); FileModule *root_module; ModuleInstantiation root_inst("group"); @@ -273,6 +270,8 @@ int cmdline( const char* deps_output_file, const char* filename, Camera &camera, tree.setRoot(root_node); + if (echostream) echostream->close(); + if (csg_output_file) { fs::current_path(original_path); std::ofstream fstream(csg_output_file); @@ -320,8 +319,8 @@ int cmdline( const char* deps_output_file, const char* filename, Camera &camera, } else { #ifdef ENABLE_CGAL - if ((echotest_output_file || png_output_file) && !(renderer==Render::CGAL)) { - // echotest or OpenCSG png -> don't necessarily need CGALMesh evaluation + if ((echo_output_file || png_output_file) && !(renderer==Render::CGAL)) { + // echo or OpenCSG png -> don't necessarily need CGALMesh evaluation } else { root_N = cgalevaluator.evaluateCGALMesh(*tree.root()); } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4c4bf9f..61a3520 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -897,7 +897,7 @@ add_cmdline_test(csgtermtest EXE ${OPENSCAD_BINPATH} ARGS -o SUFFIX term FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/allexpressions.scad ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/allfunctions.scad ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/allmodules.scad) -add_cmdline_test(echotest EXE ${OPENSCAD_BINPATH} ARGS -o SUFFIX echotest FILES ${ECHO_FILES}) +add_cmdline_test(echotest EXE ${OPENSCAD_BINPATH} ARGS -o SUFFIX echo FILES ${ECHO_FILES}) add_cmdline_test(dumptest EXE ${OPENSCAD_BINPATH} ARGS -o dump SUFFIX csg FILES ${DUMPTEST_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}) diff --git a/tests/regression/echotest/builtin-tests-expected.txt b/tests/regression/echotest/builtin-tests-expected.echo index 385b0dc..385b0dc 100644 --- a/tests/regression/echotest/builtin-tests-expected.txt +++ b/tests/regression/echotest/builtin-tests-expected.echo diff --git a/tests/regression/echotest/dim-all-expected.txt b/tests/regression/echotest/dim-all-expected.echo index a16c580..a16c580 100644 --- a/tests/regression/echotest/dim-all-expected.txt +++ b/tests/regression/echotest/dim-all-expected.echo diff --git a/tests/regression/echotest/echo-expected.txt b/tests/regression/echotest/echo-expected.echo index 8fc094e..8fc094e 100644 --- a/tests/regression/echotest/echo-expected.txt +++ b/tests/regression/echotest/echo-expected.echo diff --git a/tests/regression/echotest/echo-tests-expected.txt b/tests/regression/echotest/echo-tests-expected.echo index d7ebe2f..d7ebe2f 100644 --- a/tests/regression/echotest/echo-tests-expected.txt +++ b/tests/regression/echotest/echo-tests-expected.echo diff --git a/tests/regression/echotest/escape-test-expected.txt b/tests/regression/echotest/escape-test-expected.echo index e69de29..e69de29 100644 --- a/tests/regression/echotest/escape-test-expected.txt +++ b/tests/regression/echotest/escape-test-expected.echo diff --git a/tests/regression/echotest/expression-shortcircuit-tests-expected.txt b/tests/regression/echotest/expression-shortcircuit-tests-expected.echo index d7f1c40..d7f1c40 100644 --- a/tests/regression/echotest/expression-shortcircuit-tests-expected.txt +++ b/tests/regression/echotest/expression-shortcircuit-tests-expected.echo diff --git a/tests/regression/echotest/inf-tests-expected.txt b/tests/regression/echotest/inf-tests-expected.echo index 7ac4fe9..7ac4fe9 100644 --- a/tests/regression/echotest/inf-tests-expected.txt +++ b/tests/regression/echotest/inf-tests-expected.echo diff --git a/tests/regression/echotest/len-tests-expected.txt b/tests/regression/echotest/len-tests-expected.echo index 2a776c0..2a776c0 100644 --- a/tests/regression/echotest/len-tests-expected.txt +++ b/tests/regression/echotest/len-tests-expected.echo diff --git a/tests/regression/echotest/lookup-tests-expected.txt b/tests/regression/echotest/lookup-tests-expected.echo index b98ebe2..b98ebe2 100644 --- a/tests/regression/echotest/lookup-tests-expected.txt +++ b/tests/regression/echotest/lookup-tests-expected.echo diff --git a/tests/regression/echotest/parser-tests-expected.txt b/tests/regression/echotest/parser-tests-expected.echo index 615726a..615726a 100644 --- a/tests/regression/echotest/parser-tests-expected.txt +++ b/tests/regression/echotest/parser-tests-expected.echo diff --git a/tests/regression/echotest/rands-expected.txt b/tests/regression/echotest/rands-expected.echo index 36ac6cd..36ac6cd 100644 --- a/tests/regression/echotest/rands-expected.txt +++ b/tests/regression/echotest/rands-expected.echo diff --git a/tests/regression/echotest/recursion-tests-expected.txt b/tests/regression/echotest/recursion-tests-expected.echo index e5c99b1..e5c99b1 100644 --- a/tests/regression/echotest/recursion-tests-expected.txt +++ b/tests/regression/echotest/recursion-tests-expected.echo diff --git a/tests/regression/echotest/search-tests-expected.txt b/tests/regression/echotest/search-tests-expected.echo index 0269f43..0269f43 100644 --- a/tests/regression/echotest/search-tests-expected.txt +++ b/tests/regression/echotest/search-tests-expected.echo diff --git a/tests/regression/echotest/string-indexing-expected.txt b/tests/regression/echotest/string-indexing-expected.echo index 3fcdfa4..3fcdfa4 100644 --- a/tests/regression/echotest/string-indexing-expected.txt +++ b/tests/regression/echotest/string-indexing-expected.echo diff --git a/tests/regression/echotest/string-test-expected.txt b/tests/regression/echotest/string-test-expected.echo index 1969a74..1969a74 100644 --- a/tests/regression/echotest/string-test-expected.txt +++ b/tests/regression/echotest/string-test-expected.echo diff --git a/tests/regression/echotest/value-reassignment-tests-expected.txt b/tests/regression/echotest/value-reassignment-tests-expected.echo index 344f7ab..344f7ab 100644 --- a/tests/regression/echotest/value-reassignment-tests-expected.txt +++ b/tests/regression/echotest/value-reassignment-tests-expected.echo diff --git a/tests/regression/echotest/value-reassignment-tests2-expected.txt b/tests/regression/echotest/value-reassignment-tests2-expected.echo index efb1be7..efb1be7 100644 --- a/tests/regression/echotest/value-reassignment-tests2-expected.txt +++ b/tests/regression/echotest/value-reassignment-tests2-expected.echo diff --git a/tests/regression/echotest/variable-scope-tests-expected.txt b/tests/regression/echotest/variable-scope-tests-expected.echo index 2a82090..2a82090 100644 --- a/tests/regression/echotest/variable-scope-tests-expected.txt +++ b/tests/regression/echotest/variable-scope-tests-expected.echo diff --git a/tests/regression/echotest/vector-values-expected.txt b/tests/regression/echotest/vector-values-expected.echo index 78053b9..78053b9 100644 --- a/tests/regression/echotest/vector-values-expected.txt +++ b/tests/regression/echotest/vector-values-expected.echo |