Best-practise currently for testing internal parts of libs? *_TEST_EXPORT macro?
Friedrich W. H. Kossebau
kossebau at kde.org
Mon Aug 31 12:41:00 UTC 2015
Hi,
what approach is best-practise currently for testing internal parts of libs?
E.g. by symbols (classes) are not exported by default?
In Calligra we have code that uses XYZ_TEST_EXPORT macros for those symbols
which should be only exported in test-enabled builds, e.g. by defining
COMPILING_TESTS to true and having code in the export header like
#ifdef COMPILING_TESTS
#if defined _WIN32 || defined _WIN64
# if defined(calligrasheetsodf_EXPORTS)
# define CALLIGRA_SHEETS_ODF_TEST_EXPORT KDE_EXPORT
# else
# define CALLIGRA_SHEETS_ODF_TEST_EXPORT KDE_IMPORT
# endif
# else /* not windows */
# define CALLIGRA_SHEETS_ODF_TEST_EXPORT KDE_EXPORT
# endif
#else /* not compiling tests */
# define CALLIGRA_SHEETS_ODF_TEST_EXPORT
#endif
But when switching to generated export headers, using cmake's
generate_export_header macro, this seems no longer an option.
Grepping for TEST_EXPORT on lxr.kde.org points that this seems an older
approach which only might have survived in the island of Calligra :) when the
rest of KDE world evolved to something else?
So what are others doing?
The only place lxr.kde.org pointed out to use the *TEST_EXPORT approach was
grantlee, which simply creates a separate file with the define that then is
appended to the file generated with generate_export_header:
http://lxr.kde.org/source/grantlee/templates/lib/CMakeLists.txt
Seems a working hack which we could copy. But not sure if this is the best way
and if this should not be done more generically?
Cheers
Friedrich
More information about the Kde-buildsystem
mailing list