From 647a6300757e141a53a7e7ceb207f6211cb55009 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Tue, 7 Feb 2017 16:58:25 +0000 Subject: Fix tests on Windows (specifically, tested on MSYS2) --- tests/.gitignore | 4 ++++ unittests/.gitignore | 2 ++ unittests/EnchantBrokerTestFixture.h | 30 ++++++++++++++++++++---------- unittests/EnchantDictionaryTestFixture.h | 6 +++--- unittests/Makefile.am | 4 ++-- unittests/enchant_providers/.gitignore | 1 + unittests/enchant_providers/Makefile.am | 6 +++--- unittests/mock_provider/mock_provider.cpp | 2 +- unittests/pwl/enchant_pwl_tests.cpp | 6 +++--- 9 files changed, 39 insertions(+), 22 deletions(-) diff --git a/tests/.gitignore b/tests/.gitignore index c19e2a7..b6b3a4d 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -1,6 +1,10 @@ /enchant +/enchant.exe /enchant-lsmod +/enchant-lsmod.exe /ispell /enchant.test +/enchant.test.exe /enchantxx.test +/enchantxx.test.exe /test.pwl diff --git a/unittests/.gitignore b/unittests/.gitignore index 6497ea3..9a151be 100644 --- a/unittests/.gitignore +++ b/unittests/.gitignore @@ -1,2 +1,4 @@ /main +/main.exe libenchant_*.so +*enchant*.dll diff --git a/unittests/EnchantBrokerTestFixture.h b/unittests/EnchantBrokerTestFixture.h index 209b76d..01b176e 100644 --- a/unittests/EnchantBrokerTestFixture.h +++ b/unittests/EnchantBrokerTestFixture.h @@ -125,8 +125,8 @@ struct EnchantBrokerTestFixture : EnchantTestFixture userMockProviderConfiguration = userConfiguration; userMockProvider2Configuration = user2Configuration; - CopyProvider("libenchant_mock_provider", "libenchant_mock_provider"); - hModule = g_module_open("lib/enchant/libenchant_mock_provider", (GModuleFlags) 0); + CopyProvider("enchant_mock_provider", "enchant_mock_provider"); + hModule = g_module_open("lib/enchant/enchant_mock_provider", (GModuleFlags) 0); if(hModule!=NULL){ SET_CONFIGURE sc; assert(g_module_symbol(hModule, "set_configure", (gpointer *)&sc)); @@ -135,8 +135,8 @@ struct EnchantBrokerTestFixture : EnchantTestFixture hModule2 = NULL; if(user2Configuration != NULL){ - CopyProvider("libenchant_mock_provider2", "libenchant_mock_provider2"); - hModule2 = g_module_open("lib/enchant/libenchant_mock_provider2", (GModuleFlags) 0); + CopyProvider("enchant_mock_provider2", "enchant_mock_provider2"); + hModule2 = g_module_open("lib/enchant/enchant_mock_provider2", (GModuleFlags) 0); if(hModule2!=NULL){ SET_CONFIGURE sc; assert(g_module_symbol(hModule2, "set_configure", (gpointer *)&sc)); @@ -145,10 +145,10 @@ struct EnchantBrokerTestFixture : EnchantTestFixture } if(includeNullProviders){ - CopyProvider("libenchant_null_provider", "null_provider"); - CopyProvider("libenchant_null_identify", "null_identify"); - CopyProvider("libenchant_null_describe", "null_describe"); - CopyProvider("libenchant", "libenchant"); //not a provider + CopyProvider("enchant_null_provider", "null_provider"); + CopyProvider("enchant_null_identify", "null_identify"); + CopyProvider("enchant_null_describe", "null_describe"); + CopyProvider("enchant", "enchant"); //not a provider } #if _WIN32 @@ -183,8 +183,18 @@ struct EnchantBrokerTestFixture : EnchantTestFixture void CopyProvider(const std::string& sourceProviderName, const std::string& destinationProviderName) { - std::string sourceName = sourceProviderName +"."+ G_MODULE_SUFFIX; - std::string destinationName = destinationProviderName + "." +G_MODULE_SUFFIX; + std::string prefix = + // FIXME: Get this information from libtool +#if defined(__MSYS__) + "msys-" +#elif defined(__CYGWIN__) + "cyg" +#else + "lib" +#endif + ; + std::string sourceName = prefix + sourceProviderName + "." + G_MODULE_SUFFIX; + std::string destinationName = destinationProviderName + "." + G_MODULE_SUFFIX; std::string destinationDir = AddToPath(AddToPath(GetDirectoryOfThisModule(), "lib"),"enchant"); diff --git a/unittests/EnchantDictionaryTestFixture.h b/unittests/EnchantDictionaryTestFixture.h index aa5109c..e94e222 100644 --- a/unittests/EnchantDictionaryTestFixture.h +++ b/unittests/EnchantDictionaryTestFixture.h @@ -265,7 +265,7 @@ struct EnchantDictionaryTestFixture : EnchantBrokerTestFixture sleep(1); // FAT systems have a 2 second resolution // NTFS is appreciably faster but no specs on what it is exactly // c runtime library's time_t has a 1 second resolution - FILE * f = g_fopen(filename.c_str(), "at"); + FILE * f = g_fopen(filename.c_str(), "a"); if(f) { fputc('\n', f); @@ -279,7 +279,7 @@ struct EnchantDictionaryTestFixture : EnchantBrokerTestFixture sleep(1); // FAT systems have a 2 second resolution // NTFS is appreciably faster but no specs on what it is exactly // c runtime library's time_t has a 1 second resolution - FILE * f = g_fopen(GetPersonalDictFileName().c_str(), "at"); + FILE * f = g_fopen(GetPersonalDictFileName().c_str(), "a"); if(f) { fputc('\n', f); @@ -292,7 +292,7 @@ struct EnchantDictionaryTestFixture : EnchantBrokerTestFixture sleep(1); // FAT systems have a 2 second resolution // NTFS is appreciably faster but no specs on what it is exactly // c runtime library's time_t has a 1 second resolution - FILE * f = g_fopen(GetPersonalDictFileName().c_str(), "at"); + FILE * f = g_fopen(GetPersonalDictFileName().c_str(), "a"); if(f) { for (std::vector::const_iterator itWord = sWords.begin(); diff --git a/unittests/Makefile.am b/unittests/Makefile.am index 9e352c5..7948641 100644 --- a/unittests/Makefile.am +++ b/unittests/Makefile.am @@ -6,7 +6,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/src $(ENCHANT_CFLAGS) $(UNITTESTPP_CFLAGS) AM_TESTS_ENVIRONMENT = \ ENCHANT_MODULE_PATH=$(top_builddir)/unittests/lib/enchant; \ export ENCHANT_MODULE_PATH; \ - cp $(builddir)/mock_provider/*.so $(builddir)/mock_provider/.libs/*.so . || :; + cp $(builddir)/mock_provider/*.so $(builddir)/mock_provider/.libs/*.so $(builddir)/mock_provider/*.dll $(builddir)/mock_provider/.libs/*.dll . || :; DEPS = $(top_builddir)/src/libenchant.la ldadd = $(top_builddir)/src/libenchant.la $(ENCHANT_LIBS) @@ -53,4 +53,4 @@ main_LDFLAGS = main_DEPENDENCIES = $(DEPS) main_LDADD = $(ldadd) $(UNITTESTPP_LIBS) $(ENCHANT_LIBS) -DISTCLEANFILES = libenchant_*.so +DISTCLEANFILES = libenchant_*.so *enchant*.dll diff --git a/unittests/enchant_providers/.gitignore b/unittests/enchant_providers/.gitignore index 95811e0..824308f 100644 --- a/unittests/enchant_providers/.gitignore +++ b/unittests/enchant_providers/.gitignore @@ -1 +1,2 @@ /main +/main.exe diff --git a/unittests/enchant_providers/Makefile.am b/unittests/enchant_providers/Makefile.am index 3cbf489..acf2076 100644 --- a/unittests/enchant_providers/Makefile.am +++ b/unittests/enchant_providers/Makefile.am @@ -2,8 +2,8 @@ AM_CPPFLAGS = -I$(top_srcdir)/src $(ENCHANT_CFLAGS) $(UNITTESTPP_CFLAGS) # FIXME: .so extension will not work on Windows AM_TESTS_ENVIRONMENT = \ - cp $(builddir)/../mock_provider/*.so $(builddir)/../mock_provider/.libs/*.so . || :; \ - cp $(top_builddir)/src/*/*.so $(top_builddir)/src/*/.libs/*.so . || :; + cp $(builddir)/../mock_provider/*.so $(builddir)/../mock_provider/.libs/*.so $(builddir)/../mock_provider/*.dll $(builddir)/../mock_provider/.libs/*.dll . || :; + cp $(top_builddir)/src/*/*.so $(top_builddir)/src/*/.libs/*.so cp $(top_builddir)/src/*/*.dll $(top_builddir)/src/*/.libs/*.dll . || :; DEPS = $(top_builddir)/src/libenchant.la ldadd = $(top_builddir)/src/libenchant.la $(ENCHANT_LIBS) @@ -28,4 +28,4 @@ main_LDFLAGS = main_DEPENDENCIES = $(DEPS) main_LDADD = $(ldadd) $(UNITTESTPP_LIBS) -DISTCLEANFILES = libenchant_*.so +DISTCLEANFILES = libenchant_*.so *enchant*.dll diff --git a/unittests/mock_provider/mock_provider.cpp b/unittests/mock_provider/mock_provider.cpp index 3291541..5bed47c 100644 --- a/unittests/mock_provider/mock_provider.cpp +++ b/unittests/mock_provider/mock_provider.cpp @@ -101,4 +101,4 @@ configure_enchant_provider(EnchantProvider * me, const char *dir_name) } } -} \ No newline at end of file +} diff --git a/unittests/pwl/enchant_pwl_tests.cpp b/unittests/pwl/enchant_pwl_tests.cpp index 99e6394..90be9e8 100644 --- a/unittests/pwl/enchant_pwl_tests.cpp +++ b/unittests/pwl/enchant_pwl_tests.cpp @@ -201,7 +201,7 @@ TEST_FIXTURE(EnchantPwl_TestFixture, sleep(1); // FAT systems have a 2 second resolution // NTFS is appreciably faster but no specs on what it is exactly // c runtime library's time_t has a 1 second resolution - FILE * f = g_fopen(GetPersonalDictFileName().c_str(), "at"); + FILE * f = g_fopen(GetPersonalDictFileName().c_str(), "a"); if(f) { fputs(Utf8Bom, f); @@ -257,7 +257,7 @@ TEST_FIXTURE(EnchantPwl_TestFixture, sleep(1); // FAT systems have a 2 second resolution // NTFS is appreciably faster but no specs on what it is exactly // c runtime library's time_t has a 1 second resolution - FILE * f = g_fopen(GetPersonalDictFileName().c_str(), "at"); + FILE * f = g_fopen(GetPersonalDictFileName().c_str(), "a"); if(f) { fputs(sWords[0].c_str(), f); @@ -1153,7 +1153,7 @@ TEST_FIXTURE(EnchantPwl_TestFixture, sleep(1); // FAT systems have a 2 second resolution // NTFS is appreciably faster but no specs on what it is exactly // c runtime library's time_t has a 1 second resolution - FILE * f = g_fopen(GetPersonalDictFileName().c_str(), "at"); + FILE * f = g_fopen(GetPersonalDictFileName().c_str(), "a"); if(f) { fputs(Utf8Bom, f); for(std::vector::const_iterator itWord = sWords.begin(); -- cgit v1.2.1 From 730e6bf5a0eea0b00565f0f8875c4a0618f4c675 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Tue, 7 Feb 2017 17:46:21 +0000 Subject: Add appveyor.yml --- appveyor.yml | 20 ++++++++++++++++++++ build-aux/appveyor-install.sh | 12 ++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 appveyor.yml create mode 100755 build-aux/appveyor-install.sh diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..c0af82b --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,20 @@ +version: "{build}" + +environment: + global: + CONFIGURE_FLAGS: --with-myspell-dir=/mingw64/share/hunspell + VERBOSE: 1 # Get test logs in output + +# FIXME: Build on mingw-w64, mingw-w32 and MSYS2 +# matrix: +# - COMPILER: MinGW-w64 +# - COMPILER: MinGW-w32 + +init: + - git config --global core.autocrlf input + +install: + - C:\msys64\usr\bin\bash.exe -l c:/projects/enchant/build-aux/appveyor-install.sh + +build_script: + - C:\msys64\usr\bin\bash.exe -lc "cd c:/projects/enchant && ./autogen.sh %CONFIGURE_FLAGS% && make && make DISTCHECK_CONFIGURE_FLAGS=%CONFIGURE_FLAGS% distcheck" diff --git a/build-aux/appveyor-install.sh b/build-aux/appveyor-install.sh new file mode 100755 index 0000000..e24836a --- /dev/null +++ b/build-aux/appveyor-install.sh @@ -0,0 +1,12 @@ +#!/bin/sh +# Pre-install script for appveyor + +pacman --noconfirm -S glib2-devel +wget http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-hunspell-en-2016.11.20-2-any.pkg.tar.xz +pacman --noconfirm -U mingw-w64-x86_64-hunspell-en-2016.11.20-2-any.pkg.tar.xz +wget https://github.com/hunspell/hunspell/archive/v1.6.0.tar.gz +tar zxvf v1.6.0.tar.gz || true # Error in unpacking (symlink README before file README.md) +cd hunspell-1.6.0 && ln -s README.md README && autoreconf -vfi && ./configure --prefix=/usr && make && make install +wget https://github.com/unittest-cpp/unittest-cpp/releases/download/v1.6.1/unittest-cpp-1.6.1.tar.gz +tar zxvf unittest-cpp-1.6.1.tar.gz +cd unittest-cpp-1.6.1 && ./configure --prefix=/usr && make && make install -- cgit v1.2.1