diff --git a/CMakeLists.txt b/CMakeLists.txt index dd06b917..5d281485 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,10 +14,14 @@ SET(MOO_PACKAGE_VENDOR ${MOO_EMAIL}) MOO_OPTION(MOO_BUILD_CTAGS ${MOO_OS_UNIX} "Build Ctags plugin" HIDDEN ${MOO_OS_WIN32} HEADER TRUE) MOO_OPTION(MOO_ENABLE_PROJECT FALSE "Build project plugin" HIDDEN TRUE) -MOO_OPTION(MOO_ENABLE_UNIT_TESTS FALSE "Build unit tests" DEFINE TRUE) MOO_OPTION(MOO_ENABLE_GENERATED_FILES ${MOO_OS_UNIX} "Run gtk-update-icon-cache on install") MOO_OPTION(MOO_BROKEN_GTK_THEME FALSE "Work around bugs in gtk theme" HEADER TRUE) +MOO_OPTION(MOO_ENABLE_UNIT_TESTS FALSE "Build unit tests" DEFINE TRUE) +IF(MOO_ENABLE_UNIT_TESTS) + ADD_DEFINITIONS(-DMOO_ENABLE_UNIT_TESTS) +ENDIF(MOO_ENABLE_UNIT_TESTS) + INCLUDE(cmake/gtk.cmake) INCLUDE(cmake/moo.cmake) INCLUDE(cmake/dist.cmake) @@ -56,6 +60,10 @@ IF(WIN32) CONFIGURE_FILE(plat/win32/run-medit.in run-medit.bat) SET(_MOO_RUN_HOW "gdb --args ") CONFIGURE_FILE(plat/win32/run-medit.in run-medit-in-gdb.bat) + IF(MOO_ENABLE_UNIT_TESTS) + SET(_MOO_RUN_HOW "@") + CONFIGURE_FILE(plat/win32/run-tests.in run-tests.bat) + ENDIF(MOO_ENABLE_UNIT_TESTS) ENDIF(WIN32) IF(NOT WIN32) diff --git a/medit/CMakeLists.txt b/medit/CMakeLists.txt index b04bf512..ac60592a 100644 --- a/medit/CMakeLists.txt +++ b/medit/CMakeLists.txt @@ -2,9 +2,9 @@ IF(MOO_ENABLE_PROJECT) ADD_DEFINITIONS(-DMOO_ENABLE_PROJECT) ENDIF(MOO_ENABLE_PROJECT) -IF(MOO_ENABLE_UNIT_TESTS AND NOT WIN32) +IF(MOO_ENABLE_UNIT_TESTS) ADD_DEFINITIONS(-DSRCDIR="${CMAKE_SOURCE_DIR}/medit") -ENDIF(MOO_ENABLE_UNIT_TESTS AND NOT WIN32) +ENDIF(MOO_ENABLE_UNIT_TESTS) IF(MOO_ENABLE_PYTHON) SET(moopythonlib moopython) @@ -34,7 +34,11 @@ IF(MOO_OS_LINUX) LIST(APPEND MOO_DEP_LIBS m dl) ENDIF(MOO_OS_LINUX) -ADD_EXECUTABLE(medit WIN32 ${MEDIT_SOURCES}) +IF(NOT MOO_ENABLE_UNIT_TESTS) + SET(MEDIT_WIN32 WIN32) +ENDIF(NOT MOO_ENABLE_UNIT_TESTS) + +ADD_EXECUTABLE(medit ${MEDIT_WIN32} ${MEDIT_SOURCES}) TARGET_LINK_LIBRARIES(medit ${medit_libs} ${MOO_DEP_LIBS}) INSTALL(TARGETS medit DESTINATION ${BINDIR}) @@ -45,8 +49,10 @@ ENDIF(MOO_ENABLE_PYTHON) FIND_PACKAGE(MooDesktopFile) MOO_INSTALL_DESKTOP_FILE(medit.desktop.in) -SET(PIXMAPS_DIR "${DATADIR}/pixmaps") -SET(ICONTHEME_DIR "${DATADIR}/icons/hicolor/48x48/apps") -SET(MEDIT_ICONS "${CMAKE_SOURCE_DIR}/moo/mooutils/pixmaps/medit.png") -INSTALL(FILES ${MEDIT_ICONS} DESTINATION "${PIXMAPS_DIR}") -INSTALL(FILES ${MEDIT_ICONS} DESTINATION "${ICONTHEME_DIR}") +IF(MOO_OS_UNIX) + SET(PIXMAPS_DIR "${DATADIR}/pixmaps") + SET(ICONTHEME_DIR "${DATADIR}/icons/hicolor/48x48/apps") + SET(MEDIT_ICONS "${CMAKE_SOURCE_DIR}/moo/mooutils/pixmaps/medit.png") + INSTALL(FILES ${MEDIT_ICONS} DESTINATION "${PIXMAPS_DIR}") + INSTALL(FILES ${MEDIT_ICONS} DESTINATION "${ICONTHEME_DIR}") +ENDIF(MOO_OS_UNIX) diff --git a/medit/run-tests.h b/medit/run-tests.h index 994cae10..63ba27b8 100644 --- a/medit/run-tests.h +++ b/medit/run-tests.h @@ -46,11 +46,7 @@ unit_tests_main (int argc, char *argv[]) g_thread_init (NULL); g_set_prgname ("run-tests"); -#ifdef __WIN32__ - data_dir = "test-data"; -#else data_dir = SRCDIR "/data"; -#endif grp = g_option_group_new ("run-tests", "run-tests", "run-tests", NULL, NULL); g_option_group_add_entries (grp, options); @@ -83,7 +79,7 @@ unit_tests_main (int argc, char *argv[]) moo_test_cleanup (); #ifdef __WIN32__ - if (!g_getenv ("WINESERVER")) + if (!g_getenv ("WINESERVER") && !list_only) { printf ("Done, press Enter..."); fflush (stdout); diff --git a/moo/mooedit/mooedit.c b/moo/mooedit/mooedit.c index a9029b1b..493d4dd8 100644 --- a/moo/mooedit/mooedit.c +++ b/moo/mooedit/mooedit.c @@ -2072,7 +2072,10 @@ test_encodings_1 (const char *name, editor = moo_editor_instance (); doc = moo_editor_open_file (editor, NULL, NULL, filename, encoding); - TEST_ASSERT (doc != NULL); + TEST_ASSERT_MSG (doc != NULL, + "file '%s', encoding '%s'", + TEST_FMT_STR (filename), + TEST_FMT_STR (encoding)); if (doc) { diff --git a/plat/win32/run-medit.in b/plat/win32/run-medit.in index 71b50a8f..e035cfa1 100644 --- a/plat/win32/run-medit.in +++ b/plat/win32/run-medit.in @@ -1,3 +1,3 @@ @pushd ${_MOO_BINARY_DIR}\moo -${_MOO_RUN_HOW}${_MOO_BINARY_DIR}\medit\medit.exe -n --log-window %1 %2 %3 %4 %5 %6 %7 %8 %9 +${_MOO_RUN_HOW}${_MOO_BINARY_DIR}\medit\medit.exe -n --log-window %* @popd diff --git a/plat/win32/run-tests.in b/plat/win32/run-tests.in new file mode 100644 index 00000000..fcbff5e1 --- /dev/null +++ b/plat/win32/run-tests.in @@ -0,0 +1,3 @@ +@pushd ${_MOO_BINARY_DIR} +${_MOO_RUN_HOW}${_MOO_BINARY_DIR}\medit\medit.exe --ut %* +@popd