make echotest work on BSD, by adding .echo as recognized extension

issue480
Don Bright 2013-09-21 09:04:01 -05:00
parent 47ed2f1b12
commit efc6731774
22 changed files with 20 additions and 31 deletions

View File

@ -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:
------------------------------

View File

@ -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());
}

View File

@ -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})