From 4d44f9cfee1b587d713fbbc9be166fb3cde2504c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milo=C5=A1=20Komar=C4=8Devi=C4=87?= Date: Fri, 17 Dec 2021 18:55:46 +0100 Subject: [PATCH 1/3] Forward CI changes --- .github/workflows/on_PR_linux_matrix.yml | 2 - .../workflows/on_PR_linux_special_buils.yml | 24 ---- .github/workflows/on_PR_mac_matrix.yml | 2 - .github/workflows/on_PR_windows_matrix.yml | 132 ++++++++++++++++-- .../workflows/on_push_ExtraJobsForMain.yml | 2 - 5 files changed, 120 insertions(+), 42 deletions(-) diff --git a/.github/workflows/on_PR_linux_matrix.yml b/.github/workflows/on_PR_linux_matrix.yml index 71c69909f7..21ca38ed43 100644 --- a/.github/workflows/on_PR_linux_matrix.yml +++ b/.github/workflows/on_PR_linux_matrix.yml @@ -47,8 +47,6 @@ jobs: tree install - name: Test - env: - EXIV2_EXT: .exe run: | cd build ctest --output-on-failure diff --git a/.github/workflows/on_PR_linux_special_buils.yml b/.github/workflows/on_PR_linux_special_buils.yml index 613b4443fc..838288eb8f 100644 --- a/.github/workflows/on_PR_linux_special_buils.yml +++ b/.github/workflows/on_PR_linux_special_buils.yml @@ -37,8 +37,6 @@ jobs: cmake --build . - name: Tests + Upload coverage - env: - EXIV2_EXT: .exe run: | cd build ctest --output-on-failure @@ -85,8 +83,6 @@ jobs: cmake --build . - name: Tests with valgrind - env: - EXIV2_EXT: .exe run: | cd build/bin valgrind ./unit_tests @@ -123,8 +119,6 @@ jobs: cmake --build . - name: Tests - env: - EXIV2_EXT: .exe run: | cd build ctest --output-on-failure @@ -163,21 +157,3 @@ jobs: - name: Generate documentation run: | make doc - - special_FedoraMinGW: - name: 'Fedora MinGW' - runs-on: ubuntu-latest - container: - image: "fedora:latest" - - steps: - - uses: actions/checkout@v2 - - - name: install dependencies - run: | - dnf -y upgrade - dnf -y install mingw64-gcc-c++ mingw64-filesystem mingw64-expat mingw64-zlib cmake make - - - name: Build - run: - python3 ci/test_build.py --without-tests --cmake-executable "mingw64-cmake" --cmake-options "-DEXIV2_TEAM_EXTRA_WARNINGS=OFF -DEXIV2_TEAM_WARNINGS_AS_ERRORS=OFF -DEXIV2_ENABLE_WEBREADY=ON -DEXIV2_ENABLE_WIN_UNICODE=ON " --compilers --shared-libs OFF diff --git a/.github/workflows/on_PR_mac_matrix.yml b/.github/workflows/on_PR_mac_matrix.yml index 11226eb65f..d65f0b5717 100644 --- a/.github/workflows/on_PR_mac_matrix.yml +++ b/.github/workflows/on_PR_mac_matrix.yml @@ -40,8 +40,6 @@ jobs: cmake --build . --target install - name: Test - env: - EXIV2_EXT: .exe run: | cd build ctest --output-on-failure diff --git a/.github/workflows/on_PR_windows_matrix.yml b/.github/workflows/on_PR_windows_matrix.yml index 9f0180ed04..780a8a55d3 100644 --- a/.github/workflows/on_PR_windows_matrix.yml +++ b/.github/workflows/on_PR_windows_matrix.yml @@ -19,7 +19,7 @@ jobs: build_type: [Release, Debug] shared_libraries: [ON, OFF] platform: [ x64, x86 ] - + steps: - uses: actions/checkout@v2 @@ -28,7 +28,7 @@ jobs: with: arch: ${{matrix.platform}} - - name: Setup Ninja + - name: Set up Ninja uses: ashutoshvarma/setup-ninja@master with: version: 1.10.0 @@ -38,7 +38,7 @@ jobs: with: python-version: 3.7 - - name: Restore conan cache + - name: Restore Conan cache uses: actions/cache@v2 with: path: ${{github.workspace}}/conanCache @@ -68,23 +68,131 @@ jobs: conan install .. --build missing dir .. tree /f ../conanCache - + - name: Build run: | - cd build - cmake -GNinja -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBUILD_SHARED_LIBS=${{matrix.shared_libraries}} -DEXIV2_ENABLE_NLS=OFF -DEXIV2_ENABLE_PNG=ON -DEXIV2_ENABLE_WEBREADY=ON -DEXIV2_BUILD_UNIT_TESTS=ON -DEXIV2_ENABLE_WIN_UNICODE=OFF -DEXIV2_TEAM_WARNINGS_AS_ERRORS=ON -DEXIV2_ENABLE_BMFF=ON -DCMAKE_INSTALL_PREFIX=install .. - ninja + cmake -GNinja ` + -DCMAKE_BUILD_TYPE=${{matrix.build_type}} ` + -DBUILD_SHARED_LIBS=${{matrix.shared_libraries}} ` + -DEXIV2_ENABLE_NLS=OFF ` + -DEXIV2_ENABLE_WIN_UNICODE=OFF ` + -DEXIV2_ENABLE_WEBREADY=ON ` + -DEXIV2_ENABLE_BMFF=ON ` + -DEXIV2_BUILD_UNIT_TESTS=ON ` + -DEXIV2_TEAM_WARNINGS_AS_ERRORS=ON ` + -DCMAKE_INSTALL_PREFIX=install ` + -S . -B build && ` + cmake --build build - name: Install run: | cd build - ninja install + cmake --install . tree /f install - name: Test if: ${{matrix.platform == 'x64'}} - env: - EXIV2_EXT: .exe run: | - cd build - ctest --output-on-failure + ctest --test-dir build --output-on-failure + + msys2: + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + build_type: [Release, Debug] + shared_libraries: [ON, OFF] + sys: [MINGW64] + name: MSYS2 ${{matrix.sys}} - BuildType:${{matrix.build_type}} - SHARED:${{matrix.shared_libraries}} + defaults: + run: + shell: msys2 {0} + steps: + - uses: actions/checkout@v2 + + - name: Set up MSYS2 + uses: msys2/setup-msys2@v2 + with: + msystem: ${{matrix.sys}} + update: true + install: >- + base-devel + pacboy: >- + toolchain:p + cmake:p + ninja:p + expat:p + gettext:p + gtest:p + libiconv:p + python-lxml:p + zlib:p + + - name: Build + run: | + cmake -GNinja \ + -DCMAKE_CXX_FLAGS=-Wno-deprecated \ + -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ + -DBUILD_SHARED_LIBS=${{matrix.shared_libraries}} \ + -DEXIV2_ENABLE_NLS=ON \ + -DEXIV2_ENABLE_WIN_UNICODE=ON \ + -DEXIV2_ENABLE_WEBREADY=ON \ + -DEXIV2_ENABLE_BMFF=ON \ + -DEXIV2_BUILD_UNIT_TESTS=ON \ + -S . -B build && \ + cmake --build build + + - name: Test + run: | + ctest --test-dir build --output-on-failure + + cygwin: + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + build_type: [Release] + shared_libraries: [ON] + platform: [x64] + name: Cygwin ${{matrix.platform}} - BuildType:${{matrix.build_type}} - SHARED:${{matrix.shared_libraries}} + env: + SHELLOPTS: igncr + defaults: + run: + shell: C:\tools\cygwin\bin\bash.exe -eo pipefail '{0}' + steps: + # Make sure we don't check out scripts using Windows CRLF line endings + - run: git config --global core.autocrlf input + shell: pwsh + - uses: actions/checkout@v2 + + - name: Set up Cygwin + uses: egor-tensin/setup-cygwin@v3 + with: + platform: ${{matrix.platform}} + packages: >- + gcc-g++ + cmake + ninja + libexpat-devel + libxml2-devel + libxslt-devel + python38-lxml + zlib-devel + - name: Build + run: | + cmake -GNinja \ + -DCMAKE_CXX_FLAGS=-Wno-deprecated \ + -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ + -DBUILD_SHARED_LIBS=${{matrix.shared_libraries}} \ + -DEXIV2_ENABLE_NLS=OFF \ + -DEXIV2_ENABLE_WIN_UNICODE=OFF \ + -DEXIV2_ENABLE_WEBREADY=ON \ + -DEXIV2_ENABLE_BMFF=ON \ + -DEXIV2_BUILD_UNIT_TESTS=OFF \ + -S . -B build && \ + cmake --build build + + - name: Test + run: | + ctest --test-dir build --output-on-failure diff --git a/.github/workflows/on_push_ExtraJobsForMain.yml b/.github/workflows/on_push_ExtraJobsForMain.yml index 9bb7e7baf2..1a5e34f021 100644 --- a/.github/workflows/on_push_ExtraJobsForMain.yml +++ b/.github/workflows/on_push_ExtraJobsForMain.yml @@ -38,8 +38,6 @@ jobs: make -j - name: Tests + Upload coverage - env: - EXIV2_EXT: .exe run: | cd build ctest --output-on-failure From 82adcb1f86def0555b25713a8b84dba84944b275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milo=C5=A1=20Komar=C4=8Devi=C4=87?= Date: Fri, 17 Dec 2021 20:45:58 +0100 Subject: [PATCH 2/3] Do not use exact string match for errno output --- unitTests/test_futils.cpp | 46 ++------------------------------------- 1 file changed, 2 insertions(+), 44 deletions(-) diff --git a/unitTests/test_futils.cpp b/unitTests/test_futils.cpp index 723ed7121c..2bb4dc81ec 100644 --- a/unitTests/test_futils.cpp +++ b/unitTests/test_futils.cpp @@ -42,28 +42,8 @@ TEST(strError, returnSuccessAfterClosingFile) std::string tmpFile("tmp.dat"); std::ofstream auxFile(tmpFile.c_str()); auxFile.close(); - bool useExactString{true}; -#if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW__) || defined(__MSYS__) - const char * expectedString = "No error (errno = 0)"; -#elif defined(__APPLE__) - const char * expectedString = "Undefined error: 0 (errno = 0)"; -#elif defined(__sun__) - const char * expectedString = "Error 0 (errno = 0)"; -#elif defined(__FreeBSD__) - const char * expectedString = "No error: 0 (errno = 0)"; -#elif defined(__NetBSD__) - const char * expectedString = "Undefined error: 0 (errno = 0)"; -#else - // On Alpine we get 'No error information (errno = 0)' instead of 'Success (errno = 0)' - const char * expectedString = "(errno = 0)"; - useExactString = false; -#endif std::remove(tmpFile.c_str()); - if (useExactString) { - ASSERT_STREQ(expectedString, strError().c_str()); - } else { - ASSERT_TRUE(strError().find(expectedString) != std::string::npos); - } + ASSERT_TRUE(strError().find("(errno = 0)") != std::string::npos); } TEST(strError, returnNoSuchFileOrDirectoryWhenTryingToOpenNonExistingFile) @@ -75,29 +55,7 @@ TEST(strError, returnNoSuchFileOrDirectoryWhenTryingToOpenNonExistingFile) TEST(strError, doNotRecognizeUnknownError) { errno = 9999; - bool useExactString{true}; -#if defined(__MINGW__) || defined(__MSYS__) || defined(__CYGWIN__) - const char * expectedString = "Unknown error 9999 (errno = 9999)"; -#elif defined(_WIN32) - const char * expectedString = "Unknown error (errno = 9999)"; -#elif defined(__APPLE__) - const char * expectedString = "Unknown error: 9999 (errno = 9999)"; -#elif defined(__sun__) - const char * expectedString = "Unknown error (errno = 9999)"; -#elif defined(__FreeBSD__) - const char * expectedString = "Unknown error: 9999 (errno = 9999)"; -#elif defined(__NetBSD__) - const char * expectedString = "Unknown error: 9999 (errno = 9999)"; -#else - // On Alpine we get 'No error information (errno = 9999)' instead of 'Unknown error 9999 (errno = 9999)' - const char * expectedString = "(errno = 9999)"; - useExactString = false; -#endif - if (useExactString) { - ASSERT_STREQ(expectedString, strError().c_str()); - } else { - ASSERT_TRUE(strError().find(expectedString) != std::string::npos); - } + ASSERT_TRUE(strError().find("(errno = 9999)") != std::string::npos); } TEST(getEnv, getsDefaultValueWhenExpectedEnvVariableDoesNotExist) From 23c5100f9868aa1486ab0af2d75dc3e616e091bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milo=C5=A1=20Komar=C4=8Devi=C4=87?= <4973094+kmilos@users.noreply.github.com> Date: Sat, 18 Dec 2021 18:17:25 +0100 Subject: [PATCH 3/3] Improve config file platform test --- exiv2.md | 12 ++++++------ tests/lens_tests/test_config_file.py | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/exiv2.md b/exiv2.md index 8b83d49167..e50e1c1407 100644 --- a/exiv2.md +++ b/exiv2.md @@ -1326,7 +1326,7 @@ standards-defined metadata. With [--Modify cmd](#Modify_cmd), quotation marks are use to surround the *cmd*. The Windows command line requires double quotes to be used, however generally, quotes inside that string, can be either single -or double. Generally, UNIX based systems can use pairs of single or +or double. Generally, Unix-based systems can use pairs of single or double quotes in any position. In both systems, inner string quotation marks may need to use the `\` escape sequence. @@ -1634,11 +1634,11 @@ For another example, see: https://www.exiv2.org/sample.html # 12 CONFIGURATION FILE **exiv2** can read an optional configuration file, which allows -additional lens definitions to be added to translated output. On UNIX -based systems, this file is called *.exiv2* and on Windows (including MinGW), -*exiv2.ini*. The file is searched for first in the current directory, -then in the home directory (on UNIX based systems, `~/` and on Windows, -`%USERPROFILE%\\`). +additional lens definitions to be added to translated output. On Unix-based +systems (including Cygwin), this file is called *.exiv2* and on Windows +(including MinGW), *exiv2.ini*. The file is searched for first in the +current directory, then in the home directory (`$HOME` on Unix-based +systems, and `%USERPROFILE%` on Windows). You can determine the name of the file and where it is searched for, with the command: diff --git a/tests/lens_tests/test_config_file.py b/tests/lens_tests/test_config_file.py index 667ca78d82..14b3c41745 100644 --- a/tests/lens_tests/test_config_file.py +++ b/tests/lens_tests/test_config_file.py @@ -6,11 +6,11 @@ # copy the example config file into current working directory -# and name it ".exiv2" on linux or "exiv2.ini" on Win +# and name it "exiv2.ini" on Win or ".exiv2" on other platforms class TmpConfigFile(system_tests.FileDecoratorBase): def setUp_file_action(self, expanded_file_name): config_file_path = os.path.dirname(os.path.abspath(__file__)) - fname = ".exiv2" if sys.platform == "linux" or sys.platform == "darwin" else "exiv2.ini" + fname = os.path.basename(system_tests.BT.verbose_version().get('config_path')) return shutil.copyfile(expanded_file_name, os.path.join(config_file_path, fname))