summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--RELEASE_NOTES2
-rw-r--r--src/context.cc5
-rw-r--r--src/dxfdata.cc4
-rw-r--r--src/mainwin.cc39
-rw-r--r--src/module.cc10
-rw-r--r--src/module.h5
-rw-r--r--src/openscad.cc7
-rw-r--r--src/parser.y17
-rw-r--r--src/value.cc2
-rw-r--r--testdata/scad/misc/sfære.scad2
-rw-r--r--testdata/scad/misc/størrelse.scad1
-rw-r--r--testdata/scad/misc/value-reassignment-tests.scad4
-rw-r--r--tests/CMakeLists.txt135
-rw-r--r--tests/regression/echotest/value-reassignment-tests-expected.txt1
-rw-r--r--tests/regression/openscad-camcenter/example001-expected.pngbin0 -> 11662 bytes
-rw-r--r--tests/regression/openscad-camdist/example001-expected.pngbin0 -> 16360 bytes
-rw-r--r--tests/regression/openscad-cameye/example001-expected.pngbin0 -> 17829 bytes
-rw-r--r--tests/regression/openscad-cameye2/example001-expected.pngbin0 -> 11180 bytes
-rw-r--r--tests/regression/openscad-cameyeortho/example001-expected.pngbin0 -> 25997 bytes
-rw-r--r--tests/regression/openscad-camortho/example001-expected.pngbin0 -> 10309 bytes
-rw-r--r--tests/regression/openscad-camrot/example001-expected.pngbin0 -> 22427 bytes
-rw-r--r--tests/regression/openscad-camtrans/example001-expected.pngbin0 -> 13161 bytes
-rw-r--r--tests/regression/openscad-imgsize/example001-expected.pngbin0 -> 2503 bytes
-rw-r--r--tests/regression/openscad-imgstretch/example001-expected.pngbin0 -> 3441 bytes
-rw-r--r--tests/regression/openscad-imgstretch2/example001-expected.pngbin0 -> 3881 bytes
-rw-r--r--tests/regression/openscad-nonascii/sfære-expected.csg3
-rwxr-xr-xtests/test_cmdline_tool.py50
27 files changed, 186 insertions, 101 deletions
diff --git a/RELEASE_NOTES b/RELEASE_NOTES
index d1a02ed..9e2da81 100644
--- a/RELEASE_NOTES
+++ b/RELEASE_NOTES
@@ -8,6 +8,7 @@ o Mac: Added document icon
o Mac: Added auto-update check
o Commandline output to PNG, with various camera and rendering settings
o Regression test now creates single monolithic .html file for easier uploading
+o value reassignment is now less strict
Bugfixes:
o OpenCSG rendering sometimes crashed when rendering large models
@@ -18,6 +19,7 @@ o Fixed some issues related to ARM builds
o Changed multmatrix floating-point output to improve dumptest portability
o Regression test auto-starts & stops Xvfb / Xvnc if on headless unix machine
o CGAL triangulation more lenient- enables partial rendering of 'bad' DXF data
+o Fixes problem where local changes are overwritten on automatic reload when included files has changed.
OpenSCAD 2013.01
================
diff --git a/src/context.cc b/src/context.cc
index a2a8d13..97ea5b9 100644
--- a/src/context.cc
+++ b/src/context.cc
@@ -51,9 +51,8 @@ Context::Context(const Context *parent, const Module *library)
this->functions_p = &library->functions;
this->modules_p = &library->modules;
this->usedlibs_p = &library->usedlibs;
- for (size_t j = 0; j < library->assignments_var.size(); j++) {
- this->set_variable(library->assignments_var[j],
- library->assignments_expr[j]->evaluate(this));
+ BOOST_FOREACH(const std::string &var, library->assignments_var) {
+ this->set_variable(var, library->assignments.at(var)->evaluate(this));
}
}
else {
diff --git a/src/dxfdata.cc b/src/dxfdata.cc
index 2fd40ab..f34af51 100644
--- a/src/dxfdata.cc
+++ b/src/dxfdata.cc
@@ -389,10 +389,10 @@ DxfData::DxfData(double fn, double fs, double fa,
BOOST_FOREACH(const EntityList::value_type &i, unsupported_entities_list) {
if (layername.empty()) {
PRINTB("WARNING: Unsupported DXF Entity '%s' (%x) in %s.",
- i.first % i.second % QuotedString(QDir::current().relativeFilePath(QString::fromStdString(filename)).toStdString()));
+ i.first % i.second % QuotedString(QDir::current().relativeFilePath(QString::fromLocal8Bit(filename.c_str())).toLocal8Bit().constData()));
} else {
PRINTB("WARNING: Unsupported DXF Entity '%s' (%x) in layer '%s' of %s.",
- i.first % i.second % layername % QuotedString(QDir::current().relativeFilePath(QString::fromStdString(filename)).toStdString()));
+ i.first % i.second % layername % QuotedString(QDir::current().relativeFilePath(QString::fromLocal8Bit(filename.c_str())).toLocal8Bit().constData()));
}
}
diff --git a/src/mainwin.cc b/src/mainwin.cc
index c82e949..dd855fb 100644
--- a/src/mainwin.cc
+++ b/src/mainwin.cc
@@ -522,7 +522,7 @@ MainWindow::setFileName(const QString &filename)
this->fileName = fileinfo.fileName();
}
- this->root_ctx.setDocumentPath(fileinfo.dir().absolutePath().toStdString());
+ this->root_ctx.setDocumentPath(fileinfo.dir().absolutePath().toLocal8Bit().constData());
QDir::setCurrent(fileinfo.dir().absolutePath());
}
@@ -586,13 +586,13 @@ void MainWindow::refreshDocument()
QFile file(this->fileName);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
PRINTB("Failed to open file %s: %s",
- this->fileName.toStdString() % file.errorString().toStdString());
+ this->fileName.toLocal8Bit().constData() % file.errorString().toLocal8Bit().constData());
}
else {
QTextStream reader(&file);
reader.setCodec("UTF-8");
QString text = reader.readAll();
- PRINTB("Loaded design '%s'.", this->fileName.toStdString());
+ PRINTB("Loaded design '%s'.", this->fileName.toLocal8Bit().constData());
editor->setPlainText(text);
}
}
@@ -904,13 +904,13 @@ void MainWindow::actionSave()
setCurrentOutput();
QFile file(this->fileName);
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
- PRINTB("Failed to open file for writing: %s (%s)", this->fileName.toStdString() % file.errorString().toStdString());
+ PRINTB("Failed to open file for writing: %s (%s)", this->fileName.toLocal8Bit().constData() % file.errorString().toLocal8Bit().constData());
}
else {
QTextStream writer(&file);
writer.setCodec("UTF-8");
writer << this->editor->toPlainText();
- PRINTB("Saved design '%s'.", this->fileName.toStdString());
+ PRINTB("Saved design '%s'.", this->fileName.toLocal8Bit().constData());
this->editor->setContentModified(false);
}
clearCurrentOutput();
@@ -1040,8 +1040,9 @@ bool MainWindow::compileTopLevelDocument(bool reload)
{
bool shouldcompiletoplevel = !reload;
- if ((reload && fileChangedOnDisk() && checkEditorModified()) ||
- includesChanged()) {
+ if (includesChanged()) shouldcompiletoplevel = true;
+
+ if (reload && fileChangedOnDisk() && checkEditorModified()) {
shouldcompiletoplevel = true;
refreshDocument();
}
@@ -1053,7 +1054,8 @@ bool MainWindow::compileTopLevelDocument(bool reload)
this->last_compiled_doc = editor->toPlainText();
std::string fulltext =
- this->last_compiled_doc.toStdString() + "\n" + commandline_commands;
+ std::string(this->last_compiled_doc.toLocal8Bit().constData()) +
+ "\n" + commandline_commands;
delete this->root_module;
this->root_module = NULL;
@@ -1292,7 +1294,7 @@ void MainWindow::actionDisplayAST()
e->setWindowTitle("AST Dump");
e->setReadOnly(true);
if (root_module) {
- e->setPlainText(QString::fromStdString(root_module->dump("", "")));
+ e->setPlainText(QString::fromLocal8Bit(root_module->dump("", "").c_str()));
} else {
e->setPlainText("No AST to dump. Please try compiling first...");
}
@@ -1310,7 +1312,7 @@ void MainWindow::actionDisplayCSGTree()
e->setWindowTitle("CSG Tree Dump");
e->setReadOnly(true);
if (this->root_node) {
- e->setPlainText(QString::fromStdString(this->tree.getString(*this->root_node)));
+ e->setPlainText(QString::fromLocal8Bit(this->tree.getString(*this->root_node).c_str()));
} else {
e->setPlainText("No CSG to dump. Please try compiling first...");
}
@@ -1327,7 +1329,12 @@ void MainWindow::actionDisplayCSGProducts()
e->setTabStopWidth(30);
e->setWindowTitle("CSG Products Dump");
e->setReadOnly(true);
- e->setPlainText(QString("\nCSG before normalization:\n%1\n\n\nCSG after normalization:\n%2\n\n\nCSG rendering chain:\n%3\n\n\nHighlights CSG rendering chain:\n%4\n\n\nBackground CSG rendering chain:\n%5\n").arg(root_raw_term ? QString::fromStdString(root_raw_term->dump()) : "N/A", root_norm_term ? QString::fromStdString(root_norm_term->dump()) : "N/A", this->root_chain ? QString::fromStdString(this->root_chain->dump()) : "N/A", highlights_chain ? QString::fromStdString(highlights_chain->dump()) : "N/A", background_chain ? QString::fromStdString(background_chain->dump()) : "N/A"));
+ e->setPlainText(QString("\nCSG before normalization:\n%1\n\n\nCSG after normalization:\n%2\n\n\nCSG rendering chain:\n%3\n\n\nHighlights CSG rendering chain:\n%4\n\n\nBackground CSG rendering chain:\n%5\n")
+ .arg(root_raw_term ? QString::fromLocal8Bit(root_raw_term->dump().c_str()) : "N/A",
+ root_norm_term ? QString::fromLocal8Bit(root_norm_term->dump().c_str()) : "N/A",
+ this->root_chain ? QString::fromLocal8Bit(this->root_chain->dump().c_str()) : "N/A",
+ highlights_chain ? QString::fromLocal8Bit(highlights_chain->dump().c_str()) : "N/A",
+ background_chain ? QString::fromLocal8Bit(background_chain->dump().c_str()) : "N/A"));
e->show();
e->resize(600, 400);
clearCurrentOutput();
@@ -1375,7 +1382,7 @@ void MainWindow::actionExportSTLorOFF(bool)
std::ofstream fstream(stl_filename.toUtf8());
if (!fstream.is_open()) {
- PRINTB("Can't open file \"%s\" for export", stl_filename.toStdString());
+ PRINTB("Can't open file \"%s\" for export", stl_filename.toLocal8Bit().constData());
}
else {
if (stl_mode) export_stl(this->root_N, fstream);
@@ -1428,7 +1435,7 @@ void MainWindow::actionExportDXF()
std::ofstream fstream(dxf_filename.toUtf8());
if (!fstream.is_open()) {
- PRINTB("Can't open file \"%s\" for export", dxf_filename.toStdString());
+ PRINTB("Can't open file \"%s\" for export", dxf_filename.toLocal8Bit().constData());
}
else {
export_dxf(this->root_N, fstream);
@@ -1461,7 +1468,7 @@ void MainWindow::actionExportCSG()
std::ofstream fstream(csg_filename.toUtf8());
if (!fstream.is_open()) {
- PRINTB("Can't open file \"%s\" for export", csg_filename.toStdString());
+ PRINTB("Can't open file \"%s\" for export", csg_filename.toLocal8Bit().constData());
}
else {
fstream << this->tree.getString(*this->root_node) << "\n";
@@ -1481,7 +1488,7 @@ void MainWindow::actionExportImage()
if (img_filename.isEmpty()) {
PRINT("No filename specified. Image export aborted.");
} else {
- qglview->save(img_filename.toStdString().c_str());
+ qglview->save(img_filename.toLocal8Bit().constData());
}
clearCurrentOutput();
return;
@@ -1831,7 +1838,7 @@ void MainWindow::consoleOutput(const std::string &msg, void *userdata)
// originates in a worker thread.
MainWindow *thisp = static_cast<MainWindow*>(userdata);
QMetaObject::invokeMethod(thisp->console, "append", Qt::QueuedConnection,
- Q_ARG(QString, QString::fromStdString(msg)));
+ Q_ARG(QString, QString::fromLocal8Bit(msg.c_str())));
}
void MainWindow::setCurrentOutput()
diff --git a/src/module.cc b/src/module.cc
index cfd73cc..e6dcb57 100644
--- a/src/module.cc
+++ b/src/module.cc
@@ -136,7 +136,7 @@ std::vector<AbstractNode*> IfElseModuleInstantiation::evaluateElseChildren(const
Module::~Module()
{
- BOOST_FOREACH (Expression *v, assignments_expr) delete v;
+ BOOST_FOREACH (const AssignmentContainer::value_type &v, assignments) delete v.second;
BOOST_FOREACH (FunctionContainer::value_type &f, functions) delete f.second;
BOOST_FOREACH (AbstractModuleContainer::value_type &m, modules) delete m.second;
BOOST_FOREACH (ModuleInstantiation *v, children) delete v;
@@ -158,8 +158,8 @@ AbstractNode *Module::evaluate(const Context *ctx, const ModuleInstantiation *in
else
c.usedlibs_p = NULL;
- for (size_t i = 0; i < assignments_var.size(); i++) {
- c.set_variable(assignments_var[i], assignments_expr[i]->evaluate(&c));
+ BOOST_FOREACH(const std::string &var, assignments_var) {
+ c.set_variable(var, assignments.at(var)->evaluate(&c));
}
AbstractNode *node = new AbstractNode(inst);
@@ -192,8 +192,8 @@ std::string Module::dump(const std::string &indent, const std::string &name) con
BOOST_FOREACH(const AbstractModuleContainer::value_type &m, modules) {
dump << m.second->dump(indent + tab, m.first);
}
- for (size_t i = 0; i < assignments_var.size(); i++) {
- dump << indent << tab << assignments_var[i] << " = " << *assignments_expr[i] << ";\n";
+ BOOST_FOREACH(const std::string &var, assignments_var) {
+ dump << indent << tab << var << " = " << *assignments.at(var) << ";\n";
}
for (size_t i = 0; i < children.size(); i++) {
dump << children[i]->dump(indent + tab);
diff --git a/src/module.h b/src/module.h
index 879d249..cc82f81 100644
--- a/src/module.h
+++ b/src/module.h
@@ -74,8 +74,9 @@ public:
bool is_handling_dependencies;
bool handleDependencies();
- std::vector<std::string> assignments_var;
- std::vector<Expression*> assignments_expr;
+ std::list<std::string> assignments_var;
+ typedef boost::unordered_map<std::string, Expression*> AssignmentContainer;
+ AssignmentContainer assignments;
typedef boost::unordered_map<std::string, class AbstractFunction*> FunctionContainer;
FunctionContainer functions;
diff --git a/src/openscad.cc b/src/openscad.cc
index 682ccb7..f7cc48e 100644
--- a/src/openscad.cc
+++ b/src/openscad.cc
@@ -49,6 +49,7 @@
#endif
#include <QApplication>
+#include <QString>
#include <QDir>
#include <sstream>
@@ -294,7 +295,7 @@ int main(int argc, char **argv)
examplesdir = exdir.path();
}
- parser_init(QApplication::instance()->applicationDirPath().toStdString());
+ parser_init(QApplication::instance()->applicationDirPath().toLocal8Bit().constData());
// Initialize global visitors
NodeCache nodecache;
@@ -492,7 +493,7 @@ int main(int argc, char **argv)
#endif
QString qfilename;
- if (filename) qfilename = QString::fromStdString(boosty::stringy(boosty::absolute(filename)));
+ if (filename) qfilename = QString::fromLocal8Bit(boosty::stringy(boosty::absolute(filename)).c_str());
#if 0 /*** disabled by clifford wolf: adds rendering artefacts with OpenCSG ***/
// turn on anti-aliasing
@@ -507,7 +508,7 @@ int main(int argc, char **argv)
if (vm.count("input-file")) {
inputFiles = vm["input-file"].as<vector<string> >();
for (vector<string>::const_iterator infile = inputFiles.begin()+1; infile != inputFiles.end(); infile++) {
- new MainWindow(QString::fromStdString(boosty::stringy((original_path / *infile))));
+ new MainWindow(QString::fromLocal8Bit(boosty::stringy(original_path / *infile).c_str()));
}
}
app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
diff --git a/src/parser.y b/src/parser.y
index 3e485ff..536f4ef 100644
--- a/src/parser.y
+++ b/src/parser.y
@@ -151,19 +151,10 @@ statement:
}
} |
TOK_ID '=' expr ';' {
- bool add_new_assignment = true;
- for (size_t i = 0; i < currmodule->assignments_var.size(); i++) {
- if (currmodule->assignments_var[i] != $1)
- continue;
- delete currmodule->assignments_expr[i];
- currmodule->assignments_expr[i] = $3;
- add_new_assignment = false;
- }
- if (add_new_assignment) {
- currmodule->assignments_var.push_back($1);
- currmodule->assignments_expr.push_back($3);
- free($1);
- }
+ std::list<std::string>::iterator found = std::find(currmodule->assignments_var.begin(), currmodule->assignments_var.end(),$1);
+ if (found != currmodule->assignments_var.end()) currmodule->assignments_var.erase(found);
+ currmodule->assignments_var.push_back($1);
+ currmodule->assignments[$1] = $3;
} |
TOK_MODULE TOK_ID '(' arguments_decl optional_commas ')' {
Module *p = currmodule;
diff --git a/src/value.cc b/src/value.cc
index 5712e33..f14f826 100644
--- a/src/value.cc
+++ b/src/value.cc
@@ -39,7 +39,7 @@
std::ostream &operator<<(std::ostream &stream, const Filename &filename)
{
- stream << QuotedString(QDir::current().relativeFilePath(QString::fromStdString(filename)).toStdString());
+ stream << QuotedString(QDir::current().relativeFilePath(QString::fromLocal8Bit(filename.c_str())).toLocal8Bit().constData());
return stream;
}
diff --git a/testdata/scad/misc/sfære.scad b/testdata/scad/misc/sfære.scad
new file mode 100644
index 0000000..df47b51
--- /dev/null
+++ b/testdata/scad/misc/sfære.scad
@@ -0,0 +1,2 @@
+include <størrelse.scad>
+sphere(radius);
diff --git a/testdata/scad/misc/størrelse.scad b/testdata/scad/misc/størrelse.scad
new file mode 100644
index 0000000..508de48
--- /dev/null
+++ b/testdata/scad/misc/størrelse.scad
@@ -0,0 +1 @@
+radius=10;
diff --git a/testdata/scad/misc/value-reassignment-tests.scad b/testdata/scad/misc/value-reassignment-tests.scad
new file mode 100644
index 0000000..475f78f
--- /dev/null
+++ b/testdata/scad/misc/value-reassignment-tests.scad
@@ -0,0 +1,4 @@
+myval = 2;
+i = 2;
+myval = i * 2;
+echo(myval);
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index c8eacfb..5eecaae 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -674,11 +674,11 @@ endfunction()
#
# This functions adds cmd-line tests given files.
#
-# Usage add_cmdline_test(testname [EXE <executable>] [ARGS <args to exe>]
+# Usage add_cmdline_test(testbasename [EXE <executable>] [ARGS <args to exe>]
# [EXPECTEDDIR <shared dir>] SUFFIX <suffix> FILES <test files>)
#
find_package(PythonInterp)
-function(add_cmdline_test TESTCMD)
+function(add_cmdline_test TESTCMD_BASENAME)
cmake_parse_arguments(TESTCMD "" "EXE;SUFFIX;EXPECTEDDIR" "FILES;ARGS" ${ARGN})
# If sharing results with another test, pass on this to the python script
@@ -686,18 +686,18 @@ function(add_cmdline_test TESTCMD)
set(EXTRA_OPTIONS -e ${TESTCMD_EXPECTEDDIR})
endif()
- get_filename_component(TESTCMD_NAME ${TESTCMD} NAME_WE)
-
- # If no executable was specified, assume it was built by us and resides here
- if (NOT TESTCMD_EXE)
- set(TESTCMD_EXE ${CMAKE_BINARY_DIR}/${TESTCMD})
+ if (TESTCMD_EXE)
+ set(TESTNAME_OPTION -t ${TESTCMD_BASENAME})
+ else()
+ # If no executable was specified, assume it was built by us and resides here
+ set(TESTCMD_EXE ${CMAKE_BINARY_DIR}/${TESTCMD_BASENAME})
endif()
# Add tests from args
foreach (SCADFILE ${TESTCMD_FILES})
- get_filename_component(TESTNAME ${SCADFILE} NAME_WE)
- string(REPLACE " " "_" TESTNAME ${TESTNAME}) # Test names cannot include spaces
- set(TEST_FULLNAME "${TESTCMD_NAME}_${TESTNAME}")
+ get_filename_component(FILE_BASENAME ${SCADFILE} NAME_WE)
+ string(REPLACE " " "_" FILE_BASENAME ${FILE_BASENAME}) # Test names cannot include spaces
+ set(TEST_FULLNAME "${TESTCMD_BASENAME}_${FILE_BASENAME}")
list(FIND DISABLED_TESTS ${TEST_FULLNAME} DISABLED)
if (${DISABLED} EQUAL -1)
@@ -719,10 +719,10 @@ function(add_cmdline_test TESTCMD)
# The python script cannot extract the testname when given extra parameters
if (TESTCMD_ARGS)
- set(TESTNAME_OPTION -t ${TESTNAME})
+ set(FILENAME_OPTION -f ${FILE_BASENAME})
endif()
- add_test(NAME ${TEST_FULLNAME} ${CONFARG} ${CONFVAL} COMMAND ${PYTHON_EXECUTABLE} ${tests_SOURCE_DIR}/test_cmdline_tool.py ${MINGW_CROSS_ARG} --comparator=${COMPARATOR} -c ${ImageMagick_convert_EXECUTABLE} -s ${TESTCMD_SUFFIX} ${EXTRA_OPTIONS} ${TESTNAME_OPTION} ${TESTCMD_EXE} "${SCADFILE}" ${TESTCMD_ARGS})
+ add_test(NAME ${TEST_FULLNAME} ${CONFARG} ${CONFVAL} COMMAND ${PYTHON_EXECUTABLE} ${tests_SOURCE_DIR}/test_cmdline_tool.py ${MINGW_CROSS_ARG} --comparator=${COMPARATOR} -c ${ImageMagick_convert_EXECUTABLE} -s ${TESTCMD_SUFFIX} ${EXTRA_OPTIONS} ${TESTNAME_OPTION} ${FILENAME_OPTION} ${TESTCMD_EXE} "${SCADFILE}" ${TESTCMD_ARGS})
set_property(TEST ${TEST_FULLNAME} PROPERTY ENVIRONMENT "${CTEST_ENVIRONMENT}")
endif()
endforeach()
@@ -763,7 +763,8 @@ list(APPEND ECHO_FILES ${FUNCTION_FILES}
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/string-indexing.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/vector-values.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/search-tests.scad
- ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/recursion-tests.scad)
+ ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/recursion-tests.scad
+ ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/value-reassignment-tests.scad)
list(APPEND DUMPTEST_FILES ${MINIMAL_FILES} ${FEATURES_FILES} ${EXAMPLE_FILES})
list(APPEND DUMPTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/escape-test.scad
@@ -781,8 +782,8 @@ list(APPEND THROWNTOGETHERTEST_FILES ${OPENCSGTEST_FILES})
list(APPEND CGALSTLSANITYTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/normal-nan.scad)
-list(APPEND GUICGALPNGTEST_FILES ${CGALPNGTEST_FILES})
-list(APPEND GUIOPENCSGTEST_FILES ${OPENCSGTEST_FILES})
+list(APPEND OPENSCAD-CGALPNG_FILES ${CGALPNGTEST_FILES})
+list(APPEND OPENSCAD-CSGPNG_FILES ${OPENCSGTEST_FILES})
# Disable tests which are known to cause floating point comparison issues
# Once we're capable of comparing these across platforms, we can put these back in
@@ -808,19 +809,19 @@ disable_tests(dumptest_transform-tests
# FIXME: This test illustrates a weakness in child() combined with modifiers.
# Reenable it when this is improved
disable_tests(opencsgtest_child-background)
-disable_tests(guiopencsgtest_child-background)
+disable_tests(openscad-csgpng_child-background)
# FIXME: This single test takes over an hour to run on a 2.7 GHz P4
disable_tests(opencsgtest_example006 cgalpngtest_example006)
-disable_tests(guiopencsgtest_example006 guicgalpngtest_example006)
+disable_tests(openscad-csgpng_example006 openscad-cgalpng_example006)
# These tests only makes sense in OpenCSG mode
disable_tests(cgalpngtest_child-background
cgalpngtest_highlight-and-background-modifier
cgalpngtest_testcolornames
- guicgalpngtest_child-background
- guicgalpngtest_highlight-and-background-modifier
- guicgalpngtest_testcolornames
+ openscad-cgalpng_child-background
+ openscad-cgalpng_highlight-and-background-modifier
+ openscad-cgalpng_testcolornames
throwntogethertest_child-background
throwntogethertest_highlight-and-background-modifier
throwntogethertest_testcolornames)
@@ -829,8 +830,8 @@ disable_tests(cgalpngtest_child-background
set_test_config(Heavy opencsgtest_minkowski3-tests
opencsgtest_projection-tests
- guiopencsgtest_minkowski3-tests
- guiopencsgtest_projection-tests
+ openscad-csgpng_minkowski3-tests
+ openscad-csgpng_projection-tests
throwntogethertest_minkowski3-tests
throwntogethertest_projection-tests
cgalpngtest_projection-tests
@@ -842,14 +843,14 @@ set_test_config(Heavy opencsgtest_minkowski3-tests
cgalpngtest_for-nested-tests
cgalpngtest_intersection-tests
cgalpngtest_text-search-test
- guicgalpngtest_projection-tests
- guicgalpngtest_rotate_extrude-tests
- guicgalpngtest_surface-tests
- guicgalpngtest_sphere-tests
- guicgalpngtest_minkowski3-tests
- guicgalpngtest_for-tests
- guicgalpngtest_for-nested-tests
- guicgalpngtest_intersection-tests)
+ openscad-cgalpng_projection-tests
+ openscad-cgalpng_rotate_extrude-tests
+ openscad-cgalpng_surface-tests
+ openscad-cgalpng_sphere-tests
+ openscad-cgalpng_minkowski3-tests
+ openscad-cgalpng_for-tests
+ openscad-cgalpng_for-nested-tests
+ openscad-cgalpng_intersection-tests)
foreach(FILE ${EXAMPLE_FILES})
get_test_fullname(cgalpngtest ${FILE} TEST_FULLNAME)
@@ -858,9 +859,9 @@ 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(guicgalpngtest ${FILE} TEST_FULLNAME)
+ get_test_fullname(openscad-cgalpng ${FILE} TEST_FULLNAME)
set_test_config(Examples ${TEST_FULLNAME})
- get_test_fullname(guiopencsgtest ${FILE} TEST_FULLNAME)
+ get_test_fullname(openscad-csgpng ${FILE} TEST_FULLNAME)
set_test_config(Examples ${TEST_FULLNAME})
endforeach()
@@ -914,17 +915,73 @@ add_cmdline_test(csgtermtest SUFFIX txt FILES ${MINIMAL_FILES})
add_cmdline_test(cgalpngtest SUFFIX png FILES ${CGALPNGTEST_FILES})
add_cmdline_test(opencsgtest SUFFIX png FILES ${OPENCSGTEST_FILES})
add_cmdline_test(throwntogethertest SUFFIX png FILES ${THROWNTOGETHERTEST_FILES})
-add_cmdline_test(guicgalpngtest EXE ${GUI_BINPATH} ARGS --render -o
- EXPECTEDDIR cgalpngtest SUFFIX png
- FILES ${GUICGALPNGTEST_FILES})
-add_cmdline_test(guiopencsgtest EXE ${GUI_BINPATH} ARGS -o
- EXPECTEDDIR opencsgtest SUFFIX png
- FILES ${GUICGALPNGTEST_FILES})
-
# FIXME: We don't actually need to compare the output of cgalstlsanitytest
# with anything. It's self-contained and returns != 0 on error
add_cmdline_test(cgalstlsanitytest SUFFIX txt FILES ${CGALSTLSANITYTEST_FILES})
+# Tests using the actual OpenSCAD binary
+
+# non-ASCII filenames
+add_cmdline_test(openscad-nonascii EXE ${GUI_BINPATH} ARGS -o
+ SUFFIX csg
+ FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/sfære.scad)
+
+
+# Image output
+add_cmdline_test(openscad-cgalpng EXE ${GUI_BINPATH} ARGS --render -o
+ EXPECTEDDIR cgalpngtest SUFFIX png
+ FILES ${OPENSCAD-CGALPNG_FILES})
+add_cmdline_test(openscad-csgpng EXE ${GUI_BINPATH} ARGS -o
+ EXPECTEDDIR opencsgtest SUFFIX png
+ FILES ${OPENSCAD-CGALPNG_FILES})
+
+add_cmdline_test(openscad-imgsize EXE ${GUI_BINPATH}
+ ARGS --imgsize 100,100 -o
+ SUFFIX png
+ FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad)
+add_cmdline_test(openscad-imgstretch EXE ${GUI_BINPATH}
+ ARGS --imgsize 500,100 -o
+ SUFFIX png
+ FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad)
+add_cmdline_test(openscad-imgstretch2 EXE ${GUI_BINPATH}
+ ARGS --imgsize 100,500 -o
+ SUFFIX png
+ FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad)
+add_cmdline_test(openscad-camdist EXE ${GUI_BINPATH}
+ ARGS --imgsize=500,500 --camera=0,0,0,0,0,0,300 examples/example001.scad -o
+ SUFFIX png
+ FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad)
+add_cmdline_test(openscad-camrot EXE ${GUI_BINPATH}
+ ARGS --imgsize=500,500 --camera=0,0,0,10,22.5,45,300 examples/example001.scad -o
+ SUFFIX png
+ FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad)
+add_cmdline_test(openscad-camtrans EXE ${GUI_BINPATH}
+ ARGS --imgsize=500,500 --camera=20,100,10,0,0,0,300 examples/example001.scad -o
+ SUFFIX png
+ FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad)
+add_cmdline_test(openscad-camortho EXE ${GUI_BINPATH}
+ ARGS --imgsize=500,500 --camera=20,100,10,0,0,0,300 examples/example001.scad --projection=o -o
+ SUFFIX png
+ FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad)
+add_cmdline_test(openscad-cameye EXE ${GUI_BINPATH}
+ ARGS --imgsize=500,500 --camera=60,40,30,0,0,0 examples/example001.scad -o
+ SUFFIX png
+ FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad)
+add_cmdline_test(openscad-cameye2 EXE ${GUI_BINPATH}
+ ARGS --imgsize=500,500 --camera=160,140,130,0,0,0 examples/example001.scad -o
+ SUFFIX png
+ FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad)
+add_cmdline_test(openscad-cameyeortho EXE ${GUI_BINPATH}
+ ARGS --imgsize=500,500 --camera=160,140,130,0,0,0 examples/example001.scad --projection=o -o
+ SUFFIX png
+ FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad)
+add_cmdline_test(openscad-camcenter EXE ${GUI_BINPATH}
+ ARGS --imgsize=500,500 --camera=60,40,30,20,10,30 -o
+ SUFFIX png
+ FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad)
+
+
+
message("Available test configurations: ${TEST_CONFIGS}")
#foreach(CONF ${TEST_CONFIGS})
# message("${CONF}: ${${CONF}_TEST_CONFIG}")
diff --git a/tests/regression/echotest/value-reassignment-tests-expected.txt b/tests/regression/echotest/value-reassignment-tests-expected.txt
new file mode 100644
index 0000000..05a6741
--- /dev/null
+++ b/tests/regression/echotest/value-reassignment-tests-expected.txt
@@ -0,0 +1 @@
+ECHO: 4
diff --git a/tests/regression/openscad-camcenter/example001-expected.png b/tests/regression/openscad-camcenter/example001-expected.png
new file mode 100644
index 0000000..5cdada7
--- /dev/null
+++ b/tests/regression/openscad-camcenter/example001-expected.png
Binary files differ
diff --git a/tests/regression/openscad-camdist/example001-expected.png b/tests/regression/openscad-camdist/example001-expected.png
new file mode 100644
index 0000000..363cc50
--- /dev/null
+++ b/tests/regression/openscad-camdist/example001-expected.png
Binary files differ
diff --git a/tests/regression/openscad-cameye/example001-expected.png b/tests/regression/openscad-cameye/example001-expected.png
new file mode 100644
index 0000000..ad7a8b0
--- /dev/null
+++ b/tests/regression/openscad-cameye/example001-expected.png
Binary files differ
diff --git a/tests/regression/openscad-cameye2/example001-expected.png b/tests/regression/openscad-cameye2/example001-expected.png
new file mode 100644
index 0000000..0315799
--- /dev/null
+++ b/tests/regression/openscad-cameye2/example001-expected.png
Binary files differ
diff --git a/tests/regression/openscad-cameyeortho/example001-expected.png b/tests/regression/openscad-cameyeortho/example001-expected.png
new file mode 100644
index 0000000..0de38bd
--- /dev/null
+++ b/tests/regression/openscad-cameyeortho/example001-expected.png
Binary files differ
diff --git a/tests/regression/openscad-camortho/example001-expected.png b/tests/regression/openscad-camortho/example001-expected.png
new file mode 100644
index 0000000..29c1083
--- /dev/null
+++ b/tests/regression/openscad-camortho/example001-expected.png
Binary files differ
diff --git a/tests/regression/openscad-camrot/example001-expected.png b/tests/regression/openscad-camrot/example001-expected.png
new file mode 100644
index 0000000..ecfd698
--- /dev/null
+++ b/tests/regression/openscad-camrot/example001-expected.png
Binary files differ
diff --git a/tests/regression/openscad-camtrans/example001-expected.png b/tests/regression/openscad-camtrans/example001-expected.png
new file mode 100644
index 0000000..1117751
--- /dev/null
+++ b/tests/regression/openscad-camtrans/example001-expected.png
Binary files differ
diff --git a/tests/regression/openscad-imgsize/example001-expected.png b/tests/regression/openscad-imgsize/example001-expected.png
new file mode 100644
index 0000000..52fb547
--- /dev/null
+++ b/tests/regression/openscad-imgsize/example001-expected.png
Binary files differ
diff --git a/tests/regression/openscad-imgstretch/example001-expected.png b/tests/regression/openscad-imgstretch/example001-expected.png
new file mode 100644
index 0000000..9d704c8
--- /dev/null
+++ b/tests/regression/openscad-imgstretch/example001-expected.png
Binary files differ
diff --git a/tests/regression/openscad-imgstretch2/example001-expected.png b/tests/regression/openscad-imgstretch2/example001-expected.png
new file mode 100644
index 0000000..92a93b6
--- /dev/null
+++ b/tests/regression/openscad-imgstretch2/example001-expected.png
Binary files differ
diff --git a/tests/regression/openscad-nonascii/sfære-expected.csg b/tests/regression/openscad-nonascii/sfære-expected.csg
new file mode 100644
index 0000000..e1ee757
--- /dev/null
+++ b/tests/regression/openscad-nonascii/sfære-expected.csg
@@ -0,0 +1,3 @@
+group() {
+ sphere($fn = 0, $fa = 12, $fs = 2, r = 10);
+}
diff --git a/tests/test_cmdline_tool.py b/tests/test_cmdline_tool.py
index 81a7795..eb01abd 100755
--- a/tests/test_cmdline_tool.py
+++ b/tests/test_cmdline_tool.py
@@ -32,17 +32,28 @@ def initialize_environment():
if not options.generate: options.generate = bool(os.getenv("TEST_GENERATE"))
return True
-def init_expected_filename(testname, cmd):
+def init_expected_filename():
global expecteddir, expectedfilename
+
+ expected_testname = options.testname
+
if hasattr(options, "expecteddir"):
- expected_basename = options.expecteddir
+ expected_dirname = options.expecteddir
else:
- expected_basename = os.path.split(cmd)[1]
+ expected_dirname = expected_testname
- expecteddir = os.path.join(options.regressiondir, expected_basename)
- expectedfilename = os.path.join(expecteddir, testname + "-expected." + options.suffix)
+ expecteddir = os.path.join(options.regressiondir, expected_dirname)
+ expectedfilename = os.path.join(expecteddir, options.filename + "-expected." + options.suffix)
expectedfilename = os.path.normpath(expectedfilename)
+def init_actual_filename():
+ global actualdir, actualfilename
+
+ cmdname = os.path.split(options.cmd)[1]
+ actualdir = os.path.join(os.getcwd(), options.testname + "-output")
+ actualfilename = os.path.join(actualdir, options.filename + "-actual." + options.suffix)
+ actualfilename = os.path.normpath(actualfilename)
+
def verify_test(testname, cmd):
global expectedfilename
if not options.generate:
@@ -133,17 +144,13 @@ def compare_with_expected(resultfilename):
def run_test(testname, cmd, args):
cmdname = os.path.split(options.cmd)[1]
- outputdir = os.path.join(os.getcwd(), cmdname + "-output")
- actualfilename = os.path.join(outputdir, testname + "-actual." + options.suffix)
- actualfilename = os.path.normpath(actualfilename)
-
if options.generate:
if not os.path.exists(expecteddir): os.makedirs(expecteddir)
outputname = expectedfilename
else:
- if not os.path.exists(outputdir): os.makedirs(outputdir)
+ if not os.path.exists(actualdir): os.makedirs(actualdir)
outputname = actualfilename
- outputname = os.path.normpath( outputname )
+ outputname = os.path.normpath(outputname)
outfile = open(outputname, "wb")
@@ -154,6 +161,7 @@ def run_test(testname, cmd, args):
cmdline = ['wine']+[cmd] + args + [outputname]
else:
cmdline = [cmd] + args + [outputname]
+ print cmdline
proc = subprocess.Popen(cmdline, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
errtext = proc.communicate()[1]
if errtext != None and len(errtext) > 0:
@@ -182,14 +190,15 @@ def usage():
print >> sys.stderr, " -g, --generate Generate expected output for the given tests"
print >> sys.stderr, " -s, --suffix=<suffix> Write -expected and -actual files with the given suffix instead of .txt"
print >> sys.stderr, " -e, --expected-dir=<dir> Use -expected files from the given dir (to share files between test drivers)"
- print >> sys.stderr, " -t, --test=<name> Specify test name instead of deducting it from the argument"
+ print >> sys.stderr, " -t, --test=<name> Specify test name instead of deducting it from the argument (defaults to basename <exe>)"
+ print >> sys.stderr, " -f, --file=<name> Specify test file instead of deducting it from the argument (default to basename <first arg>)"
print >> sys.stderr, " -c, --convexec=<name> Path to ImageMagick 'convert' executable"
print >> sys.stderr, " -x, --mingw-cross-env Mingw-cross-env cross compilation"
if __name__ == '__main__':
# Handle command-line arguments
try:
- opts, args = getopt.getopt(sys.argv[1:], "gs:e:c:t:m:x", ["generate", "convexec=", "suffix=", "expected_dir=", "test=", "comparator=", "mingw-cross-env"])
+ opts, args = getopt.getopt(sys.argv[1:], "gs:e:c:t:f:m:x", ["generate", "convexec=", "suffix=", "expected_dir=", "test=", "file=", "comparator=", "mingw-cross-env"])
except getopt.GetoptError, err:
usage()
sys.exit(2)
@@ -199,6 +208,7 @@ if __name__ == '__main__':
options.regressiondir = os.path.join(os.path.split(sys.argv[0])[0], "regression")
options.generate = False
options.suffix = "txt"
+ options.comparator = ""
for o, a in opts:
if o in ("-g", "--generate"): options.generate = True
@@ -209,6 +219,8 @@ if __name__ == '__main__':
options.expecteddir = a
elif o in ("-t", "--test"):
options.testname = a
+ elif o in ("-f", "--file"):
+ options.filename = a
elif o in ("-c", "--convexec"):
options.convert_exec = os.path.normpath( a )
elif o in ("-m", "--comparator"):
@@ -225,16 +237,20 @@ if __name__ == '__main__':
# If only one test file, we can usually deduct the test name from the file
if len(args) == 2:
basename = os.path.splitext(args[1])[0]
- path, options.testname = os.path.split(basename)
+ path, options.filename = os.path.split(basename)
- if not hasattr(options, "testname"):
- print >> sys.stderr, "Test name cannot be deducted from arguments. Specify test name using the -t option"
+ if not hasattr(options, "filename"):
+ print >> sys.stderr, "Filename cannot be deducted from arguments. Specify test filename using the -f option"
sys.exit(2)
+ if not hasattr(options, "testname"):
+ options.testname = os.path.split(args[0])[1]
+
# Initialize and verify run-time environment
if not initialize_environment(): sys.exit(1)
- init_expected_filename(options.testname, options.cmd)
+ init_expected_filename()
+ init_actual_filename()
# Verify test environment
verification = verify_test(options.testname, options.cmd)
contact: Jan Huwald // Impressum