Skip to content

Commit

Permalink
Merge pull request #111 from thbeu/fix-diff-cmd
Browse files Browse the repository at this point in the history
Let CTest succeed on Windows by ignoring CR
  • Loading branch information
rouault authored Mar 9, 2024
2 parents 5fecb1f + 7b01427 commit 71a6552
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 11 deletions.
31 changes: 26 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
pull_request:
workflow_dispatch:

defaults:
run:
shell: bash

jobs:
build-autoconf:
name: linux-autoconf
Expand Down Expand Up @@ -41,7 +45,8 @@ jobs:
toolchain:
- linux-gcc
- macos-clang
- windows-msvc
- windows-msvc-shared
- windows-msvc-static

configuration:
- Release
Expand All @@ -55,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

Expand All @@ -64,10 +73,22 @@ 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.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
- 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
2 changes: 1 addition & 1 deletion contrib/tests/shpproj.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions shputils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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--)
{
}
Expand Down Expand Up @@ -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++)
{
Expand Down
2 changes: 1 addition & 1 deletion tests/test1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 71a6552

Please sign in to comment.