diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 48502bebf..40b896906 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,6 +71,52 @@ jobs: LD_LIBRARY_PATH: ${{env.HOME}}/BUILD_${{matrix.arch_name}}/INSTALL/lib:${{env.HOME}}/BUILD_${{matrix.arch_name}}/INSTALL/lib64 run: meson test -C build --verbose + Windows: + runs-on: windows-2022 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup python 3.10 + uses: actions/setup-python@v5 + with: + python-version: '3.10' + + - name: Install packages + run: + choco install pkgconfiglite ninja + + - name: Install python modules + run: pip3 install meson + + - name: Setup MSVC compiler + uses: bus1/cabuild/action/msdevshell@v1 + with: + architecture: x64 + + - name: Install dependencies + uses: kiwix/kiwix-build/actions/dl_deps_archive@main + with: + target_platform: win-x86_64-static + + - name: Compile + shell: cmd + run: | + set PKG_CONFIG_PATH=%cd%\BUILD_win-amd64\INSTALL\lib\pkgconfig + set CPPFLAGS=-I%cd%\BUILD_win-amd64\INSTALL\include + meson.exe setup . build -Dwerror=false --default-library=static --buildtype=debug + cd build + ninja.exe + + - name: Test + shell: cmd + run: | + cd build + meson.exe test --verbose + env: + WAIT_TIME_FACTOR_TEST: 10 + Linux: strategy: fail-fast: false diff --git a/scripts/kiwix-compile-resources b/scripts/kiwix-compile-resources index 11391cce9..fca014e87 100755 --- a/scripts/kiwix-compile-resources +++ b/scripts/kiwix-compile-resources @@ -71,7 +71,7 @@ class Resource: for base_dir in base_dirs: try: with open(os.path.join(base_dir, filename), 'rb') as f: - self.data = f.read() + self.data = f.read().replace(b"\r\n", b"\n") found = True break except FileNotFoundError: diff --git a/src/tools/stringTools.cpp b/src/tools/stringTools.cpp index 690fcd65c..05ed6a198 100644 --- a/src/tools/stringTools.cpp +++ b/src/tools/stringTools.cpp @@ -257,7 +257,7 @@ std::string kiwix::urlDecode(const std::string& value, bool component) // If there aren't enough characters left for this to be a // valid escape code, just use the character and move on - if (it > value.end() - 3) { + if (value.end() - it < 3) { os << *it; continue; } diff --git a/test/book.cpp b/test/book.cpp index 55de4e2df..b69b8cf40 100644 --- a/test/book.cpp +++ b/test/book.cpp @@ -15,11 +15,19 @@ struct XMLDoc : pugi::xml_document } // unnamed namespace +#if _WIN32 +# define DATA_ABS_PATH "C:\\data\\zim" +# define ZARA_ABS_PATH "C:\\data\\zim\\zara.zim" +#else +# define DATA_ABS_PATH "/data/zim" +# define ZARA_ABS_PATH "/data/zim/zara.zim" +#endif + TEST(BookTest, updateFromXMLTest) { const XMLDoc xml(R"( getBookById("0d0bcd57-d3f6-cb22-44cc-a723ccb4e1b2"); - EXPECT_EQ("/data/zimfiles/unittest.zim", book.getPath()); + EXPECT_EQ(ZIM_ABS_PATH, book.getPath()); EXPECT_EQ("https://example.com/zimfiles/unittest.zim", book.getUrl()); EXPECT_EQ("Unit Test", book.getTitle()); EXPECT_EQ("Wikipedia articles about unit testing", book.getDescription()); diff --git a/test/name_mapper.cpp b/test/name_mapper.cpp index 74fecf481..371cc9d5f 100644 --- a/test/name_mapper.cpp +++ b/test/name_mapper.cpp @@ -7,6 +7,23 @@ namespace { +#if _WIN32 +const char libraryXML[] = R"( + + + + + + + + + + + + + +)"; +#else const char libraryXML[] = R"( @@ -22,6 +39,7 @@ const char libraryXML[] = R"( )"; +#endif class NameMapperTest : public ::testing::Test { public: @@ -61,7 +79,22 @@ public: operator std::string() const { return buffer.str(); } }; +#if _WIN32 +const std::string ZERO_FOUR_NAME_CONFLICT_MSG = + "Path collision: 'C:\\data\\zero_four_2021-10.zim' and" + " 'C:\\data\\zero_four_2021-11.zim' can't share the same URL path 'zero_four'." + " Therefore, only 'C:\\data\\zero_four_2021-10.zim' will be served.\n"; +const std::string ZERO_SIX_NAME_CONFLICT_MSG = + "Path collision: 'C:\\data\\zërô + SIX.zim' and " + "'C:\\data\\zero_plus_six.zim' can't share the same URL path 'zero_plus_six'." + " Therefore, only 'C:\\data\\zërô + SIX.zim' will be served.\n"; + +const std::string ZERO_SEVEN_NAME_CONFLICT_MSG = + "Path collision: 'C:\\data\\subdir\\zero_seven.zim' and" + " 'C:\\data\\zero_seven.zim' can't share the same URL path 'zero_seven'." + " Therefore, only 'C:\\data\\subdir\\zero_seven.zim' will be served.\n"; +#else const std::string ZERO_FOUR_NAME_CONFLICT_MSG = "Path collision: '/data/zero_four_2021-10.zim' and" " '/data/zero_four_2021-11.zim' can't share the same URL path 'zero_four'." @@ -76,6 +109,7 @@ const std::string ZERO_SEVEN_NAME_CONFLICT_MSG = "Path collision: '/data/subdir/zero_seven.zim' and" " '/data/zero_seven.zim' can't share the same URL path 'zero_seven'." " Therefore, only '/data/subdir/zero_seven.zim' will be served.\n"; +#endif // Name conflicts in the default mode (without the --nodatealiases is off const std::string DEFAULT_NAME_CONFLICTS = ZERO_SIX_NAME_CONFLICT_MSG