2018-06-03 23:36:06 +02:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
KLayout Layout Viewer
|
2023-01-01 22:27:09 +01:00
|
|
|
Copyright (C) 2006-2023 Matthias Koefferlein
|
2018-06-03 23:36:06 +02:00
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
2018-06-20 23:19:26 +02:00
|
|
|
// Oh my god ... STRINGIFY(s) will get the argument with MACROS REPLACED.
|
|
|
|
|
// So if the PYTHONPATH is something like build.linux-released, the "linux" macro
|
|
|
|
|
// set to 1 will make this "build.1-release". So STRINGIFY isn't a real solution.
|
|
|
|
|
// On the other hand that is the only documented way to turn a macro into a string.
|
|
|
|
|
// This will prevent that issue:
|
|
|
|
|
#undef linux
|
|
|
|
|
|
2018-06-03 23:36:06 +02:00
|
|
|
#define STRINGIFY(s) _STRINGIFY(s)
|
|
|
|
|
#define _STRINGIFY(s) #s
|
|
|
|
|
|
|
|
|
|
#include "tlUnitTest.h"
|
2018-07-04 20:26:34 +02:00
|
|
|
#include "tlStream.h"
|
2023-12-07 19:32:19 +01:00
|
|
|
#include "tlEnv.h"
|
2018-06-03 23:36:06 +02:00
|
|
|
|
2018-07-04 20:26:34 +02:00
|
|
|
int run_pymodtest (tl::TestBase *_this, const std::string &fn)
|
2018-06-03 23:36:06 +02:00
|
|
|
{
|
2023-12-07 19:32:19 +01:00
|
|
|
std::string pypath = STRINGIFY (PYTHONPATH);
|
|
|
|
|
tl::set_env ("PYTHONPATH", pypath);
|
2018-07-15 18:03:42 +02:00
|
|
|
tl::info << pypath;
|
2018-06-03 23:36:06 +02:00
|
|
|
|
2021-05-01 21:36:52 +02:00
|
|
|
std::string fp (tl::testdata ());
|
|
|
|
|
fp += "/pymod/";
|
2018-06-03 23:36:06 +02:00
|
|
|
fp += fn;
|
|
|
|
|
|
2018-07-04 20:26:34 +02:00
|
|
|
std::string text;
|
|
|
|
|
{
|
2018-10-09 22:56:32 +02:00
|
|
|
std::string cmd;
|
|
|
|
|
|
|
|
|
|
#if defined(__APPLE__)
|
|
|
|
|
// NOTE: because of system integrity, MacOS does not inherit DYLD_LIBRARY_PATH to child
|
|
|
|
|
// processes like sh. We need to port this variable explicitly.
|
|
|
|
|
const char *ldpath_name = "DYLD_LIBRARY_PATH";
|
|
|
|
|
const char *ldpath = getenv (ldpath_name);
|
|
|
|
|
if (ldpath) {
|
|
|
|
|
cmd += std::string (ldpath_name) + "=\"" + ldpath + "\"; export " + ldpath_name + "; ";
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
cmd += std::string ("\"") + STRINGIFY (PYTHON) + "\" " + fp + " 2>&1";
|
|
|
|
|
|
2018-09-02 00:40:35 +02:00
|
|
|
tl::info << cmd;
|
|
|
|
|
tl::InputPipe pipe (cmd);
|
2018-07-04 20:26:34 +02:00
|
|
|
tl::InputStream is (pipe);
|
|
|
|
|
text = is.read_all ();
|
2023-04-07 10:59:30 +02:00
|
|
|
|
|
|
|
|
// subprocess exits without error
|
|
|
|
|
EXPECT_EQ (pipe.wait(), 0);
|
2018-07-04 20:26:34 +02:00
|
|
|
}
|
2018-06-03 23:36:06 +02:00
|
|
|
|
2018-07-04 20:26:34 +02:00
|
|
|
tl::info << text;
|
|
|
|
|
EXPECT_EQ (text.find ("OK") != std::string::npos, true);
|
2018-06-20 22:25:03 +02:00
|
|
|
|
2018-07-04 20:26:34 +02:00
|
|
|
return 0;
|
2018-06-03 23:36:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define PYMODTEST(n, file) \
|
|
|
|
|
TEST(n) { EXPECT_EQ (run_pymodtest(_this, file), 0); }
|
|
|
|
|
|
2018-06-09 02:11:32 +02:00
|
|
|
PYMODTEST (bridge, "bridge.py")
|
|
|
|
|
|
2018-06-03 23:36:06 +02:00
|
|
|
PYMODTEST (import_tl, "import_tl.py")
|
|
|
|
|
PYMODTEST (import_db, "import_db.py")
|
2018-06-15 22:49:01 +02:00
|
|
|
PYMODTEST (import_rdb, "import_rdb.py")
|
2018-06-03 23:36:06 +02:00
|
|
|
PYMODTEST (import_lay, "import_lay.py")
|
2022-05-14 00:00:35 +02:00
|
|
|
|
2023-04-07 10:59:30 +02:00
|
|
|
// others
|
|
|
|
|
PYMODTEST (issue1327, "issue1327.py")
|
|
|
|
|
|
2022-05-14 00:00:35 +02:00
|
|
|
#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS)
|
2018-06-15 22:49:01 +02:00
|
|
|
|
2018-06-03 23:36:06 +02:00
|
|
|
PYMODTEST (import_QtCore, "import_QtCore.py")
|
2021-12-10 01:23:54 +01:00
|
|
|
#if QT_VERSION >= 0x60000
|
|
|
|
|
PYMODTEST (import_QtGui, "import_QtGui_Qt6.py")
|
|
|
|
|
#else
|
2018-06-03 23:36:06 +02:00
|
|
|
PYMODTEST (import_QtGui, "import_QtGui.py")
|
2021-12-10 01:23:54 +01:00
|
|
|
#endif
|
2021-03-02 23:28:35 +01:00
|
|
|
#if defined(HAVE_QT_XML)
|
2018-06-03 23:36:06 +02:00
|
|
|
PYMODTEST (import_QtXml, "import_QtXml.py")
|
2021-03-02 23:28:35 +01:00
|
|
|
#endif
|
|
|
|
|
#if defined(HAVE_QT_SQL)
|
2018-06-03 23:36:06 +02:00
|
|
|
PYMODTEST (import_QtSql, "import_QtSql.py")
|
2021-03-02 23:28:35 +01:00
|
|
|
#endif
|
|
|
|
|
#if defined(HAVE_QT_NETWORK)
|
2018-06-03 23:36:06 +02:00
|
|
|
PYMODTEST (import_QtNetwork, "import_QtNetwork.py")
|
2021-03-02 23:28:35 +01:00
|
|
|
#endif
|
2021-12-10 01:23:54 +01:00
|
|
|
#if defined(HAVE_QT_DESIGNER) && QT_VERSION < 0x60000
|
2018-06-03 23:36:06 +02:00
|
|
|
PYMODTEST (import_QtDesigner, "import_QtDesigner.py")
|
2021-03-02 23:28:35 +01:00
|
|
|
#endif
|
2021-02-26 23:59:23 +01:00
|
|
|
#if defined(HAVE_QT_UITOOLS)
|
2021-02-25 21:29:21 +01:00
|
|
|
PYMODTEST (import_QtUiTools, "import_QtUiTools.py")
|
2021-02-26 23:59:23 +01:00
|
|
|
#endif
|
|
|
|
|
|
2018-06-03 23:36:06 +02:00
|
|
|
#if QT_VERSION >= 0x50000
|
|
|
|
|
|
2021-12-10 01:23:54 +01:00
|
|
|
#if QT_VERSION >= 0x60000
|
|
|
|
|
PYMODTEST (import_QtWidgets, "import_QtWidgets_Qt6.py")
|
|
|
|
|
#else
|
2018-06-03 23:36:06 +02:00
|
|
|
PYMODTEST (import_QtWidgets, "import_QtWidgets.py")
|
2021-12-10 01:23:54 +01:00
|
|
|
#endif
|
2021-03-02 23:28:35 +01:00
|
|
|
#if defined(HAVE_QT_MULTIMEDIA)
|
2018-06-03 23:36:06 +02:00
|
|
|
PYMODTEST (import_QtMultimedia, "import_QtMultimedia.py")
|
2021-03-02 23:28:35 +01:00
|
|
|
#endif
|
|
|
|
|
#if defined(HAVE_QT_PRINTSUPPORT)
|
2018-06-03 23:36:06 +02:00
|
|
|
PYMODTEST (import_QtPrintSupport, "import_QtPrintSupport.py")
|
2021-03-02 23:28:35 +01:00
|
|
|
#endif
|
|
|
|
|
#if defined(HAVE_QT_SVG)
|
2021-12-10 01:23:54 +01:00
|
|
|
#if QT_VERSION >= 0x60000
|
|
|
|
|
PYMODTEST (import_QtSvg, "import_QtSvg_Qt6.py")
|
|
|
|
|
#else
|
2018-06-03 23:36:06 +02:00
|
|
|
PYMODTEST (import_QtSvg, "import_QtSvg.py")
|
2021-03-02 23:28:35 +01:00
|
|
|
#endif
|
2021-12-10 01:23:54 +01:00
|
|
|
#endif
|
|
|
|
|
#if defined(HAVE_QT_XML) && QT_VERSION < 0x60000
|
2018-06-03 23:36:06 +02:00
|
|
|
PYMODTEST (import_QtXmlPatterns, "import_QtXmlPatterns.py")
|
2021-03-02 23:28:35 +01:00
|
|
|
#endif
|
2018-06-03 23:36:06 +02:00
|
|
|
|
2021-12-11 15:17:16 +01:00
|
|
|
#if QT_VERSION >= 0x60000
|
2021-12-10 01:23:54 +01:00
|
|
|
PYMODTEST (import_QtCore5Compat, "import_QtCore5Compat.py")
|
|
|
|
|
#endif
|
|
|
|
|
|
2018-06-03 23:36:06 +02:00
|
|
|
#endif
|
2018-06-15 22:49:01 +02:00
|
|
|
|
2018-11-18 22:42:13 +01:00
|
|
|
PYMODTEST (import_pya, "pya_tests.py")
|
|
|
|
|
|
2018-06-15 22:49:01 +02:00
|
|
|
#endif
|