Skip to content

Conversation

@dbaarda
Copy link
Member

@dbaarda dbaarda commented Aug 9, 2021

This makes all tests pass on Windows when libpopt is installed so rdiff is built and tested. This includes;

  • Tidy and simplify cmake/FindPOPT.cmake.
  • Fix bash test scripts invoked by cmake to work on Windows.
  • Add .gitattributes to ensure test data is binary

Note libpopt is now available on windows in the vcpkg package repository. It can used to compile and test rdiff on Windows like this;

$ vcpkg --triplet x64-windows install libpopt
$ cmake -B build -DCMAKE_BUILD_TYPE=Release \
 -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
$ cmake --build build --config Release --target check

dbaarda added 3 commits August 9, 2021 22:41
The arguments given to `find_path()` and `find_library()` either matched the
default values, were redundant, or were better fixed by setting
`CMAKE_PREFIX_PATH` to point at the popt install location in the cmake cmdline.

The POPT_ROOT_DIR location hint has also been removed, but note that cmake
3.12 adds support for using `<PackageName>_ROOT` as the first location hint by
default.
In CMakeLists.txt, explicity execute scripts with bash on WIN32 platforms (it
doesn't understand `#!/bin/sh`). Execute test scripts with the full rdiff path
expanded from `$<TARGET_FILE:rdiff>` as the first argument instead of
`${CMAKE_CURRENT_BINARY_DIR}`.

Update tests/testcommon.sh to set `RDIFF` instead of `bindir` from $1, and use
`${RDIFF}` as the rdiff binary in all tests.

Change rdiff_bad_option.sh to use testcommon.sh and use $RDIFF to execute the
rdiff binary. Make it use the testcommon.sh created tmpdir and use set -x to
trace only the interesting cmds instead of the whole script.

The $<TARGET_FILE:rdiff> is always the full path of the generated binary,
including the .exe extension on Windows. The ${CMAKE_CURRENT_BINARY_DIR} is
usually the directory where the generated binary is, but multi-configuration
generators (Visual Studio, Ninja) add a per-build-type directory (Release,
Debug, etc) and put them in there.

This means ${CMAKE_CURRENT_BINARY_DIR} doesn't give you an easy way to find
the binary, and doesn't tell you if it has a .exe extension. Passing in the
full binary path solves all these problems. Fortunately the tests only need
the rdiff binary.
This is important to ensure that git doesn't apply "\n" -> "\r\n" text
conversions on checkout for Windows platforms. Changing the data files like
this breaks the tests that use them.
@dbaarda dbaarda merged commit dbfeede into librsync:master Aug 9, 2021
@dbaarda dbaarda mentioned this pull request Aug 9, 2021
@dbaarda dbaarda deleted the dev/winrdiff1 branch August 9, 2021 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant