From 4969d78c7f4a020e2d61fb850aec197b4e8a9ca3 Mon Sep 17 00:00:00 2001 From: Thomas Beutlich Date: Sat, 9 Mar 2024 15:24:22 +0100 Subject: [PATCH 1/4] Let tests succeed on Windows by ignoring CR --- contrib/tests/shpproj.sh | 2 +- tests/test1.sh | 2 +- tests/test2.sh | 2 +- tests/test3.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/tests/shpproj.sh b/contrib/tests/shpproj.sh index 7b20751..3cfb2d2 100755 --- a/contrib/tests/shpproj.sh +++ b/contrib/tests/shpproj.sh @@ -20,7 +20,7 @@ readonly SCRIPTDIR=$(dirname "${BASH_SOURCE[0]}") "${SHPDUMP:-$top_builddir/shpdump}" -precision 8 "test" > "test.out" -if result=$(diff "$SCRIPTDIR/expect.out" "test.out"); then +if result=$(diff --strip-trailing-cr "$SCRIPTDIR/expect.out" "test.out"); then echo "******* Test Succeeded *********" exit 0 else diff --git a/tests/test1.sh b/tests/test1.sh index 5d752b8..787892e 100755 --- a/tests/test1.sh +++ b/tests/test1.sh @@ -34,7 +34,7 @@ echo ------------------------------------------------------------------------- } > s1.out -if result=$(diff "$EXPECT" "s1.out"); then +if result=$(diff --strip-trailing-cr "$EXPECT" "s1.out"); then echo "******* Stream 1 Succeeded *********" exit 0 else diff --git a/tests/test2.sh b/tests/test2.sh index 6957f15..7615983 100755 --- a/tests/test2.sh +++ b/tests/test2.sh @@ -12,7 +12,7 @@ for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13; do "${SHPDUMP:-./shpdump}" test${i}.shp done > "s2.out" -if result=$(diff "$EXPECT" "s2.out"); then +if result=$(diff --strip-trailing-cr "$EXPECT" "s2.out"); then echo "******* Stream 2 Succeeded *********" exit 0 else diff --git a/tests/test3.sh b/tests/test3.sh index 0d149b5..fa2bed0 100755 --- a/tests/test3.sh +++ b/tests/test3.sh @@ -27,7 +27,7 @@ readonly EXPECT="${1:-$SCRIPTDIR/expect3.out}" "${DBFDUMP:-./dbfdump}" test.dbf } > s3.out -if result=$(diff "$EXPECT" "s3.out"); then +if result=$(diff --strip-trailing-cr "$EXPECT" "s3.out"); then echo "******* Stream 3 Succeeded *********" exit 0 else From 7dedb644800f3d265ef6fd4a7fda35592de9cbfe Mon Sep 17 00:00:00 2001 From: Thomas Beutlich Date: Sat, 9 Mar 2024 15:44:49 +0100 Subject: [PATCH 2/4] Run CTest on Windows via GitHub Actions --- .github/workflows/main.yml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e3cb2c1..7d70a6c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,6 +5,10 @@ on: pull_request: workflow_dispatch: +defaults: + run: + shell: bash + jobs: build-autoconf: name: linux-autoconf @@ -64,10 +68,20 @@ jobs: uses: actions/checkout@v4 - name: Configure (${{ matrix.configuration }}) - run: cmake -S . -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DCMAKE_UNITY_BUILD=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON + run: | + if [ "${{ matrix.compiler }}" == "msvc" ]; then + cmake -S . -Bbuild -DCMAKE_UNITY_BUILD=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DBUILD_TESTING=ON -DBASH_EXECUTABLE="C:/Program Files/Git/bin/bash.exe" + else + cmake -S . -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DCMAKE_UNITY_BUILD=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DBUILD_TESTING=ON + fi - name: Build with ${{ matrix.compiler }} - run: cmake --build build + run: | + if [ "${{ matrix.compiler }}" == "msvc" ]; then + cmake --build build --config ${{ matrix.configuration }} + else + cmake --build build + fi - name: Test - run: cd build && ctest -V . + run: ctest --test-dir build --build-config ${{ matrix.configuration }} --verbose From 8b8ea5dd86fd613adfe088798539546c611e2db1 Mon Sep 17 00:00:00 2001 From: Thomas Beutlich Date: Sat, 9 Mar 2024 15:51:18 +0100 Subject: [PATCH 3/4] Add cast --- shputils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shputils.c b/shputils.c index edda346..ceb1e82 100644 --- a/shputils.c +++ b/shputils.c @@ -107,7 +107,7 @@ double xshift = 0, yshift = 0; /* NO SHIFT */ /* -------------------------------------------------------------------- */ void setext(char *pt, const char *ext) { - int i = strlen(pt) - 1; + int i = (int)(strlen(pt) - 1); for (; i > 0 && pt[i] != '.' && pt[i] != '/' && pt[i] != '\\'; i--) { } @@ -278,7 +278,7 @@ void mergefields() int strncasecmp2(char *s1, char *s2, int n) { if (n < 1) - n = strlen(s1) + 1; + n = (int)(strlen(s1) + 1); for (int i = 0; i < n; i++) { From 7b014274f4b6ceeab8c2e18a0932220c4b601979 Mon Sep 17 00:00:00 2001 From: Thomas Beutlich Date: Sat, 9 Mar 2024 15:56:40 +0100 Subject: [PATCH 4/4] Run CTest on Windows only for static build --- .github/workflows/main.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7d70a6c..8aa4a96 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -45,7 +45,8 @@ jobs: toolchain: - linux-gcc - macos-clang - - windows-msvc + - windows-msvc-shared + - windows-msvc-static configuration: - Release @@ -59,7 +60,11 @@ jobs: os: macos-latest compiler: clang - - toolchain: windows-msvc + - toolchain: windows-msvc-shared + os: windows-latest + compiler: msvc + + - toolchain: windows-msvc-static os: windows-latest compiler: msvc @@ -69,8 +74,10 @@ jobs: - name: Configure (${{ matrix.configuration }}) run: | - if [ "${{ matrix.compiler }}" == "msvc" ]; then - cmake -S . -Bbuild -DCMAKE_UNITY_BUILD=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DBUILD_TESTING=ON -DBASH_EXECUTABLE="C:/Program Files/Git/bin/bash.exe" + if [ "${{ matrix.toolchain }}" == "windows-msvc-shared" ]; then + cmake -S . -Bbuild -DCMAKE_UNITY_BUILD=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DBUILD_SHARED_LIBS=ON + elif [ "${{ matrix.toolchain }}" == "windows-msvc-static" ]; then + cmake -S . -Bbuild -DCMAKE_UNITY_BUILD=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DBUILD_TESTING=ON -DBASH_EXECUTABLE="C:/Program Files/Git/bin/bash.exe" -DBUILD_SHARED_LIBS=OFF else cmake -S . -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DCMAKE_UNITY_BUILD=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DBUILD_TESTING=ON fi