mirror of https://github.com/KLayout/klayout.git
Provisions for self-contained plugin tests
Plugin tests are not placed into a "*.klp_ut" shared object and are executed by the unit test runner.
This commit is contained in:
parent
eea686a5b9
commit
4e299d45f2
|
|
@ -36,7 +36,8 @@ mkqtdecl.tmp
|
||||||
# private data
|
# private data
|
||||||
private
|
private
|
||||||
src/plugins/*
|
src/plugins/*
|
||||||
!src/plugins/plugins.pro
|
!src/plugins/*.pro
|
||||||
|
!src/plugins/*.pri
|
||||||
|
|
||||||
# QTCreator files
|
# QTCreator files
|
||||||
src/klayout.pro.user
|
src/klayout.pro.user
|
||||||
|
|
|
||||||
|
|
@ -53,3 +53,15 @@ win32 {
|
||||||
} else {
|
} else {
|
||||||
QMAKE_CXXFLAGS += -fvisibility=hidden
|
QMAKE_CXXFLAGS += -fvisibility=hidden
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# define our own shared object extension since QMAKE_EXTENSION_SHLIB is blank on
|
||||||
|
# Linux
|
||||||
|
win32 {
|
||||||
|
SHLIB_EXT = dll
|
||||||
|
SHLIB_PREFIX =
|
||||||
|
} else {
|
||||||
|
SHLIB_EXT = so
|
||||||
|
SHLIB_PREFIX = lib
|
||||||
|
}
|
||||||
|
export(SHLIB_EXT)
|
||||||
|
export(SHLIB_PREFIX)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
|
||||||
|
DESTDIR_KLP = $$OUT_PWD/../../..
|
||||||
|
|
||||||
|
TEMPLATE = lib
|
||||||
|
|
||||||
|
INCLUDEPATH += ../../../db ../../../tl ../../../gsi ../../../laybasic ../../../lay ../../../common
|
||||||
|
DEPENDPATH += ../../../db ../../../tl ../../../gsi ../../../laybasic ../../../lay ../../../common
|
||||||
|
LIBS += -L$$DESTDIR_KLP -lklayout_db -lklayout_tl -lklayout_gsi -lklayout_laybasic -lklayout_lay
|
||||||
|
|
||||||
|
QMAKE_POST_LINK += $(COPY) $$OUT_PWD/$${SHLIB_PREFIX}$${TARGET}.$${SHLIB_EXT} $$DESTDIR_KLP/$${TARGET}.klp
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
|
||||||
|
DESTDIR_KLP = $$OUT_PWD/../../..
|
||||||
|
|
||||||
|
TEMPLATE = lib
|
||||||
|
|
||||||
|
INCLUDEPATH += ../src ../../../db ../../../tl ../../../gsi ../../../laybasic ../../../lay ../../../common ../../../ut
|
||||||
|
DEPENDPATH += ../src ../../../db ../../../tl ../../../gsi ../../../laybasic ../../../lay ../../../common ../../../ut
|
||||||
|
LIBS += -L$$DESTDIR_KLP -lklayout_db -lklayout_tl -lklayout_gsi -lklayout_laybasic -lklayout_lay -lklayout_ut
|
||||||
|
|
||||||
|
QMAKE_POST_LINK += $(COPY) $$OUT_PWD/$${SHLIB_PREFIX}$${TARGET}.$${SHLIB_EXT} $$DESTDIR_KLP/$${TARGET}.klp_ut
|
||||||
|
|
@ -3,5 +3,7 @@ TEMPLATE = subdirs
|
||||||
# Automatically include all sub-folders, but not the .pro file
|
# Automatically include all sub-folders, but not the .pro file
|
||||||
SUBDIR_LIST = $$files($$PWD/*)
|
SUBDIR_LIST = $$files($$PWD/*)
|
||||||
SUBDIR_LIST -= $$PWD/plugins.pro
|
SUBDIR_LIST -= $$PWD/plugins.pro
|
||||||
|
SUBDIR_LIST -= $$PWD/plugin.pri
|
||||||
|
SUBDIR_LIST -= $$PWD/plugin_ut.pri
|
||||||
|
|
||||||
SUBDIRS = $$SUBDIR_LIST
|
SUBDIRS = $$SUBDIR_LIST
|
||||||
|
|
|
||||||
|
|
@ -44,10 +44,11 @@
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
# include <sys/ioctl.h>
|
# include <sys/ioctl.h>
|
||||||
|
# include <dlfcn.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
# include <Windows.h>
|
# include <Windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -799,6 +800,42 @@ main_cont (int argc, char **argv)
|
||||||
pya::PythonInterpreter::initialize ();
|
pya::PythonInterpreter::initialize ();
|
||||||
gsi::initialize_external ();
|
gsi::initialize_external ();
|
||||||
|
|
||||||
|
// Search and initialize plugin unit tests
|
||||||
|
|
||||||
|
QStringList name_filters;
|
||||||
|
name_filters << QString::fromUtf8 ("*.klp_ut");
|
||||||
|
|
||||||
|
QDir inst_dir (tl::to_qstring (tl::get_inst_path ()));
|
||||||
|
QStringList inst_modules = inst_dir.entryList (name_filters);
|
||||||
|
inst_modules.sort ();
|
||||||
|
|
||||||
|
for (QStringList::const_iterator im = inst_modules.begin (); im != inst_modules.end (); ++im) {
|
||||||
|
|
||||||
|
QFileInfo klp_file (inst_dir.path (), *im);
|
||||||
|
if (klp_file.exists () && klp_file.isReadable ()) {
|
||||||
|
|
||||||
|
std::string pp = tl::to_string (klp_file.absoluteFilePath ());
|
||||||
|
tl::log << "Loading plugin unit tests " << pp;
|
||||||
|
|
||||||
|
// NOTE: since we are using a different suffix ("*.klp_ut"), we can't use QLibrary.
|
||||||
|
#ifdef _WIN32
|
||||||
|
// there is no "dlopen" on mingw, so we need to emulate it.
|
||||||
|
HINSTANCE handle = LoadLibraryW ((const wchar_t *) tl::to_qstring (pp).constData ());
|
||||||
|
if (! handle) {
|
||||||
|
throw tl::Exception (tl::to_string (QObject::tr ("Unable to load plugin tests: %s with error message: %s ")), pp, GetLastError ());
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void *handle;
|
||||||
|
handle = dlopen (tl::string_to_system (pp).c_str (), RTLD_LAZY);
|
||||||
|
if (! handle) {
|
||||||
|
throw tl::Exception (tl::to_string (QObject::tr ("Unable to load plugin tests: %s")), pp);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// No side effects
|
// No side effects
|
||||||
tl::set_klayout_path (std::vector<std::string> ());
|
tl::set_klayout_path (std::vector<std::string> ());
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue